Search in sources :

Example 1 with ReplyQueue

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

the class SharedSourceSessionTestCase method requireThatSessionCanSendMessage.

@Test
public void requireThatSessionCanSendMessage() throws InterruptedException {
    RemoteServer server = RemoteServer.newInstanceWithInternSlobrok();
    SharedSourceSession session = newSourceSession(server.slobrokId(), new SourceSessionParams());
    ReplyQueue queue = new ReplyQueue();
    Message msg = new SimpleMessage("foo").setRoute(Route.parse(server.connectionSpec()));
    msg.pushHandler(queue);
    assertTrue(session.sendMessage(msg).isAccepted());
    assertNotNull(msg = server.awaitMessage(60, TimeUnit.SECONDS));
    server.ackMessage(msg);
    assertNotNull(queue.awaitReply(60, TimeUnit.SECONDS));
    session.release();
    server.close();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Message(com.yahoo.messagebus.Message) ReplyQueue(com.yahoo.messagebus.jdisc.test.ReplyQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SourceSessionParams(com.yahoo.messagebus.SourceSessionParams) RemoteServer(com.yahoo.messagebus.jdisc.test.RemoteServer) Test(org.junit.Test)

Example 2 with ReplyQueue

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

the class SharedDestinationSessionTestCase method requireThatSessionRepliesIfMessageHandlerIsNull.

@Test
public void requireThatSessionRepliesIfMessageHandlerIsNull() throws InterruptedException {
    SharedDestinationSession session = newDestinationSession();
    Message msg = new SimpleMessage("foo");
    ReplyQueue queue = new ReplyQueue();
    msg.pushHandler(queue);
    session.handleMessage(msg);
    Reply reply = queue.awaitReply(60, TimeUnit.SECONDS);
    assertNotNull(reply);
    assertEquals(1, reply.getNumErrors());
    assertEquals(ErrorCode.SESSION_BUSY, reply.getError(0).getCode());
    session.release();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ReplyQueue(com.yahoo.messagebus.jdisc.test.ReplyQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Test(org.junit.Test)

Example 3 with ReplyQueue

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

the class SharedIntermediateSessionTestCase method requireThatSessionRepliesIfMessageHandlerIsNull.

@Test
public void requireThatSessionRepliesIfMessageHandlerIsNull() throws InterruptedException {
    SharedIntermediateSession session = newIntermediateSession();
    Message msg = new SimpleMessage("foo");
    ReplyQueue queue = new ReplyQueue();
    msg.pushHandler(queue);
    session.handleMessage(msg);
    Reply reply = queue.awaitReply(60, TimeUnit.SECONDS);
    assertNotNull(reply);
    assertEquals(1, reply.getNumErrors());
    assertEquals(ErrorCode.SESSION_BUSY, reply.getError(0).getCode());
    session.release();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ReplyQueue(com.yahoo.messagebus.jdisc.test.ReplyQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Test(org.junit.Test)

Example 4 with ReplyQueue

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

the class SharedIntermediateSessionTestCase method requireThatSessionCanSendMessage.

@Test
public void requireThatSessionCanSendMessage() throws InterruptedException {
    RemoteServer server = RemoteServer.newInstanceWithInternSlobrok();
    SharedIntermediateSession session = newIntermediateSession(server.slobrokId(), new IntermediateSessionParams());
    ReplyQueue queue = new ReplyQueue();
    Message msg = new SimpleMessage("foo").setRoute(Route.parse(server.connectionSpec()));
    msg.setTimeReceivedNow();
    msg.setTimeRemaining(60000);
    msg.getTrace().setLevel(9);
    msg.pushHandler(queue);
    assertTrue(session.sendMessage(msg).isAccepted());
    assertNotNull(msg = server.awaitMessage(60, TimeUnit.SECONDS));
    server.ackMessage(msg);
    assertNotNull(queue.awaitReply(60, TimeUnit.SECONDS));
    session.release();
    server.close();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ReplyQueue(com.yahoo.messagebus.jdisc.test.ReplyQueue) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) RemoteServer(com.yahoo.messagebus.jdisc.test.RemoteServer) Test(org.junit.Test)

Example 5 with ReplyQueue

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

the class SharedIntermediateSessionTestCase method requireThatReplyHandlerCanNotBeSet.

@Test
public void requireThatReplyHandlerCanNotBeSet() throws ListenFailedException {
    Slobrok slobrok = new Slobrok();
    try {
        newIntermediateSession(slobrok.configId(), new IntermediateSessionParams().setReplyHandler(new ReplyQueue()));
        fail();
    } catch (IllegalArgumentException e) {
        assertEquals("Reply handler must be null.", e.getMessage());
    }
}
Also used : ReplyQueue(com.yahoo.messagebus.jdisc.test.ReplyQueue) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Test(org.junit.Test)

Aggregations

ReplyQueue (com.yahoo.messagebus.jdisc.test.ReplyQueue)5 Test (org.junit.Test)5 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)4 RemoteServer (com.yahoo.messagebus.jdisc.test.RemoteServer)2 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)1 Message (com.yahoo.messagebus.Message)1 SourceSessionParams (com.yahoo.messagebus.SourceSessionParams)1