* Test to insert different objects into one btree. (cdaller)
*/
@Test
public void testInsert() throws IOException
{
RecordManager recman;
BTree<String, Object> tree;
recman = RecordManagerFactory.createRecordManager( getTemporaryFile( "testInsert" ) );
tree = new BTree<String, Object>( recman, new StringComparator() );
// insert different objects and retrieve them
tree.insert( "test1", "value1", false );
tree.insert( "test2", "value2", false );
tree.insert( "one", Integer.valueOf( 1 ), false );
tree.insert( "two", Long.valueOf( 2 ), false );
tree.insert( "myownobject", new ObjectStore( Integer.valueOf( 234 ) ), false );
assertEquals( "value2", tree.find( "test2" ) );
assertEquals( "value1", tree.find( "test1" ) );
assertEquals( Integer.valueOf( 1 ), tree.find( "one" ) );
assertEquals( Long.valueOf( 2 ), tree.find( "two" ) );
// what happens here? must not be replaced, does it return anything?
// probably yes!
assertEquals( "value1", tree.insert( "test1", "value11", false ) );
assertEquals( "value1", tree.find( "test1" ) ); // still the old value?
assertEquals( "value1", tree.insert( "test1", "value11", true ) );
assertEquals( "value11", tree.find( "test1" ) ); // now the new value!
ObjectStore expectedObj = new ObjectStore( Integer.valueOf( 234 ) );
ObjectStore btreeObj = ( ObjectStore ) tree.find( "myownobject" );
assertEquals( expectedObj, btreeObj );
recman.close();
}