use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ContainerResourceTestCase method requireThatServerProvidersAreRetainedOnActivate.
@Test
public void requireThatServerProvidersAreRetainedOnActivate() {
MyServerProvider foo = new MyServerProvider();
MyServerProvider bar = new MyServerProvider();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverProviders().install(foo);
builder.serverProviders().install(bar);
assertEquals(0, foo.retainCnt.get());
assertEquals(0, bar.retainCnt.get());
driver.activateContainer(builder);
assertEquals(1, foo.retainCnt.get());
assertEquals(1, bar.retainCnt.get());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ContainerSnapshotTestCase method requireThatServerHandlerCanBeResolved.
@Test
public void requireThatServerHandlerCanBeResolved() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://foo/*", MyRequestHandler.newInstance());
driver.activateContainer(builder);
Request request = new Request(driver, URI.create("http://foo/"));
assertNotNull(request.container().resolveHandler(request));
assertNotNull(request.getBindingMatch());
request.release();
request = new Request(driver, URI.create("http://foo/"));
request.setServerRequest(false);
assertNull(request.container().resolveHandler(request));
assertNull(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 ContainerSnapshotTestCase method requireThatClientBindingsAreUsed.
@Test
public void requireThatClientBindingsAreUsed() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.clientBindings().bind("http://host/path", MyRequestHandler.newInstance());
driver.activateContainer(builder);
Request request = new Request(driver, URI.create("http://host/path"));
assertNull(request.container().resolveHandler(request));
request.setServerRequest(false);
assertNotNull(request.container().resolveHandler(request));
request.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ContainerSnapshotTestCase method requireThatBindingMatchIsSetByResolveHandler.
@Test
public void requireThatBindingMatchIsSetByResolveHandler() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind("http://*/*", MyRequestHandler.newInstance());
driver.activateContainer(builder);
Request request = new Request(driver, URI.create("http://localhost:69/status.html"));
assertNotNull(request.container().resolveHandler(request));
BindingMatch<RequestHandler> match = request.getBindingMatch();
assertNotNull(match);
assertEquals(3, match.groupCount());
assertEquals("localhost", match.group(0));
assertEquals("69", match.group(1));
assertEquals("status.html", match.group(2));
request.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.application.ContainerBuilder in project vespa by vespa-engine.
the class ThroughputTestCase method runMeasurements.
private static List<Long> runMeasurements(TestDriver driver, RequestHandler handler) throws Exception {
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings().bind(HANDLER_URI, handler);
driver.activateContainer(builder);
handler.release();
List<Long> ret = new LinkedList<>();
for (int i = MIN_THREADS; i <= MAX_THREADS; i *= 2) {
ret.add(measureThroughput(driver, i));
}
return ret;
}
Aggregations