use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class CallableRequestDispatchTestCase method requireThatDispatchIsCalled.
@Test
public void requireThatDispatchIsCalled() throws Exception {
final TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
Response response = new Response(Response.Status.OK);
builder.serverBindings().bind("http://host/path", new MyRequestHandler(response));
driver.activateContainer(builder);
assertSame(response, new CallableRequestDispatch() {
@Override
protected Request newRequest() {
return new Request(driver, URI.create("http://host/path"));
}
}.call());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class RequestDeniedTestCase method requireThatRequestDeniedIsThrown.
@Test
public void requireThatRequestDeniedIsThrown() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
RequestHandler requestHandler = new MyRequestHandler();
builder.serverBindings().bind("http://host/path", requestHandler);
driver.activateContainer(builder);
Request request = new Request(driver, URI.create("http://host/path"));
try {
request.connect(new MyResponseHandler());
fail();
} catch (RequestDeniedException e) {
assertSame(request, e.request());
}
request.release();
driver.close();
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class TestDriverTestCase method requireThatDispatchRequestWorks.
@Test
public void requireThatDispatchRequestWorks() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyRequestHandler requestHandler = new MyRequestHandler(new MyContentChannel());
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("scheme://host/path", requestHandler);
driver.activateContainer(builder);
driver.dispatchRequest("scheme://host/path", new MyResponseHandler());
assertNotNull(requestHandler.handler);
assertTrue(requestHandler.content.closed);
requestHandler.handler.handleResponse(new Response(Response.Status.OK)).close(null);
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class TestDriverTestCase method requireThatConnectRequestWorks.
@Test
public void requireThatConnectRequestWorks() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyRequestHandler requestHandler = new MyRequestHandler(new MyContentChannel());
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("scheme://host/path", requestHandler);
driver.activateContainer(builder);
ContentChannel content = driver.connectRequest("scheme://host/path", new MyResponseHandler());
assertNotNull(content);
content.close(null);
assertNotNull(requestHandler.handler);
requestHandler.handler.handleResponse(new Response(Response.Status.OK)).close(null);
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class TestDriverTestCase method requireThatFailedRequestConnectDoesNotBlockClose.
@Test
public void requireThatFailedRequestConnectDoesNotBlockClose() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("scheme://host/path", new MyRequestHandler(null));
driver.activateContainer(builder);
try {
driver.connectRequest("scheme://host/path", new MyResponseHandler());
fail();
} catch (RequestDeniedException e) {
}
assertTrue(driver.close());
}
Aggregations