use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ContainerResourceTestCase method requireThatBoundRequestHandlersAreReleasedOnTermination.
@Test
public void requireThatBoundRequestHandlersAreReleasedOnTermination() {
MyRequestHandler handler = new MyRequestHandler();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://localhost/", handler);
driver.activateContainer(builder);
Container container = driver.newReference(URI.create("http://localhost/"));
assertEquals(1, handler.retainCnt.get());
driver.activateContainer(null);
assertEquals(1, handler.retainCnt.get());
container.release();
assertEquals(0, handler.retainCnt.get());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ContainerSnapshotTestCase method requireThatClientHandlerCanBeResolved.
@Test
public void requireThatClientHandlerCanBeResolved() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.clientBindings().bind("http://foo/*", MyRequestHandler.newInstance());
driver.activateContainer(builder);
Request request = new Request(driver, URI.create("http://foo/"));
assertNull(request.container().resolveHandler(request));
assertNull(request.getBindingMatch());
request.release();
request = new Request(driver, URI.create("http://foo/"));
request.setServerRequest(false);
assertNotNull(request.container().resolveHandler(request));
assertNotNull(request.getBindingMatch());
request.release();
request = new Request(driver, URI.create("http://bar/"));
assertNull(request.container().resolveHandler(request));
assertNull(request.getBindingMatch());
request.release();
request = new Request(driver, URI.create("http://bar/"));
request.setServerRequest(false);
assertNull(request.container().resolveHandler(request));
assertNull(request.getBindingMatch());
request.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class TestDriver method newInstance.
public static TestDriver newInstance(Class<? extends JettyHttpServer> serverClass, RequestHandler requestHandler, Module testConfig) throws IOException {
com.yahoo.jdisc.test.TestDriver driver = com.yahoo.jdisc.test.TestDriver.newSimpleApplicationInstance(testConfig);
ContainerBuilder builder = driver.newContainerBuilder();
JettyHttpServer server = builder.getInstance(serverClass);
builder.serverProviders().install(server);
builder.serverBindings().bind("*://*/*", requestHandler);
driver.activateContainer(builder);
server.start();
SimpleHttpClient client = new SimpleHttpClient(newSslContext(builder), server.getListenPort(), false);
return new TestDriver(driver, server, client);
}
Aggregations