@Test
    public void testAbortVisiting() {
        MockComponents mc = createDefaultMock();

        mc.visitorSession.start();
        mc.executor.expectAndProcessTasks(1);
        assertEquals(2, mc.sender.getMessageCount());
        mc.controlHandler.resetMock();
        // While we have active visitors, abort visiting. Completion function
        // should not be called until we have no pending messages.
        mc.visitorSession.abort();
        assertFalse(mc.visitorSession.isDone());

        assertEquals("CreateVisitorMessage(buckets=[\n" +
                "BucketId(0x0400000000000000)\n" +
                "BucketId(0x0000000000000000)\n" +
                "]\n)",
                replyToCreateVisitor(mc.sender, ProgressToken.FINISHED_BUCKET));

        mc.executor.expectAndProcessTasks(1);
        assertEquals("onProgress : 1 active, 0 pending, 1 finished, 2 total\n" +
                "onVisitorStatistics : 0 buckets visited, 0 docs returned\n",
                mc.controlHandler.toString());
        assertFalse(mc.visitorSession.isDone());
        mc.controlHandler.resetMock();

        // When aborted, no new visitors should be sent.
        assertEquals("CreateVisitorMessage(buckets=[\n" +
                "BucketId(0x0400000000000001)\n" +
                "BucketId(0x0000000000000000)\n" +
                "]\n)",
                replyToCreateVisitor(mc.sender, new BucketId(0x8400000100000001L)));

        mc.executor.expectAndProcessTasks(1);
        mc.executor.expectAndProcessTasks(0);
        assertEquals(0, mc.sender.getMessageCount());
        assertTrue(mc.visitorSession.isDone());

        assertEquals("onProgress : 0 active, 1 pending, 1 finished, 2 total\n" +
                "onVisitorStatistics : 0 buckets visited, 0 docs returned\n" +
                "onDone : ABORTED - 'Visitor aborted by user'\n",
                mc.controlHandler.toString());
        assertEquals("ABORTED: Visitor aborted by user",
                mc.controlHandler.getResult().toString());
    }
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