Search in sources :

Example 1 with MessageQueue

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

the class SharedDestinationSessionTestCase method requireThatSessionCanSendReply.

@Test
public void requireThatSessionCanSendReply() throws InterruptedException {
    RemoteClient client = RemoteClient.newInstanceWithInternSlobrok();
    MessageQueue queue = new MessageQueue();
    DestinationSessionParams params = new DestinationSessionParams().setMessageHandler(queue);
    SharedDestinationSession session = newDestinationSession(client.slobrokId(), params);
    Route route = Route.parse(session.connectionSpec());
    assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted());
    Message msg = queue.awaitMessage(60, TimeUnit.SECONDS);
    assertNotNull(msg);
    Reply reply = new SimpleReply("bar");
    reply.swapState(msg);
    session.sendReply(reply);
    assertNotNull(client.awaitReply(60, TimeUnit.SECONDS));
    session.release();
    client.close();
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) RemoteClient(com.yahoo.messagebus.jdisc.test.RemoteClient) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Route(com.yahoo.messagebus.routing.Route) Test(org.junit.Test)

Example 2 with MessageQueue

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

the class SharedIntermediateSessionTestCase method requireThatMessageHandlerCanBeAccessed.

@Test
public void requireThatMessageHandlerCanBeAccessed() {
    SharedIntermediateSession session = newIntermediateSession();
    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 3 with MessageQueue

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

the class SharedIntermediateSessionTestCase method requireThatMessageHandlerIsCalled.

@Test
public void requireThatMessageHandlerIsCalled() throws InterruptedException {
    SharedIntermediateSession session = newIntermediateSession();
    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 4 with MessageQueue

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

the class SharedIntermediateSessionTestCase method requireThatMessageHandlerCanOnlyBeSetOnce.

@Test
public void requireThatMessageHandlerCanOnlyBeSetOnce() {
    SharedIntermediateSession session = newIntermediateSession();
    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)

Example 5 with MessageQueue

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

the class SharedIntermediateSessionTestCase method requireThatSessionCanSendReply.

@Test
public void requireThatSessionCanSendReply() throws InterruptedException {
    RemoteClient client = RemoteClient.newInstanceWithInternSlobrok();
    MessageQueue queue = new MessageQueue();
    IntermediateSessionParams params = new IntermediateSessionParams().setMessageHandler(queue);
    SharedIntermediateSession session = newIntermediateSession(client.slobrokId(), params);
    Route route = Route.parse(session.connectionSpec());
    assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted());
    Message msg = queue.awaitMessage(60, TimeUnit.SECONDS);
    assertNotNull(msg);
    Reply reply = new SimpleReply("bar");
    reply.swapState(msg);
    session.sendReply(reply);
    assertNotNull(client.awaitReply(60, TimeUnit.SECONDS));
    session.release();
    client.close();
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) MessageQueue(com.yahoo.messagebus.jdisc.test.MessageQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) RemoteClient(com.yahoo.messagebus.jdisc.test.RemoteClient) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Route(com.yahoo.messagebus.routing.Route) 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