use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ResourcePoolTestCase method requireThatAddDoesNotRetainArgument.
@Test
public void requireThatAddDoesNotRetainArgument() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyResource foo = new MyResource();
assertEquals(1, foo.retainCount());
new ResourcePool(driver.newContainerBuilder()).add(foo);
assertEquals(1, foo.retainCount());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ResourcePoolTestCase method requireThatRetainRetainsArgument.
@Test
public void requireThatRetainRetainsArgument() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
MyResource foo = new MyResource();
assertEquals(1, foo.retainCount());
new ResourcePool(driver.newContainerBuilder()).retain(foo);
assertEquals(2, foo.retainCount());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class LatencyTestCase method runLatencyMeasurements.
@Test
public void runLatencyMeasurements() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
MyRequestHandler foo = new MyRequestHandler("foo");
MyRequestHandler bar = new MyRequestHandler("bar");
MyRequestHandler baz = new MyRequestHandler("baz");
builder.serverBindings().bind(foo.uri, foo);
builder.serverBindings().bind(bar.uri, bar);
builder.serverBindings().bind(baz.uri, baz);
driver.activateContainer(builder);
measureLatencies(NUM_REQUESTS, driver, foo, bar, baz);
TimeTrack time = measureLatencies(NUM_REQUESTS, driver, foo, bar, baz);
System.err.println("\n" + time);
foo.release();
bar.release();
baz.release();
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ActiveContainerTestCase method requireThatGuiceAccessorWorks.
@Test
public void requireThatGuiceAccessorWorks() {
final Object obj = new Object();
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi(new AbstractModule() {
@Override
protected void configure() {
bind(Object.class).toInstance(obj);
}
});
ActiveContainer container = new ActiveContainer(driver.newContainerBuilder());
assertSame(obj, container.guiceInjector().getInstance(Object.class));
driver.close();
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ActiveContainerTestCase method requireThatServerBindingAccessorWorks.
@Test
public void requireThatServerBindingAccessorWorks() {
TestDriver driver = TestDriver.newSimpleApplicationInstanceWithoutOsgi();
ContainerBuilder builder = driver.newContainerBuilder();
RequestHandler foo = new NonWorkingRequestHandler();
RequestHandler bar = new NonWorkingRequestHandler();
builder.serverBindings().bind("http://host/foo", foo);
builder.serverBindings("bar").bind("http://host/bar", bar);
ActiveContainer container = new ActiveContainer(builder);
Map<String, BindingSet<RequestHandler>> bindings = container.serverBindings();
assertNotNull(bindings);
assertEquals(2, bindings.size());
BindingSet<RequestHandler> set = bindings.get(BindingSet.DEFAULT);
assertNotNull(set);
Iterator<Map.Entry<UriPattern, RequestHandler>> it = set.iterator();
assertNotNull(it);
assertTrue(it.hasNext());
Map.Entry<UriPattern, RequestHandler> entry = it.next();
assertNotNull(entry);
assertEquals(new UriPattern("http://host/foo"), entry.getKey());
assertSame(foo, entry.getValue());
assertFalse(it.hasNext());
assertNotNull(set = bindings.get("bar"));
assertNotNull(it = set.iterator());
assertTrue(it.hasNext());
assertNotNull(entry = it.next());
assertEquals(new UriPattern("http://host/bar"), entry.getKey());
assertSame(bar, entry.getValue());
assertFalse(it.hasNext());
assertNotNull(bindings = container.clientBindings());
assertEquals(1, bindings.size());
assertNotNull(set = bindings.get(BindingSet.DEFAULT));
assertNotNull(it = set.iterator());
assertFalse(it.hasNext());
driver.close();
}
Aggregations