@Test
    public void testSingleBucketSplits() throws ParseException {
        int db = 2;
        BucketIdFactory idFactory = new BucketIdFactory();
        ProgressToken p = new ProgressToken();

        // Create a range of [0, 4) superbuckets
        VisitorIterator iter = VisitorIterator.createFromDocumentSelection(
                "id.group != \"yahoo.com\"", idFactory, db, p);
        VisitorIterator.BucketProgress bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db, 0));
        // Put back as pending
        iter.update(bp.getSuperbucket(), new BucketId());
        assertEquals(p.getPendingBucketCount(), 1);
        p.splitPendingBucket(new BucketId(db, 0));
        assertEquals(p.getPendingBucketCount(), 2);
        bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db + 1, 0)); // left split
        assertEquals(bp.getProgress(), new BucketId(0));
        bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db + 1, 4)); // right split
        assertEquals(bp.getProgress(), new BucketId(0));

        bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db, 2));
        // Put back as pending, with a progress of 10010. This implies splitting
        // the bucket should set both splits with a progress to 10010
        iter.update(bp.getSuperbucket(), new BucketId(db + 3, 0x12));
        assertEquals(p.getPendingBucketCount(), 1);
        p.splitPendingBucket(new BucketId(db, 2));
        assertEquals(p.getPendingBucketCount(), 2);
        bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db + 1, 2)); // left split
        assertEquals(bp.getProgress(), new BucketId(db + 3, 0x12));
        bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db + 1, 6)); // right split
        assertEquals(bp.getProgress(), new BucketId(db + 3, 0x12));

        bp = iter.getNext();
        // Put back as pending with a progress of 10101. This implies splitting the
        // bucket should _discard_ left and set right's progress to 10101.
        // Update: no it shouldn't, we now split with equal progress without
        // discarding
        assertEquals(bp.getSuperbucket(), new BucketId(db, 1));
        iter.update(bp.getSuperbucket(), new BucketId(db + 3, 0x15));
        assertEquals(p.getPendingBucketCount(), 1);
        p.splitPendingBucket(new BucketId(db, 1));
        assertEquals(p.getPendingBucketCount(), 2);
        bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db + 1, 1));
        assertEquals(bp.getProgress(), new BucketId(db + 3, 0x15));
        bp = iter.getNext();
        assertEquals(bp.getSuperbucket(), new BucketId(db + 1, 5)); // right split
        assertEquals(bp.getProgress(), new BucketId(db + 3, 0x15));
    }
Test that ensures doing update(superbucket, 0) simply puts the bucket back in
pending
documentapi/src/test/java/com/yahoo/documentapi/VisitorIteratorTestCase.java