Search in sources :

Example 6 with MessageQueue

use of com.yahoo.messagebus.jdisc.test.MessageQueue in project vespa by vespa-engine.

the class SharedDestinationSessionTestCase method requireThatMessageHandlerCanBeAccessed.

@Test
public void requireThatMessageHandlerCanBeAccessed() {
    SharedDestinationSession session = newDestinationSession();
    assertNull(session.getMessageHandler());
    MessageQueue handler = new MessageQueue();
    session.setMessageHandler(handler);
    assertSame(handler, session.getMessageHandler());
}
Also used : MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) Test(org.junit.Test)

Example 7 with MessageQueue

use of com.yahoo.messagebus.jdisc.test.MessageQueue in project vespa by vespa-engine.

the class SharedDestinationSessionTestCase method requireThatMessageHandlerIsCalled.

@Test
public void requireThatMessageHandlerIsCalled() throws InterruptedException {
    SharedDestinationSession session = newDestinationSession();
    MessageQueue queue = new MessageQueue();
    session.setMessageHandler(queue);
    session.handleMessage(new SimpleMessage("foo"));
    assertNotNull(queue.awaitMessage(60, TimeUnit.SECONDS));
    session.release();
}
Also used : MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Test(org.junit.Test)

Example 8 with MessageQueue

use of com.yahoo.messagebus.jdisc.test.MessageQueue in project vespa by vespa-engine.

the class SharedDestinationSessionTestCase method requireThatMessageHandlerCanOnlyBeSetOnce.

@Test
public void requireThatMessageHandlerCanOnlyBeSetOnce() {
    SharedDestinationSession session = newDestinationSession();
    session.setMessageHandler(new MessageQueue());
    try {
        session.setMessageHandler(new MessageQueue());
        fail();
    } catch (IllegalStateException e) {
        assertEquals("Message handler already registered.", e.getMessage());
    }
    session.release();
}
Also used : MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) Test(org.junit.Test)

Aggregations

MessageQueue (com.yahoo.messagebus.jdisc.test.MessageQueue)8 Test (org.junit.Test)8 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)4 RemoteClient (com.yahoo.messagebus.jdisc.test.RemoteClient)2 Route (com.yahoo.messagebus.routing.Route)2 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2