use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ContainerSnapshotTestCase method requireThatActiveInjectorIsUsed.
@Test
public void requireThatActiveInjectorIsUsed() {
final Object obj = new Object();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() {
@Override
protected void configure() {
bind(Object.class).toInstance(obj);
bind(String.class).annotatedWith(Names.named("foo")).toInstance("foo");
}
});
ActiveContainer active = new ActiveContainer(driver.newContainerBuilder());
ContainerSnapshot snapshot = new ContainerSnapshot(active, null, null);
assertSame(obj, snapshot.getInstance(Object.class));
assertEquals("foo", snapshot.getInstance(Key.get(String.class, Names.named("foo"))));
snapshot.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver 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.test.TestDriver 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.test.TestDriver in project vespa by vespa-engine.
the class ContainerSnapshotTestCase method requireThatNewRequestHasSameSnapshot.
@Test
public void requireThatNewRequestHasSameSnapshot() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
driver.activateContainer(driver.newContainerBuilder());
Request foo = new Request(driver, URI.create("http://host/foo"));
Request bar = new Request(foo, URI.create("http://host/bar"));
assertSame(foo.container(), bar.container());
foo.release();
bar.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ApplicationLoaderTestCase method requireThatDestroyDoesNotFailWithActiveContainer.
@Test
public void requireThatDestroyDoesNotFailWithActiveContainer() throws Exception {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
assertNull(driver.activateContainer(driver.newContainerBuilder()));
assertTrue(driver.close());
}
Aggregations