1 21 package com.db4o.db4ounit.common.btree; 22 23 import com.db4o.*; 24 import com.db4o.foundation.*; 25 import com.db4o.inside.slots.*; 26 27 import db4ounit.*; 28 29 30 public class BTreeFreeTestCase extends BTreeTestCaseBase { 31 32 private static final int[] VALUES = new int[] { 1, 2, 5, 7, 8, 9, 12 }; 33 34 public static void main(String [] args) { 35 new BTreeFreeTestCase().runSolo(); 36 } 37 38 public void test(){ 39 40 add(VALUES); 41 42 Iterator4 allSlotIDs = _btree.allNodeIds(systemTrans()); 43 44 Collection4 allSlots = new Collection4(); 45 46 while(allSlotIDs.moveNext()){ 47 Integer slotID = (Integer )allSlotIDs.current(); 48 Slot slot = fileTransaction().getCurrentSlotOfID(slotID.intValue()); 49 allSlots.add(slot); 50 } 51 52 YapFile yapFile = (YapFile)stream(); 53 54 55 final Collection4 freedSlots = new Collection4(); 56 57 yapFile.installDebugFreespaceManager( 58 new FreespaceManagerForDebug(yapFile, new SlotListener() { 59 public void onFree(Slot slot) { 60 freedSlots.add(slot); 61 } 62 })); 63 64 _btree.free(systemTrans()); 65 66 systemTrans().commit(); 67 68 Assert.isTrue(freedSlots.containsAll(allSlots.iterator())); 69 70 } 71 72 private YapFileTransaction fileTransaction() { 73 return ((YapFileTransaction)trans()); 74 } 75 76 } 77 | Popular Tags |