use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method setUp.
@Before
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)));
dstSession = dstServer.mb.createDestinationSession(new DestinationSessionParams().setName("session").setMessageHandler(new Receptor()));
retryPolicy = new RetryTransientErrorsPolicy();
retryPolicy.setBaseDelay(0);
srcServer = new TestServer(new MessageBusParams().setRetryPolicy(retryPolicy).addProtocol(new SimpleProtocol()), new RPCNetworkParams().setSlobrokConfigId(TestServer.getSlobrokConfig(slobrok)));
srcSession = srcServer.mb.createSourceSession(new SourceSessionParams().setTimeout(600.0).setThrottlePolicy(null).setReplyHandler(new Receptor()));
assertTrue(srcServer.waitSlobrok("dst/session", 1));
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatIllegalSelectIsCaught.
@Test
public void requireThatIllegalSelectIsCaught() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
Route route = Route.parse("[Custom: ]");
assertNotNull(route);
assertTrue(srcSession.send(createMessage("msg"), route).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_SERVICES_FOR_ROUTE, reply.getError(0).getCode());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatReplyCanBeRemovedFromChildNodes.
@Test
public void requireThatReplyCanBeRemovedFromChildNodes() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new SimpleProtocol.PolicyFactory() {
@Override
public RoutingPolicy create(String param) {
return new RemoveReplyPolicy(true, Arrays.asList(ErrorCode.NO_ADDRESS_FOR_SERVICE), CustomPolicyFactory.parseRoutes(param), 0);
}
});
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:[Custom:dst/session],[Custom:dst/unknown]]")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("[NO_ADDRESS_FOR_SERVICE @ localhost]", "-[NO_ADDRESS_FOR_SERVICE @ localhost]", "Sending message", "-Sending message"), reply.getTrace());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatHopNameIsExpanded.
@Test
public void requireThatHopNameIsExpanded() {
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addHop(new HopSpec("dst", "dst/session")));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dst")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatIgnoreResultWorks.
@Test
public void requireThatIgnoreResultWorks() {
assertTrue(srcSession.send(createMessage("msg"), Route.parse("?dst/session")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
Reply reply = new EmptyReply();
reply.swapState(msg);
reply.addError(new Error(ErrorCode.APP_FATAL_ERROR, "dst"));
dstSession.reply(reply);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("Not waiting for a reply from 'dst/session'."), reply.getTrace());
}
Aggregations