public void test_simpleRemoveAll(){
  final IRawStore store=new SimpleMemoryRawStore();
  try {
    final Random r=new Random();
    final HTreeIndexMetadata metadata=new HTreeIndexMetadata(UUID.randomUUID());
    metadata.setAddressBits(2);
    final HTree htree=HTree.create(store,metadata);
    final byte[] key=new byte[]{1,2,3};
    final byte[] val=new byte[24];
    r.nextBytes(val);
    final int entries=23;
    for (int i=0; i < entries; i++) {
      htree.insert(key,val);
    }
    final byte[] altkey=new byte[]{2,3,4};
    final int altentries=11;
    for (int i=0; i < altentries; i++) {
      htree.insert(altkey,val);
    }
    assertEquals(entries + altentries,htree.getEntryCount());
    final DirectoryPage root=(DirectoryPage)htree.getRoot();
    TestCase3.assertEquals(val,htree.lookupFirst(key));
    assertEquals(entries,htree.removeAll(key));
    assertEquals(altentries,htree.getEntryCount());
    TestCase3.assertEquals(null,htree.lookupFirst(key));
  }
  finally {
    store.destroy();
  }
}

public void test_simpleRemoveAll ( ) { final IRawStore store = new SimpleMemoryRawStore ( ) ; try { final Random r = new Random ( ) ; final HTreeIndexMetadata metadata = new HTreeIndexMetadata ( UUID . randomUUID ( ) ) ; metadata . setAddressBits ( 2 ) ; final HTree htree = HTree . create ( store , metadata ) ; final byte [ ] key = new byte [ ] { 1 , 2 , 3 } ; final byte [ ] val = new byte [ 24 ] ; r . nextBytes ( val ) ; final int entries = 23 ; for ( int i = 0 ; i < entries ; i ++ ) { htree . insert ( key , val ) ; } final byte [ ] altkey = new byte [ ] { 2 , 3 , 4 } ; final int altentries = 11 ; for ( int i = 0 ; i < altentries ; i ++ ) { htree . insert ( altkey , val ) ; } assertEquals ( entries + altentries , htree . getEntryCount ( ) ) ; final DirectoryPage root = ( DirectoryPage ) htree . getRoot ( ) ; TestCase3 . assertEquals ( val , htree . lookupFirst ( key ) ) ; assertEquals ( entries , htree . removeAll ( key ) ) ; assertEquals ( altentries , htree . getEntryCount ( ) ) ; TestCase3 . assertEquals ( null , htree . lookupFirst ( key ) ) ; } finally { store . destroy ( ) ; } }
insert and remove several copies of the same key . test includes insertions of other key values , unaffected by the removal .
