Search in sources :

Example 41 with SimpleMessage

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

the class MbusServerTestCase method requireThatReplyInsideMbusResponseIsUsed.

@Test
public void requireThatReplyInsideMbusResponseIsUsed() {
    MyRequestHandler requestHandler = MyRequestHandler.newInstance();
    ServerTestDriver driver = ServerTestDriver.newInstance(requestHandler);
    assertTrue(driver.sendMessage(new SimpleMessage("foo")));
    assertNotNull(requestHandler.awaitRequest());
    Reply reply = new SimpleReply("bar");
    reply.swapState(((MbusRequest) requestHandler.request).getMessage());
    assertTrue(requestHandler.sendResponse(new MbusResponse(Response.Status.OK, reply)));
    reply = driver.awaitSuccess();
    assertTrue(reply instanceof SimpleReply);
    assertEquals("bar", ((SimpleReply) reply).getValue());
    assertTrue(driver.close());
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleReply(com.yahoo.messagebus.test.SimpleReply) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Example 42 with SimpleMessage

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

the class MbusServerTestCase method requireThatBindingSetNotFoundExceptionIsCaught.

@Test
public void requireThatBindingSetNotFoundExceptionIsCaught() {
    ServerTestDriver driver = ServerTestDriver.newUnboundInstance(new MySelector("foo"));
    assertTrue(driver.sendMessage(new SimpleMessage("bar")));
    assertNotNull(driver.awaitErrors(ErrorCode.APP_FATAL_ERROR));
    assertTrue(driver.close());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Example 43 with SimpleMessage

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

the class MbusServerTestCase method requireThatContainerNotReadyExceptionIsCaught.

@Test
public void requireThatContainerNotReadyExceptionIsCaught() {
    ServerTestDriver driver = ServerTestDriver.newInactiveInstance();
    assertTrue(driver.sendMessage(new SimpleMessage("foo")));
    assertNotNull(driver.awaitErrors(ErrorCode.APP_FATAL_ERROR));
    assertTrue(driver.close());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) ServerTestDriver(com.yahoo.messagebus.jdisc.test.ServerTestDriver) Test(org.junit.Test)

Example 44 with SimpleMessage

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

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

the class LocalNetworkTest method requireThatLocalNetworkCanSendAndReceive.

@Test
public void requireThatLocalNetworkCanSendAndReceive() throws InterruptedException {
    final LocalWire wire = new LocalWire();
    final Server serverA = new Server(wire);
    final SourceSession source = serverA.newSourceSession();
    final Server serverB = new Server(wire);
    final IntermediateSession intermediate = serverB.newIntermediateSession();
    final Server serverC = new Server(wire);
    final DestinationSession destination = serverC.newDestinationSession();
    Message msg = new SimpleMessage("foo");
    msg.setRoute(new Route().addHop(Hop.parse(intermediate.getConnectionSpec())).addHop(Hop.parse(destination.getConnectionSpec())));
    assertThat(source.send(msg).isAccepted(), is(true));
    msg = serverB.messages.poll(60, TimeUnit.SECONDS);
    assertThat(msg, instanceOf(SimpleMessage.class));
    assertThat(((SimpleMessage) msg).getValue(), is("foo"));
    intermediate.forward(msg);
    msg = serverC.messages.poll(60, TimeUnit.SECONDS);
    assertThat(msg, instanceOf(SimpleMessage.class));
    assertThat(((SimpleMessage) msg).getValue(), is("foo"));
    Reply reply = new SimpleReply("bar");
    reply.swapState(msg);
    destination.reply(reply);
    reply = serverB.replies.poll(60, TimeUnit.SECONDS);
    assertThat(reply, instanceOf(SimpleReply.class));
    assertThat(((SimpleReply) reply).getValue(), is("bar"));
    intermediate.forward(reply);
    reply = serverA.replies.poll(60, TimeUnit.SECONDS);
    assertThat(reply, instanceOf(SimpleReply.class));
    assertThat(((SimpleReply) reply).getValue(), is("bar"));
    serverA.mbus.destroy();
    serverB.mbus.destroy();
    serverC.mbus.destroy();
}
Also used : SimpleReply(com.yahoo.messagebus.test.SimpleReply) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Route(com.yahoo.messagebus.routing.Route) 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