use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class MbusRequestHandlerTestCase method requireThatHandlerCanRespondInOtherThread.
@Test
public void requireThatHandlerCanRespondInOtherThread() throws Exception {
TestDriver driver = newTestDriver(ThreadedReplier.INSTANCE);
Response response = dispatchMessage(driver, new SimpleMessage("msg")).get(60, TimeUnit.SECONDS);
assertTrue(response instanceof MbusResponse);
assertEquals(Response.Status.OK, response.getStatus());
Reply reply = ((MbusResponse) response).getReply();
assertTrue(reply instanceof EmptyReply);
assertFalse(reply.hasErrors());
assertTrue(driver.close());
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class MbusClientTestCase method requireThatRequestContentDoesNotSupportWrite.
@Test
public void requireThatRequestContentDoesNotSupportWrite() throws InterruptedException {
ClientTestDriver driver = ClientTestDriver.newInstance();
MyResponseHandler responseHandler = MyResponseHandler.newInstance();
Request request = null;
ContentChannel content;
try {
request = driver.newClientRequest(new SimpleMessage("foo"));
content = request.connect(responseHandler);
} finally {
if (request != null) {
request.release();
}
}
try {
content.write(ByteBuffer.allocate(69), null);
fail();
} catch (UnsupportedOperationException e) {
}
content.close(null);
assertTrue(driver.awaitMessageAndSendReply(new EmptyReply()));
assertNotNull(responseHandler.awaitResponse());
assertTrue(driver.close());
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class MbusClientTestCase method requireThatStateIsTransferredToResponse.
@Test
public void requireThatStateIsTransferredToResponse() {
ClientTestDriver driver = ClientTestDriver.newInstance();
MyResponseHandler responseHandler = MyResponseHandler.newInstance();
Message msg = new SimpleMessage("foo");
Object pushedCtx = new Object();
msg.setContext(pushedCtx);
ReplyHandler pushedHandler = new MyReplyHandler();
msg.pushHandler(pushedHandler);
Object currentCtx = new Object();
msg.setContext(currentCtx);
msg.getTrace().setLevel(6);
assertTrue(driver.sendMessage(msg, responseHandler));
assertTrue(driver.awaitMessageAndSendReply(new EmptyReply()));
Response response = responseHandler.awaitResponse();
assertTrue(response.getClass().getName(), response instanceof MbusResponse);
Reply reply = ((MbusResponse) response).getReply();
assertSame(currentCtx, reply.getContext());
assertEquals(6, reply.getTrace().getLevel());
assertSame(pushedHandler, reply.popHandler());
assertSame(pushedCtx, reply.getContext());
assertTrue(driver.close());
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class MbusClientTestCase method requireThatStateIsTransferredToSyncMbusSendFailureResponse.
@Test
public void requireThatStateIsTransferredToSyncMbusSendFailureResponse() {
ClientTestDriver driver = ClientTestDriver.newInstance();
driver.sourceSession().close();
Message msg = new SimpleMessage("foo");
ReplyHandler pushedHandler = new MyReplyHandler();
Object pushedCtx = new Object();
msg.setContext(pushedCtx);
msg.pushHandler(pushedHandler);
Object currentCtx = new Object();
msg.setContext(currentCtx);
msg.getTrace().setLevel(6);
MyResponseHandler responseHandler = MyResponseHandler.newInstance();
driver.sendMessage(msg, responseHandler);
Response response = responseHandler.awaitResponse();
assertNotNull(response);
assertTrue(response.getClass().getName(), response instanceof MbusResponse);
Reply reply = ((MbusResponse) response).getReply();
assertSame(currentCtx, reply.getContext());
assertEquals(6, reply.getTrace().getLevel());
assertSame(pushedHandler, reply.popHandler());
assertSame(pushedCtx, reply.getContext());
assertTrue(driver.close());
}
use of com.yahoo.messagebus.test.SimpleMessage in project vespa by vespa-engine.
the class MbusClientTestCase method requireThatSyncMbusSendFailureRespondsWithError.
@Test
public void requireThatSyncMbusSendFailureRespondsWithError() {
ClientTestDriver driver = ClientTestDriver.newInstance();
driver.sourceSession().close();
MyResponseHandler responseHandler = MyResponseHandler.newInstance();
driver.sendMessage(new SimpleMessage("foo"), responseHandler);
Response response = responseHandler.awaitResponse();
assertNotNull(response);
assertTrue(response.getClass().getName(), response instanceof MbusResponse);
Reply reply = ((MbusResponse) response).getReply();
assertEquals(1, reply.getNumErrors());
assertEquals(ErrorCode.SEND_QUEUE_CLOSED, reply.getError(0).getCode());
assertTrue(driver.close());
}
Aggregations