Search in sources :

Example 6 with TestServer

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();
}
Also used : SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Receptor(com.yahoo.messagebus.test.Receptor) SimpleMessage(com.yahoo.messagebus.test.SimpleMessage) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) SimpleReply(com.yahoo.messagebus.test.SimpleReply) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 7 with TestServer

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);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 8 with TestServer

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);
}
Also used : RoutingTableSpec(com.yahoo.messagebus.routing.RoutingTableSpec) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Example 9 with TestServer

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()));
}
Also used : Utf8String(com.yahoo.text.Utf8String) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer) StringWriter(java.io.StringWriter) Receptor(com.yahoo.messagebus.test.Receptor) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) PrintWriter(java.io.PrintWriter) Test(org.junit.Test)

Example 10 with TestServer

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));
}
Also used : SimpleProtocol(com.yahoo.messagebus.test.SimpleProtocol) Receptor(com.yahoo.messagebus.test.Receptor) RPCNetworkParams(com.yahoo.messagebus.network.rpc.RPCNetworkParams) Slobrok(com.yahoo.jrt.slobrok.server.Slobrok) Identity(com.yahoo.messagebus.network.Identity) TestServer(com.yahoo.messagebus.network.rpc.test.TestServer)

Aggregations

TestServer (com.yahoo.messagebus.network.rpc.test.TestServer)24 Slobrok (com.yahoo.jrt.slobrok.server.Slobrok)23 Receptor (com.yahoo.messagebus.test.Receptor)17 RPCNetworkParams (com.yahoo.messagebus.network.rpc.RPCNetworkParams)10 Identity (com.yahoo.messagebus.network.Identity)9 SimpleProtocol (com.yahoo.messagebus.test.SimpleProtocol)8 Test (org.junit.Test)8 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)6 RoutingTableSpec (com.yahoo.messagebus.routing.RoutingTableSpec)4 Before (org.junit.Before)3 DocumentTypeManager (com.yahoo.document.DocumentTypeManager)2 DocumentProtocol (com.yahoo.documentapi.messagebus.protocol.DocumentProtocol)2 SimpleReply (com.yahoo.messagebus.test.SimpleReply)2 RetryTransientErrorsPolicy (com.yahoo.messagebus.routing.RetryTransientErrorsPolicy)1 QueueAdapter (com.yahoo.messagebus.test.QueueAdapter)1 Utf8String (com.yahoo.text.Utf8String)1 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 ArrayList (java.util.ArrayList)1