@Test
    public void testReceiveVisitorInfoMessage() {
        MockComponents mc = createDefaultMock("id.user==1234");
        mc.visitorSession.start();
        mc.controlHandler.resetMock();
        mc.executor.expectAndProcessTasks(1);

        // Send a VisitorInfo back without any errors. This should trigger
        // the control handler's onProgress routine (at least this is what
        // the legacy code does, so let's go with that).
        mc.receiver.send(new VisitorInfoMessage());
        mc.executor.expectAndProcessTasks(1); // Message handler task

        assertEquals("onProgress : 1 active, 0 pending, 0 finished, 1 total\n",
                mc.controlHandler.toString());
        assertEquals("VisitorReply\n", mc.receiver.repliesToString());
        mc.receiver.getAndRemoveReply(0);

        // Send VisitorInfo with error. This should invoke the control
        // handler's onVisitorError method.
        VisitorInfoMessage errMsg = new VisitorInfoMessage();
        errMsg.setErrorMessage("bears! bears everywhere!");

        mc.receiver.send(errMsg);
        mc.controlHandler.resetMock();
        mc.executor.expectAndProcessTasks(1); // Message handler task

        replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET);
        mc.executor.expectAndProcessTasks(1); // Reply handler task

        // Visitor info with error should not fail visiting itself, this
        // is only done for _replies_ with errors.
        assertEquals(
                "onVisitorError : bears! bears everywhere!\n" +
                "onProgress : 1 active, 0 pending, 0 finished, 1 total\n" +
                "onProgress : 0 active, 0 pending, 1 finished, 1 total\n" +
                "onVisitorStatistics : 0 buckets visited, 0 docs returned\n" +
                "onDone : SUCCESS - ''\n",
                mc.controlHandler.toString());
        assertEquals("VisitorReply\n", mc.receiver.repliesToString());
    }
Test that receiving a WrongDistributionReply with a cluster state
we cannot parse fails the visiting session. We cannot visit anything
if we don't have a proper state anyway, so might as well fail fast.
documentapi/src/test/java/com/yahoo/documentapi/messagebus/MessageBusVisitorSessionTestCase.java