* We are also going to test to make sure the recman file doesn't grow (leak) if we repeat the
* process a number of times.
* @throws Exception
*/
public void testDeleteAllNodes() throws Exception {
RecordManager recman;
BTree<String, Serializable> tree;
// we are going to run this test without object cache enabled. If it is turned on,
// we will have problems with using a different deserializer for BPages than the standard
// serializer.
Properties props = new Properties();
props.setProperty(RecordManagerOptions.CACHE_TYPE, "none");
String recordManagerBasename = newTestFile();
String recordManagerDBname = recordManagerBasename+".dbr.0";
long previousRecmanSize = 0;
for (int i = 0; i < 5; i++){
recman = RecordManagerFactory.createRecordManager( recordManagerBasename, props );
try{
tree = BTree.createInstance( recman);
String[] keys = new String[1000];
for (int count = 0; count < 1000; count++){
keys[count] = "num" + count;
}
// put enough data into the tree so we definitely have multiple pages
for (int count = 0; count < 1000; count++){
tree.insert(keys[count],new Integer(count),false);
if (count % 100 == 0)
recman.commit();
}
recman.commit();
long currentRecmanSize = new File(recordManagerDBname).length();
assertTrue("file size too small "+ currentRecmanSize, currentRecmanSize > 0);
// now remove it all
for (int count = 0; count < 1000; count++){
tree.remove(keys[count]);
if (count % 100 == 0)
recman.commit();
}
recman.commit();
BPage root = tree.getRoot();
assertNull(root);
} finally {
recman.close();
long currentRecmanSize = new File(recordManagerDBname).length();
assertTrue("file size too small "+ currentRecmanSize, currentRecmanSize > 0);
if (previousRecmanSize != 0){
assertTrue(currentRecmanSize == previousRecmanSize);
}