@Test
    public void testWrongDistributionAdjustsDistributionBits() {
        MockSender sender = new MockSender();
        MockReceiver receiver = new MockReceiver();
        sender.setMaxPending(2);
        MockAsyncTaskExecutor executor = new MockAsyncTaskExecutor();
        VisitorParameters params = createVisitorParameters("");
        MessageBusVisitorSession visitorSession = createVisitorSession(
                sender, receiver, executor, params);

        visitorSession.start();
        executor.expectAndProcessTasks(1);
        assertEquals(2, sender.getMessageCount());
        assertEquals("CreateVisitorMessage(buckets=[\n" +
                "BucketId(0x0400000000000000)\n" +
                "BucketId(0x0000000000000000)\n" +
                "]\n)",
                replyWrongDistributionToCreateVisitor(
                        sender, "version:2 storage:100 distributor:100 bits:16"));
        executor.expectAndProcessTasks(1); // WDR reply
        // Replying with WRONG_DISTRIBUTION when there are active visitors
        // should not send any new visitors until all active have returned.
        // This allows the visitor iterator to consistently adjust the visiting
        // progress based on the distribution bit change.
        executor.expectNoTasks();

        assertEquals("CreateVisitorMessage(buckets=[\n" +
                "BucketId(0x0400000000000001)\n" +
                "BucketId(0x0000000000000000)\n" +
                "]\n)",
                replyWrongDistributionToCreateVisitor(
                        sender, "version:2 storage:100 distributor:100 bits:16"));
        executor.expectAndProcessTasks(1); // WDR reply
        executor.expectAndProcessTasks(1, new long[] { 0 }); // Send new visitors, no delay

        // Now with 16 distribution bits.
        assertEquals("CreateVisitorMessage(buckets=[\n" +
                "BucketId(0x4000000000000000)\n" +
                "BucketId(0x0000000000000000)\n" +
                "]\n)",
                replyToCreateVisitor(sender, ProgressToken.FINISHED_BUCKET));

        assertEquals("CreateVisitorMessage(buckets=[\n" +
                "BucketId(0x4000000000008000)\n" +
                "BucketId(0x0000000000000000)\n" +
                "]\n)",
                replyToCreateVisitor(sender, ProgressToken.FINISHED_BUCKET));
        // .... and 65533 more
    }
Test that using an id.user=foo selection only tries to visit a single
superbucket for that user.
documentapi/src/test/java/com/yahoo/documentapi/messagebus/MessageBusVisitorSessionTestCase.java