use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ProxyRequestHandlerTestCase method requireThatRequestHandlerIsProxied.
@Test
public void requireThatRequestHandlerIsProxied() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyRequestHandler requestHandler = MyRequestHandler.newEagerCompletion();
Request request = newRequest(driver, requestHandler);
RequestHandler resolvedHandler = new ProxyRequestHandler(request.container().resolveHandler(request));
MyResponseHandler responseHandler = MyResponseHandler.newEagerCompletion();
resolvedHandler.handleRequest(request, responseHandler).close(null);
request.release();
assertNotNull(requestHandler.handler);
resolvedHandler.handleTimeout(request, responseHandler);
assertTrue(requestHandler.timeout);
requestHandler.respond();
requestHandler.release();
final ResourceReference resolvedHandlerReference = resolvedHandler.refer();
// release installed ref
assertTrue(driver.close());
assertFalse(requestHandler.destroyed);
resolvedHandlerReference.close();
assertTrue(requestHandler.destroyed);
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ResourcePoolTestCase method requireThatAddReturnsArgument.
@Test
public void requireThatAddReturnsArgument() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyResource foo = new MyResource();
assertSame(foo, new ResourcePool(driver.newContainerBuilder()).add(foo));
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ResourcePoolTestCase method requireThatGetReturnsBoundInstance.
@Test
public void requireThatGetReturnsBoundInstance() {
final MyResource foo = new MyResource();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() {
@Override
protected void configure() {
bind(MyResource.class).toInstance(foo);
}
});
ResourcePool pool = new ResourcePool(driver.newContainerBuilder());
assertSame(foo, pool.get(MyResource.class));
assertSame(foo, pool.get(Key.get(MyResource.class)));
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ResourcePoolTestCase method requireThatRetainReturnsArgument.
@Test
public void requireThatRetainReturnsArgument() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyResource foo = new MyResource();
assertSame(foo, new ResourcePool(driver.newContainerBuilder()).retain(foo));
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ResourcePoolTestCase method requireThatGetDoesNotRetainArgument.
@Test
public void requireThatGetDoesNotRetainArgument() {
final MyResource foo = new MyResource();
assertEquals(1, foo.retainCount());
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() {
@Override
protected void configure() {
bind(MyResource.class).toInstance(foo);
}
});
ResourcePool pool = new ResourcePool(driver.newContainerBuilder());
pool.get(MyResource.class);
assertEquals(1, foo.retainCount());
pool.get(Key.get(MyResource.class));
assertEquals(1, foo.retainCount());
assertTrue(driver.close());
}
Aggregations