{
// Create a BTree with pages containing 8 elements
String path = tempFolder.getRoot().getCanonicalPath();
BTree<Integer, String> btree = BTreeFactory.createInMemoryBTree( "test", path, new IntSerializer(),
new StringSerializer() );
btree.setPageSize( 8 );
File journal = ( ( InMemoryBTree<Integer, String> ) btree ).getJournal();
File data = ( ( InMemoryBTree<Integer, String> ) btree ).getFile();
try
{
// Inject the values
for ( int value : sortedValues )
{
String strValue = "V" + value;
btree.insert( value, strValue );
}
// The journal must be full
assertTrue( journal.length() > 0 );
// Now, flush the btree
btree.flush();
// The journal must be empty
assertEquals( 0, journal.length() );
// Load the data into a new tree
BTree<Integer, String> btreeLoaded = BTreeFactory.createInMemoryBTree( "test", path, new IntSerializer(),
new StringSerializer() );
btree.setPageSize( 8 );
TupleCursor<Integer, String> cursor1 = btree.browse();
TupleCursor<Integer, String> cursor2 = btree.browse();