use of com.yahoo.messagebus.network.rpc.test.TestServer in project vespa by vespa-engine.
the class RoutableTestCase method testMessageContext.
public void testMessageContext() throws ListenFailedException, UnknownHostException {
Slobrok slobrok = new Slobrok();
TestServer srcServer = new TestServer("src", null, slobrok, null);
TestServer dstServer = new TestServer("dst", null, slobrok, null);
SourceSession srcSession = srcServer.mb.createSourceSession(new Receptor(), new SourceSessionParams().setTimeout(600.0));
DestinationSession dstSession = dstServer.mb.createDestinationSession("session", true, new Receptor());
assertTrue(srcServer.waitSlobrok("dst/session", 1));
Object context = new Object();
Message msg = new SimpleMessage("msg");
msg.setContext(context);
assertTrue(srcSession.send(msg, "dst/session", true).isAccepted());
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
assertSame(reply.getContext(), context);
srcSession.destroy();
srcServer.destroy();
dstSession.destroy();
dstServer.destroy();
slobrok.stop();
}
use of com.yahoo.messagebus.network.rpc.test.TestServer in project vespa by vespa-engine.
the class ThrottlerTestCase method setUp.
public void setUp() throws ListenFailedException, UnknownHostException {
RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME);
table.addHop("dst", "test/dst/session", Arrays.asList("test/dst/session"));
table.addRoute("test", Arrays.asList("dst"));
slobrok = new Slobrok();
src = new TestServer("test/src", table, slobrok, null);
dst = new TestServer("test/dst", table, slobrok, null);
}
use of com.yahoo.messagebus.network.rpc.test.TestServer in project vespa by vespa-engine.
the class BasicNetworkTestCase method setUp.
public void setUp() throws ListenFailedException, UnknownHostException {
RoutingTableSpec table = new RoutingTableSpec(SimpleProtocol.NAME);
table.addHop("pxy", "test/pxy/session", Arrays.asList("test/pxy/session"));
table.addHop("dst", "test/dst/session", Arrays.asList("test/dst/session"));
table.addRoute("test", Arrays.asList("pxy", "dst"));
slobrok = new Slobrok();
src = new TestServer("test/src", table, slobrok, null);
pxy = new TestServer("test/pxy", table, slobrok, null);
dst = new TestServer("test/dst", table, slobrok, null);
}
use of com.yahoo.messagebus.network.rpc.test.TestServer in project vespa by vespa-engine.
the class RPCNetworkTestCase method requireThatProtocolEncodeExceptionIsCaught.
@Test
public void requireThatProtocolEncodeExceptionIsCaught() throws Exception {
RuntimeException e = new RuntimeException();
Slobrok slobrok = new Slobrok();
TestServer server = new TestServer(new MessageBusParams().addProtocol(MyProtocol.newEncodeException(e)), new RPCNetworkParams().setSlobrokConfigId(slobrok.configId()));
Receptor receptor = new Receptor();
SourceSession src = server.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(receptor));
DestinationSession dst = server.mb.createDestinationSession(new DestinationSessionParams());
assertTrue(src.send(new MyMessage().setRoute(Route.parse(dst.getConnectionSpec()))).isAccepted());
Reply reply = receptor.getReply(60);
assertNotNull(reply);
assertEquals(1, reply.getNumErrors());
StringWriter expected = new StringWriter();
e.printStackTrace(new PrintWriter(expected));
String actual = reply.getError(0).toString();
assertTrue(actual, actual.contains(expected.toString()));
}
use of com.yahoo.messagebus.network.rpc.test.TestServer in project vespa by vespa-engine.
the class AdvancedRoutingTestCase method setUp.
@Override
public void setUp() throws ListenFailedException, UnknownHostException {
slobrok = new Slobrok();
dstServer = new TestServer(new MessageBusParams().addProtocol(new SimpleProtocol()), new RPCNetworkParams().setIdentity(new Identity("dst")).setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
dstFoo = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("foo").setMessageHandler(new Receptor()));
dstBar = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("bar").setMessageHandler(new Receptor()));
dstBaz = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("baz").setMessageHandler(new Receptor()));
srcServer = new TestServer(new MessageBusParams().setRetryPolicy(new RetryTransientErrorsPolicy().setBaseDelay(0)).addProtocol(new SimpleProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setReplyHandler(new Receptor()));
assertTrue(srcServer.waitSlobrok("dst/*", 3));
}
Aggregations