use of com.yahoo.messagebus.jdisc.test.ClientTestDriver in project vespa by vespa-engine.
the class MbusClientTestCase method requireThatRequestResponseWorks.
@Test
public void requireThatRequestResponseWorks() {
ClientTestDriver driver = ClientTestDriver.newInstance();
MyResponseHandler responseHandler = MyResponseHandler.newInstance();
assertTrue(driver.sendMessage(new SimpleMessage("foo"), responseHandler));
assertTrue(driver.awaitMessageAndSendReply(new EmptyReply()));
Response response = responseHandler.awaitResponse();
assertNotNull(response);
assertEquals(Response.Status.OK, response.getStatus());
assertTrue(driver.close());
}
use of com.yahoo.messagebus.jdisc.test.ClientTestDriver in project vespa by vespa-engine.
the class MbusClientTestCase method requireThatNonMbusRequestIsDenied.
@Test
public void requireThatNonMbusRequestIsDenied() throws InterruptedException {
ClientTestDriver driver = ClientTestDriver.newInstance();
Request serverReq = null;
Request clientReq = null;
try {
serverReq = driver.newServerRequest();
clientReq = new Request(serverReq, URI.create("mbus://host/path"));
clientReq.connect(MyResponseHandler.newInstance());
fail();
} catch (RequestDeniedException e) {
System.out.println(e.getMessage());
} finally {
if (serverReq != null) {
serverReq.release();
}
if (clientReq != null) {
clientReq.release();
}
}
assertTrue(driver.close());
}
use of com.yahoo.messagebus.jdisc.test.ClientTestDriver in project vespa by vespa-engine.
the class MbusClientTestCase method requireThatResponseIsMbus.
@Test
public void requireThatResponseIsMbus() {
ClientTestDriver driver = ClientTestDriver.newInstance();
MyResponseHandler responseHandler = MyResponseHandler.newInstance();
assertTrue(driver.sendMessage(new SimpleMessage("foo"), responseHandler));
assertTrue(driver.awaitMessageAndSendReply(new EmptyReply()));
Response response = responseHandler.awaitResponse();
assertTrue(response instanceof MbusResponse);
Reply reply = ((MbusResponse) response).getReply();
assertTrue(reply instanceof EmptyReply);
assertTrue(driver.close());
}
use of com.yahoo.messagebus.jdisc.test.ClientTestDriver 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.jdisc.test.ClientTestDriver 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());
}
Aggregations