use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class AbstractServerProviderTestCase method requireThatAccessorsWork.
@Test
public void requireThatAccessorsWork() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
MyServerProvider server = builder.getInstance(MyServerProvider.class);
assertNotNull(server.container());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ConnectToHandlerTestCase method requireThatConnectToHandlerWorks.
@Test
public void requireThatConnectToHandlerWorks() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyRequestHandler requestHandler = new MyRequestHandler(new MyContent());
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://host/*", requestHandler);
driver.activateContainer(builder);
Request request = new Request(driver, URI.create("http://host/path"));
MyResponseHandler responseHandler = new MyResponseHandler();
ContentChannel content = request.connect(responseHandler);
request.release();
assertNotNull(content);
content.close(null);
assertNotNull(requestHandler.handler);
assertSame(request, requestHandler.request);
requestHandler.handler.handleResponse(new Response(Response.Status.OK)).close(null);
driver.close();
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ProxyRequestHandlerTestCase method newRequest.
private static Request newRequest(TestDriver driver, RequestHandler requestHandler) {
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://host/path", requestHandler);
driver.activateContainer(builder);
return new Request(driver, URI.create("http://host/path"));
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class AbstractRequestHandlerTestCase method requireThatEchoWorks.
@Test
public void requireThatEchoWorks() throws InterruptedException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://localhost/", new EchoHandler());
driver.activateContainer(builder);
for (int i = 0; i < NUM_REQUESTS; ++i) {
MyResponseHandler responseHandler = new MyResponseHandler();
RequestDispatch dispatch = driver.newRequestDispatch("http://localhost/", responseHandler);
FastContentWriter requestContent = dispatch.connectFastWriter();
ByteBuffer buf = ByteBuffer.allocate(69);
requestContent.write(buf);
requestContent.close();
assertSame(buf, responseHandler.content.read());
assertNull(responseHandler.content.read());
}
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class AbstractRequestHandlerTestCase method requireThatHelloWorldWorks.
@Test
public void requireThatHelloWorldWorks() throws InterruptedException {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://localhost/", new HelloWorldHandler());
driver.activateContainer(builder);
for (int i = 0; i < NUM_REQUESTS; ++i) {
MyResponseHandler responseHandler = new MyResponseHandler();
driver.newRequestDispatch("http://localhost/", responseHandler).dispatch();
ByteBuffer buf = responseHandler.content.read();
assertNotNull(buf);
assertEquals("Hello World!", new String(buf.array(), buf.arrayOffset() + buf.position(), buf.remaining(), UTF8));
assertNull(responseHandler.content.read());
}
assertTrue(driver.close());
}
Aggregations