use of com.yahoo.messagebus.test.SimpleReply in project vespa by vespa-engine.
the class RoutableTestCase method testReplyDiscard.
public void testReplyDiscard() {
Receptor handler = new Receptor();
Message msg = new SimpleMessage("foo");
msg.pushHandler(handler);
Reply reply = new SimpleReply("bar");
reply.swapState(msg);
reply.discard();
assertNull(handler.getReply(0));
}
use of com.yahoo.messagebus.test.SimpleReply in project vespa by vespa-engine.
the class RoutableTestCase method testReplySwapState.
public void testReplySwapState() {
Reply foo = new SimpleReply("foo");
Message fooMsg = new SimpleMessage("foo");
foo.setMessage(fooMsg);
foo.setRetryDelay(1);
foo.addError(new Error(ErrorCode.APP_FATAL_ERROR, "fatal"));
foo.addError(new Error(ErrorCode.APP_TRANSIENT_ERROR, "transient"));
Reply bar = new SimpleReply("bar");
Message barMsg = new SimpleMessage("bar");
bar.setMessage(barMsg);
bar.setRetryDelay(2);
bar.addError(new Error(ErrorCode.ERROR_LIMIT, "err"));
foo.swapState(bar);
assertEquals(barMsg, foo.getMessage());
assertEquals(fooMsg, bar.getMessage());
assertEquals(2.0, foo.getRetryDelay());
assertEquals(1.0, bar.getRetryDelay());
assertEquals(1, foo.getNumErrors());
assertEquals(2, bar.getNumErrors());
}
use of com.yahoo.messagebus.test.SimpleReply in project vespa by vespa-engine.
the class SharedDestinationSessionTestCase method requireThatSessionCanSendReply.
@Test
public void requireThatSessionCanSendReply() throws InterruptedException {
RemoteClient client = RemoteClient.newInstanceWithInternSlobrok();
MessageQueue queue = new MessageQueue();
DestinationSessionParams params = new DestinationSessionParams().setMessageHandler(queue);
SharedDestinationSession session = newDestinationSession(client.slobrokId(), params);
Route route = Route.parse(session.connectionSpec());
assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted());
Message msg = queue.awaitMessage(60, TimeUnit.SECONDS);
assertNotNull(msg);
Reply reply = new SimpleReply("bar");
reply.swapState(msg);
session.sendReply(reply);
assertNotNull(client.awaitReply(60, TimeUnit.SECONDS));
session.release();
client.close();
}
use of com.yahoo.messagebus.test.SimpleReply in project vespa by vespa-engine.
the class MbusServerTestCase method assertError.
private static void assertError(List<Integer> expectedErrors, int responseStatus, int... responseErrors) {
MyRequestHandler requestHandler = MyRequestHandler.newInstance();
ServerTestDriver driver = ServerTestDriver.newInstance(requestHandler);
assertTrue(driver.sendMessage(new SimpleMessage("foo")));
assertNotNull(requestHandler.awaitRequest());
Reply reply = new SimpleReply("bar");
reply.swapState(((MbusRequest) requestHandler.request).getMessage());
for (int err : responseErrors) {
reply.addError(new Error(err, "err"));
}
assertTrue(requestHandler.sendResponse(new MbusResponse(responseStatus, reply)));
assertNotNull(reply = driver.awaitReply());
List<Integer> actual = new LinkedList<>();
for (int i = 0; i < reply.getNumErrors(); ++i) {
actual.add(reply.getError(i).getCode());
}
assertEquals(expectedErrors, actual);
assertTrue(driver.close());
}
use of com.yahoo.messagebus.test.SimpleReply in project vespa by vespa-engine.
the class SharedIntermediateSessionTestCase method requireThatSessionCanSendReply.
@Test
public void requireThatSessionCanSendReply() throws InterruptedException {
RemoteClient client = RemoteClient.newInstanceWithInternSlobrok();
MessageQueue queue = new MessageQueue();
IntermediateSessionParams params = new IntermediateSessionParams().setMessageHandler(queue);
SharedIntermediateSession session = newIntermediateSession(client.slobrokId(), params);
Route route = Route.parse(session.connectionSpec());
assertTrue(client.sendMessage(new SimpleMessage("foo").setRoute(route)).isAccepted());
Message msg = queue.awaitMessage(60, TimeUnit.SECONDS);
assertNotNull(msg);
Reply reply = new SimpleReply("bar");
reply.swapState(msg);
session.sendReply(reply);
assertNotNull(client.awaitReply(60, TimeUnit.SECONDS));
session.release();
client.close();
}
Aggregations