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();
}
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());
}
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());
}
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());
}
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();
}
Aggregations