use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatSelectExceptionIsCaught.
@Test
public void requireThatSelectExceptionIsCaught() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", exceptionOnSelectThrowingMockFactory());
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom]")).isAccepted());
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 assertAcknowledge.
private void assertAcknowledge() {
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
dstSession.acknowledge(msg);
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatIgnoreResultCanBeSetInHopBlueprint.
@Test
public void requireThatIgnoreResultCanBeSetInHopBlueprint() {
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addHop(new HopSpec("foo", "dst/session").setIgnoreResult(true)));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("foo")).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());
}
use of com.yahoo.messagebus.test.Receptor in project vespa by vespa-engine.
the class RoutingTestCase method requireThatRouteExpansionOnlyReplacesFirstHop.
@Test
public void requireThatRouteExpansionOnlyReplacesFirstHop() {
srcServer.setupRouting(new RoutingTableSpec(SimpleProtocol.NAME).addRoute(new RouteSpec("foo").addHop("dst/session").addHop("bar")));
assertTrue(srcSession.send(createMessage("msg"), Route.parse("route:foo baz")).isAccepted());
Message msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60);
assertNotNull(msg);
assertEquals(2, msg.getRoute().getNumHops());
assertEquals("bar", msg.getRoute().getHop(0).toString());
assertEquals("baz", msg.getRoute().getHop(1).toString());
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 requireThatTransientErrorsAreRetriedWithPolicy.
@Test
public void requireThatTransientErrorsAreRetriedWithPolicy() {
SimpleProtocol protocol = new SimpleProtocol();
protocol.addPolicyFactory("Custom", new CustomPolicyFactory());
srcServer.mb.putProtocol(protocol);
assertTrue(srcSession.send(createMessage("msg"), Route.parse("[Custom: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, "err1"));
dstSession.reply(reply);
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
reply = new EmptyReply();
reply.swapState(msg);
reply.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "err2"));
dstSession.reply(reply);
assertNotNull(msg = ((Receptor) dstSession.getMessageHandler()).getMessage(60));
dstSession.acknowledge(msg);
assertNotNull(reply = ((Receptor) srcSession.getReplyHandler()).getReply(60));
System.out.println(reply.getTrace());
assertFalse(reply.hasErrors());
assertTrace(Arrays.asList("Source session accepted a 3 byte message. 1 message(s) now pending.", "Running routing policy 'Custom'.", "Selecting [dst/session].", "Component 'dst/session' selected by policy 'Custom'.", "Resolving 'dst/session'.", "Sending message (version ${VERSION}) from client to 'dst/session'", "Message (type 1) received at 'dst' for session 'session'.", "[APP_TRANSIENT_ERROR @ localhost]: err1", "Sending reply (version ${VERSION}) from 'dst'.", "Reply (type 0) received at client.", "Routing policy 'Custom' merging replies.", "Merged [dst/session].", "Message scheduled for retry 1 in 0.0 seconds.", "Resender resending message.", "Running routing policy 'Custom'.", "Selecting [dst/session].", "Component 'dst/session' selected by policy 'Custom'.", "Resolving 'dst/session'.", "Sending message (version ${VERSION}) from client to 'dst/session'", "Message (type 1) received at 'dst' for session 'session'.", "[APP_TRANSIENT_ERROR @ localhost]: err2", "Sending reply (version ${VERSION}) from 'dst'.", "Reply (type 0) received at client.", "Routing policy 'Custom' merging replies.", "Merged [dst/session].", "Message scheduled for retry 2 in 0.0 seconds.", "Resender resending message.", "Running routing policy 'Custom'.", "Selecting [dst/session].", "Component 'dst/session' selected by policy 'Custom'.", "Resolving 'dst/session'.", "Sending message (version ${VERSION}) from client to 'dst/session'", "Message (type 1) received at 'dst' for session 'session'.", "Sending reply (version ${VERSION}) from 'dst'.", "Reply (type 0) received at client.", "Routing policy 'Custom' merging replies.", "Merged [dst/session].", "Source session received reply. 0 message(s) now pending."), reply.getTrace());
}
Aggregations