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