use of com.yahoo.messagebus.jdisc.test.MessageQueue 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.jdisc.test.MessageQueue in project vespa by vespa-engine.
the class SharedIntermediateSessionTestCase method requireThatMessageHandlerCanBeAccessed.
@Test
public void requireThatMessageHandlerCanBeAccessed() {
SharedIntermediateSession session = newIntermediateSession();
assertNull(session.getMessageHandler());
MessageQueue handler = new MessageQueue();
session.setMessageHandler(handler);
assertSame(handler, session.getMessageHandler());
}
use of com.yahoo.messagebus.jdisc.test.MessageQueue 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.jdisc.test.MessageQueue in project vespa by vespa-engine.
the class SharedIntermediateSessionTestCase method requireThatMessageHandlerCanOnlyBeSetOnce.
@Test
public void requireThatMessageHandlerCanOnlyBeSetOnce() {
SharedIntermediateSession session = newIntermediateSession();
session.setMessageHandler(new MessageQueue());
try {
session.setMessageHandler(new MessageQueue());
fail();
} catch (IllegalStateException e) {
assertEquals("Message handler already registered.", e.getMessage());
}
session.release();
}
use of com.yahoo.messagebus.jdisc.test.MessageQueue 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