@Test
    public void testSkipBucketOnFatalMessageProcessingError() {
        VisitorParameters visitorParameters = createVisitorParameters("id.user==1234");
        visitorParameters.skipBucketsOnFatalErrors(true);
        MockComponents mc = createDefaultMock(visitorParameters);
        mc.controlHandler.resetMock();
        mc.dataHandler.resetMock();
        mc.dataHandler.setExceptionOnMessage(new IllegalArgumentException("oh no"));

        mc.visitorSession.start();
        mc.executor.expectAndProcessTasks(1);

        mc.receiver.send(new RemoveDocumentMessage(new DocumentId("id:ns:testdoc::bar")));
        mc.executor.expectAndProcessTasks(1);
        assertEquals(1, mc.dataHandler.getMessages().size());

        // NOTE: current behavior does _not_ fail the session at the end of
        // visiting if the CreateVisitor replies do not also return with failure
        // since this is tied to the ProgressToken and its failed buckets list.
        // We make the simplifying assumption that failing a visitor _message_
        // will subsequently cause its reply to fail back to us, allowing us to
        // handle this as a regular skippable bucket.
        // TODO: reconsider this?

        replyErrorToCreateVisitor(mc.sender, new Error(
                DocumentProtocol.ERROR_INTERNAL_FAILURE,
                "The Borkening"));
        mc.executor.expectAndProcessTasks(1);
        mc.executor.expectNoTasks();
        assertTrue(mc.controlHandler.isDone());

        // Get UNPARSEABLE rather than APP_FATAL_ERROR if skip buckets is set
        assertEquals("RemoveDocumentReply(UNPARSEABLE: Got exception of type java.lang.IllegalArgumentException " +
                "with message 'oh no' while processing DocumentMessage)\n",
                mc.receiver.repliesToString());

        assertEquals("onVisitorError : INTERNAL_FAILURE: The Borkening\n" +
                "onDone : FAILURE - 'INTERNAL_FAILURE: The Borkening'\n",
                mc.controlHandler.toString());
        assertEquals("FAILURE: INTERNAL_FAILURE: The Borkening",
                mc.controlHandler.getResult().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