use of com.yahoo.jdisc.handler.RequestDispatch in project vespa by vespa-engine.
the class TimeoutManagerImplTestCase method requireThatNoEntryIsMadeIfTimeoutHandlerHasBeenSet.
@Test
public void requireThatNoEntryIsMadeIfTimeoutHandlerHasBeenSet() {
final Context ctx = new Context(MyRequestHandler.newInstance());
new RequestDispatch() {
@Override
protected Request newRequest() {
Request request = new Request(ctx.driver, URI.create(REQUEST_URI));
request.setTimeout(10, TimeUnit.MILLISECONDS);
request.setTimeoutManager(new TimeoutManager() {
@Override
public void scheduleTimeout(Request request) {
}
});
return request;
}
}.dispatch();
assertFalse(ctx.awaitQueueSize(1, 100, TimeUnit.MILLISECONDS));
assertTrue(ctx.awaitQueueSize(0, 600, TimeUnit.SECONDS));
ctx.requestHandler.respond();
assertTrue(ctx.close());
}
use of com.yahoo.jdisc.handler.RequestDispatch in project vespa by vespa-engine.
the class TimeoutManagerImplTestCase method requireThatTimeoutOccursAtExpectedTime.
@Test
public void requireThatTimeoutOccursAtExpectedTime() throws InterruptedException {
final Context ctx = new Context(MyRequestHandler.newInstance());
final MyResponseHandler responseHandler = MyResponseHandler.newInstance();
ctx.forwardToTime(100);
new RequestDispatch() {
@Override
protected Request newRequest() {
Request request = new Request(ctx.driver, URI.create(REQUEST_URI));
request.setTimeout(300, TimeUnit.MILLISECONDS);
return request;
}
@Override
public ContentChannel handleResponse(Response response) {
return responseHandler.handleResponse(response);
}
}.dispatch();
ctx.forwardToTime(300);
assertFalse(responseHandler.await(100, TimeUnit.MILLISECONDS));
ctx.forwardToTime(400);
assertTrue(responseHandler.await(600, TimeUnit.SECONDS));
Response response = responseHandler.response.get();
assertNotNull(response);
assertEquals(Response.Status.GATEWAY_TIMEOUT, response.getStatus());
assertTrue(ctx.close());
}
use of com.yahoo.jdisc.handler.RequestDispatch in project vespa by vespa-engine.
the class MbusRequestHandlerTestCase method requireThatNonMbusRequestThrows.
@Test
public void requireThatNonMbusRequestThrows() throws Exception {
final TestDriver driver = newTestDriver(SameThreadReplier.INSTANCE);
try {
new RequestDispatch() {
@Override
protected Request newRequest() {
return new Request(driver, URI.create("mbus://localhost/"));
}
}.connect();
fail();
} catch (UnsupportedOperationException e) {
assertEquals("Expected MbusRequest, got com.yahoo.jdisc.Request.", e.getMessage());
}
assertTrue(driver.close());
}
Aggregations