question: public void test_insertKeyIntoLeaf02 ( ) { final int branchingFactor = 20 ; final BTree btree = getBTree ( branchingFactor ) ; final Leaf root = ( Leaf ) btree . root ; final byte [ ] [ ] expectedKeys = new byte [ branchingFactor ] [ ] ; int nkeys = 0 ; while ( nkeys < branchingFactor ) { final byte [ ] key = new byte [ 3 ] ; r . nextBytes ( key ) ; final int nkeysBefore = root . getKeyCount ( ) ; final boolean exists = btree . lookup ( key ) != null ; btree . insert ( key , new SimpleEntry ( ) ) ; if ( nkeysBefore == root . getKeyCount ( ) ) { assertTrue ( exists ) ; continue ; } assertFalse ( exists ) ; expectedKeys [ nkeys ] = key ; nkeys ++ ; assertEquals ( nkeys , root . getKeyCount ( ) ) ; } Arrays . sort ( expectedKeys , BytesUtil . UnsignedByteArrayComparator . INSTANCE ) ; assertTrue ( root . dump ( Level . DEBUG , System . err ) ) ; assertKeys ( expectedKeys , root ) ; }
target:  Test ability to insert entries into a leaf. Random (legal) external keys are inserted into a leaf until the leaf would overflow. The random keys are then sorted and compared with the actual keys in the leaf. If the keys were inserted correctly into the leaf then the two arrays of keys will have the same values in the same order. (This is a variation on the previous test that inserts keys into the leaf using a slightly higher level API).