Search in sources :

Example 26 with SimpleMessage

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

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

the class MbusClientTestCase method requireThatRequestResponseWorks.

@Test
public void requireThatRequestResponseWorks() {
    ClientTestDriver driver = ClientTestDriver.newInstance();
    MyResponseHandler responseHandler = MyResponseHandler.newInstance();
    assertTrue(driver.sendMessage(new SimpleMessage("foo"), responseHandler));
    assertTrue(driver.awaitMessageAndSendReply(new EmptyReply()));
    Response response = responseHandler.awaitResponse();
    assertNotNull(response);
    assertEquals(Response.Status.OK, response.getStatus());
    assertTrue(driver.close());
}
Also used : Response(com.yahoo.jdisc.Response) ClientTestDriver(com.yahoo.messagebus.jdisc.test.ClientTestDriver) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Test(org.junit.Test)

Example 28 with SimpleMessage

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

the class MbusClientTestCase method requireThatResponseIsMbus.

@Test
public void requireThatResponseIsMbus() {
    ClientTestDriver driver = ClientTestDriver.newInstance();
    MyResponseHandler responseHandler = MyResponseHandler.newInstance();
    assertTrue(driver.sendMessage(new SimpleMessage("foo"), responseHandler));
    assertTrue(driver.awaitMessageAndSendReply(new EmptyReply()));
    Response response = responseHandler.awaitResponse();
    assertTrue(response instanceof MbusResponse);
    Reply reply = ((MbusResponse) response).getReply();
    assertTrue(reply instanceof EmptyReply);
    assertTrue(driver.close());
}
Also used : Response(com.yahoo.jdisc.Response) ClientTestDriver(com.yahoo.messagebus.jdisc.test.ClientTestDriver) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) SimpleReply(com.yahoo.messagebus.test.SimpleReply) Test(org.junit.Test)

Example 29 with SimpleMessage

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

the class MbusRequestTestCase method requireThatMessageCanNotBeNullInChildRequest.

@Test
public void requireThatMessageCanNotBeNullInChildRequest() {
    TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
    driver.activateContainer(driver.newContainerBuilder());
    MbusRequest parent = new MbusRequest(driver, URI.create("mbus://host/path"), new SimpleMessage("foo"));
    try {
        new MbusRequest(parent, URI.create("mbus://host/path"), null);
        fail();
    } catch (NullPointerException e) {
    // expected
    }
    parent.release();
    assertTrue(driver.close());
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 30 with SimpleMessage

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

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