use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatRouteDirectiveWorks.
@Test
public void requireThatRouteDirectiveWorks() {
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("dst").addHop("dst/session")).addHop(new HopSpec("dir", "route:dst")));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("dir")).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 requireThatRouteNameIsExpanded.
@Test
public void requireThatRouteNameIsExpanded() {
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("dst").addHop("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 requireThatRetryCanBeDisabled.
@Test
public void requireThatRetryCanBeDisabled() {
retryPolicy.setEnabled(false);
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_TRANSIENT_ERROR, "err"));
dstSession.reply(reply);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.APP_TRANSIENT_ERROR, reply.getError(0).getCode());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatMergeExceptionIsCaught.
@Test
public void requireThatMergeExceptionIsCaught() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new SimpleProtocol.PolicyFactory() {
@Override
public RoutingPolicy create(String param) {
return new RoutingPolicy() {
@Override
public void select(RoutingContext context) {
context.addChild(Route.parse("dst/session"));
}
@Override
public void merge(RoutingContext context) {
throw new RuntimeException("69");
}
@Override
public void destroy() {
}
};
}
});
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom]")).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());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.POLICY_ERROR, reply.getError(0).getCode());
assertTrue(reply.getError(0).getMessage().contains("69"));
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatPolicyOnlyConsumesDeclaredErrors.
@Test
public void requireThatPolicyOnlyConsumesDeclaredErrors() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
retryPolicy.setEnabled(false);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom:dst/unknown]")).isAccepted());
Reply reply = ((Receptor) srcSession.getReplyHandler()).getReply(60);
assertNotNull(reply);
System.out.println(reply.getTrace());
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.NO_ADDRESS_FOR_SERVICE, reply.getError(0).getCode());
assertTrace(Arrays.asList("Selecting [dst/unknown].", "[NO_ADDRESS_FOR_SERVICE @ localhost]", "Merged [dst/unknown]."), reply.getTrace());
}
Aggregations