@Test
    public void testExceptionInHandleDocumentMessage() {
        MockComponents mc = createDefaultMock("id.user=1234");
        mc.dataHandler.resetMock();
        mc.controlHandler.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());

        // Reply with OK; session should still have failed due to the processing error
        replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET);
        mc.executor.expectAndProcessTasks(1);
        mc.executor.expectNoTasks();
        assertTrue(mc.controlHandler.isDone());

        assertEquals("RemoveDocumentReply(APP_FATAL_ERROR: Got exception of type java.lang.IllegalArgumentException " +
                "with message 'oh no' while processing DocumentMessage)\n",
                mc.receiver.repliesToString());

        assertEquals("onProgress : 0 active, 0 pending, 1 finished, 1 total\n" +
                "onVisitorStatistics : 0 buckets visited, 0 docs returned\n" +
                "onDone : FAILURE - 'Got exception of type java.lang.IllegalArgumentException " +
                "with message 'oh no' while processing DocumentMessage'\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