use of com.yahoo.jdisc.Response in project vespa by vespa-engine.
the class RequestDispatchTestCase method requireThatDispatchHandlesCloseException.
@Test
public void requireThatDispatchHandlesCloseException() {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
Response response = new Response(Response.Status.OK);
builder.serverBindings().bind("http://localhost/", new MyRequestHandler(new ContentChannel() {
@Override
public void write(ByteBuffer buf, CompletionHandler handler) {
handler.completed();
}
@Override
public void close(CompletionHandler handler) {
throw new RuntimeException();
}
}, response));
driver.activateContainer(builder);
try {
new RequestDispatch() {
@Override
protected Request newRequest() {
return new Request(driver, URI.create("http://localhost/"));
}
@Override
protected Iterable<ByteBuffer> requestContent() {
return Arrays.asList(ByteBuffer.allocate(69));
}
}.dispatch();
fail();
} catch (RuntimeException e) {
}
assertTrue(driver.close());
}
use of com.yahoo.jdisc.Response in project vespa by vespa-engine.
the class RequestDispatchTestCase method requireThatDispatchHandlesWriteException.
@Test
public void requireThatDispatchHandlesWriteException() {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
Response response = new Response(Response.Status.OK);
builder.serverBindings().bind("http://localhost/", new MyRequestHandler(new ContentChannel() {
@Override
public void write(ByteBuffer buf, CompletionHandler handler) {
throw new RuntimeException();
}
@Override
public void close(CompletionHandler handler) {
handler.completed();
}
}, response));
driver.activateContainer(builder);
try {
new RequestDispatch() {
@Override
protected Request newRequest() {
return new Request(driver, URI.create("http://localhost/"));
}
@Override
protected Iterable<ByteBuffer> requestContent() {
return Arrays.asList(ByteBuffer.allocate(69));
}
}.dispatch();
fail();
} catch (RuntimeException e) {
}
assertTrue(driver.close());
}
Aggregations