@Test
    public void testSkipBucketOnFatalErrorReply() {
        VisitorParameters visitorParameters = createVisitorParameters("");
        visitorParameters.skipBucketsOnFatalErrors(true);
        MockComponents mc = createDefaultMock(visitorParameters);
        mc.controlHandler.resetMock();

        mc.visitorSession.start();
        mc.executor.expectAndProcessTasks(1); // create visitors
        assertEquals(2, mc.sender.getMessageCount());

        replyErrorToCreateVisitor(mc.sender, new Error(
                DocumentProtocol.ERROR_INTERNAL_FAILURE,
                "borked"));
        mc.executor.expectAndProcessTasks(1);
        mc.executor.expectNoTasks(); // no more buckets to send for--all either failed or active
        assertEquals(1, mc.sender.getMessageCount());
        assertFalse(mc.controlHandler.isDone());

        // partial bucket progress which must be remembered
        assertEquals("CreateVisitorMessage(buckets=[\n" +
                "BucketId(0x0400000000000001)\n" +
                "BucketId(0x0000000000000000)\n" +
                "]\n)",
                replyToCreateVisitor(mc.sender, new BucketId(33, 1L | (1L << 32))));
        mc.executor.expectAndProcessTasks(1); // reply
        mc.executor.expectAndProcessTasks(1); // create visitors
        assertEquals(1, mc.sender.getMessageCount());
        assertFalse(mc.controlHandler.isDone());

        // then fail bucket #2
        replyErrorToCreateVisitor(mc.sender, new Error(
                DocumentProtocol.ERROR_INTERNAL_FAILURE,
                "more borked"));
        mc.executor.expectAndProcessTasks(1); // reply
        mc.executor.expectNoTasks();
        assertEquals(0, mc.sender.getMessageCount());

        assertTrue(mc.controlHandler.isDone());

        // make sure progress token was updated with bad buckets and
        // remembers the initial error message
        assertNotNull(mc.controlHandler.getProgress());
        assertTrue(mc.controlHandler.getProgress().containsFailedBuckets());
        assertEquals("INTERNAL_FAILURE: borked",
                mc.controlHandler.getProgress().getFirstErrorMsg());

        assertEquals("#total: 2\n" +
                "#finished: 2\n" +
                "failed:\n" +
                "BucketId(0x0400000000000000) : BucketId(0x0000000000000000)\n" +
                "BucketId(0x0400000000000001) : BucketId(0x8400000100000001)\n",
                dumpProgressToken(mc.controlHandler.getProgress()));

        assertEquals(
                "onVisitorError : INTERNAL_FAILURE: borked\n" +
                "onProgress : 0 active, 1 pending, 1 finished, 2 total\n" +
                "onVisitorStatistics : 0 buckets visited, 0 docs returned\n" +
                "onVisitorError : INTERNAL_FAILURE: more borked\n" +
                "onDone : FAILURE - 'INTERNAL_FAILURE: borked'\n",
                mc.controlHandler.toString());
    }
Test branch where we don't know how to handle a certain reply type.
This should never happen (since we only get replies for messages we've
already sent) but deal with it anyway!
documentapi/src/test/java/com/yahoo/documentapi/messagebus/MessageBusVisitorSessionTestCase.java