Search in sources :

Example 11 with SimpleMessage

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

the class TimeoutTestCase method newMessage.

private static Message newMessage() {
    Message msg = new SimpleMessage("msg");
    msg.getTrace().setLevel(9);
    return msg;
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage)

Example 12 with SimpleMessage

use of com.yahoo.messagebus.test.SimpleMessage 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 13 with SimpleMessage

use of com.yahoo.messagebus.test.SimpleMessage 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 14 with SimpleMessage

use of com.yahoo.messagebus.test.SimpleMessage 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 15 with SimpleMessage

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

the class MbusRequestHandlerTestCase method requireThatHandlerCanRespondInSameThread.

@Test
public void requireThatHandlerCanRespondInSameThread() throws Exception {
    TestDriver driver = newTestDriver(SameThreadReplier.INSTANCE);
    Response response = dispatchMessage(driver, new SimpleMessage("msg")).get(60, TimeUnit.SECONDS);
    assertTrue(response instanceof MbusResponse);
    assertEquals(Response.Status.OK, response.getStatus());
    Reply reply = ((MbusResponse) response).getReply();
    assertTrue(reply instanceof EmptyReply);
    assertFalse(reply.hasErrors());
    assertTrue(driver.close());
}
Also used : Response(com.yahoo.jdisc.Response) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Reply(com.yahoo.messagebus.Reply) EmptyReply(com.yahoo.messagebus.EmptyReply) TestDriver(com.yahoo.jdisc.test.TestDriver) EmptyReply(com.yahoo.messagebus.EmptyReply) Test(org.junit.Test)

Aggregations

SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)58 Test (org.junit.Test)38 SimpleReply (com.yahoo.messagebus.test.SimpleReply)23 Response (com.yahoo.jdisc.Response)14 Receptor (com.yahoo.messagebus.test.Receptor)13 ServerTestDriver (com.yahoo.messagebus.jdisc.test.ServerTestDriver)12 ClientTestDriver (com.yahoo.messagebus.jdisc.test.ClientTestDriver)9 TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)7 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)6 Route (com.yahoo.messagebus.routing.Route)5 MessageQueue (com.yahoo.messagebus.jdisc.test.MessageQueue)4 ReplyQueue (com.yahoo.messagebus.jdisc.test.ReplyQueue)4 Request (com.yahoo.jdisc.Request)3 TestDriver (com.yahoo.jdisc.test.TestDriver)3 EmptyReply (com.yahoo.messagebus.EmptyReply)3 Reply (com.yahoo.messagebus.Reply)3 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)3 Error (com.yahoo.messagebus.Error)2 Message (com.yahoo.messagebus.Message)2 RemoteClient (com.yahoo.messagebus.jdisc.test.RemoteClient)2