use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ActiveContainerTestCase method requireThatServerAccessorWorks.
@Test
public void requireThatServerAccessorWorks() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
ServerProvider foo = new NonWorkingServerProvider();
builder.serverProviders().install(foo);
ServerProvider bar = new NonWorkingServerProvider();
builder.serverProviders().install(bar);
ActiveContainer container = new ActiveContainer(builder);
Iterator<ServerProvider> it = container.serverProviders().iterator();
assertTrue(it.hasNext());
assertSame(foo, it.next());
assertTrue(it.hasNext());
assertSame(bar, it.next());
assertFalse(it.hasNext());
driver.close();
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ContainerResourceTestCase method requireThatBoundRequestHandlersAreRetainedOnActivate.
@Test
public void requireThatBoundRequestHandlersAreRetainedOnActivate() {
MyRequestHandler foo = new MyRequestHandler();
MyRequestHandler bar = new MyRequestHandler();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverBindings("foo").bind("http://foo/", foo);
builder.serverBindings("bar").bind("http://bar/", 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.test.TestDriver in project vespa by vespa-engine.
the class ContainerResourceTestCase method requireThatServerProvidersAreReleasedOnTermination.
@Test
public void requireThatServerProvidersAreReleasedOnTermination() {
MyServerProvider server = new MyServerProvider();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
builder.serverProviders().install(server);
driver.activateContainer(builder);
Container container = driver.newReference(URI.create("http://localhost/"));
assertEquals(1, server.retainCnt.get());
driver.activateContainer(null);
assertEquals(1, server.retainCnt.get());
container.release();
assertEquals(0, server.retainCnt.get());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver 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.test.TestDriver 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());
}
Aggregations