public void test_concurrent_modification_insert(){
  final BTree btree;
{
    IndexMetadata md=new IndexMetadata(UUID.randomUUID());
    md.setBranchingFactor(20);
    btree=BTree.create(new SimpleMemoryRawStore(),md);
    btree.insert(10,"Bryan");
    btree.insert(20,"Mike");
    btree.insert(30,"James");
  }
{
    ITupleCursor2<String> cursor=newCursor(btree);
    assertEquals(new TestTuple<String>(20,"Mike"),cursor.seek(20));
    assertEquals(new TestTuple<String>(20,"Mike"),cursor.tuple());
    btree.insert(15,"Paul");
    assertEquals(TestKeyBuilder.asSortKey(20),cursor.currentKey());
    assertEquals(new TestTuple<String>(20,"Mike"),cursor.tuple());
    assertEquals(new TestTuple<String>(15,"Paul"),cursor.prior());
    assertEquals(new TestTuple<String>(15,"Paul"),cursor.tuple());
    btree.remove(15);
    assertEquals(null,cursor.tuple());
    assertEquals(TestKeyBuilder.asSortKey(15),cursor.currentKey());
    assertEquals(new TestTuple<String>(20,"Mike"),cursor.next());
    btree.remove(20);
    assertEquals(null,cursor.tuple());
    assertEquals(TestKeyBuilder.asSortKey(20),cursor.currentKey());
    btree.insert(25,"Allen");
    assertEquals(TestKeyBuilder.asSortKey(20),cursor.currentKey());
    assertEquals(null,cursor.tuple());
    assertEquals(new TestTuple<String>(25,"Allen"),cursor.next());
    assertEquals(new TestTuple<String>(25,"Allen"),cursor.tuple());
  }
}

public void test_concurrent_modification_insert ( ) { final BTree btree ; { IndexMetadata md = new IndexMetadata ( UUID . randomUUID ( ) ) ; md . setBranchingFactor ( 20 ) ; btree = BTree . create ( new SimpleMemoryRawStore ( ) , md ) ; btree . insert ( 10 , "Bryan" ) ; btree . insert ( 20 , "Mike" ) ; btree . insert ( 30 , "James" ) ; } { ITupleCursor2 < String > cursor = newCursor ( btree ) ; assertEquals ( new TestTuple < String > ( 20 , "Mike" ) , cursor . seek ( 20 ) ) ; assertEquals ( new TestTuple < String > ( 20 , "Mike" ) , cursor . tuple ( ) ) ; btree . insert ( 15 , "Paul" ) ; assertEquals ( TestKeyBuilder . asSortKey ( 20 ) , cursor . currentKey ( ) ) ; assertEquals ( new TestTuple < String > ( 20 , "Mike" ) , cursor . tuple ( ) ) ; assertEquals ( new TestTuple < String > ( 15 , "Paul" ) , cursor . prior ( ) ) ; assertEquals ( new TestTuple < String > ( 15 , "Paul" ) , cursor . tuple ( ) ) ; btree . remove ( 15 ) ; assertEquals ( null , cursor . tuple ( ) ) ; assertEquals ( TestKeyBuilder . asSortKey ( 15 ) , cursor . currentKey ( ) ) ; assertEquals ( new TestTuple < String > ( 20 , "Mike" ) , cursor . next ( ) ) ; btree . remove ( 20 ) ; assertEquals ( null , cursor . tuple ( ) ) ; assertEquals ( TestKeyBuilder . asSortKey ( 20 ) , cursor . currentKey ( ) ) ; btree . insert ( 25 , "Allen" ) ; assertEquals ( TestKeyBuilder . asSortKey ( 20 ) , cursor . currentKey ( ) ) ; assertEquals ( null , cursor . tuple ( ) ) ; assertEquals ( new TestTuple < String > ( 25 , "Allen" ) , cursor . next ( ) ) ; assertEquals ( new TestTuple < String > ( 25 , "Allen" ) , cursor . tuple ( ) ) ; } }
unit test for concurrent modification resulting from insert ( ) and remove ( ) .
