use of com.yahoo.messagebus.jdisc.test.ReplyQueue 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.jdisc.test.ReplyQueue 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.jdisc.test.ReplyQueue in project vespa by vespa-engine.
the class SharedIntermediateSessionTestCase method requireThatSessionRepliesIfMessageHandlerIsNull.
@Test
public void requireThatSessionRepliesIfMessageHandlerIsNull() throws InterruptedException {
SharedIntermediateSession session = newIntermediateSession();
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.jdisc.test.ReplyQueue in project vespa by vespa-engine.
the class SharedIntermediateSessionTestCase method requireThatSessionCanSendMessage.
@Test
public void requireThatSessionCanSendMessage() throws InterruptedException {
RemoteServer server = RemoteServer.newInstanceWithInternSlobrok();
SharedIntermediateSession session = newIntermediateSession(server.slobrokId(), new IntermediateSessionParams());
ReplyQueue queue = new ReplyQueue();
Message msg = new SimpleMessage("foo").setRoute(Route.parse(server.connectionSpec()));
msg.setTimeReceivedNow();
msg.setTimeRemaining(60000);
msg.getTrace().setLevel(9);
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.jdisc.test.ReplyQueue in project vespa by vespa-engine.
the class SharedIntermediateSessionTestCase method requireThatReplyHandlerCanNotBeSet.
@Test
public void requireThatReplyHandlerCanNotBeSet() throws ListenFailedException {
Slobrok slobrok = new Slobrok();
try {
newIntermediateSession(slobrok.configId(), new IntermediateSessionParams().setReplyHandler(new ReplyQueue()));
fail();
} catch (IllegalArgumentException e) {
assertEquals("Reply handler must be null.", e.getMessage());
}
}
Aggregations