use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class ThreadedRequestHandlerTestCase method requireThatNotImplementedHandlerDoesNotPreventShutdown.
@Test
public void requireThatNotImplementedHandlerDoesNotPreventShutdown() throws Exception {
TestDriver driver = newTestDriver("http://localhost/", new ThreadedRequestHandler(newExecutor()) {
});
assertEquals(Response.Status.NOT_IMPLEMENTED, dispatchRequest(driver, "http://localhost/", ByteBuffer.wrap(new byte[] { 69 })).get(600, TimeUnit.SECONDS).getStatus());
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class BundleActivatorIntegrationTest method requireThatBundleActivatorHasAccessToCurrentContainer.
@Test
public void requireThatBundleActivatorHasAccessToCurrentContainer() throws Exception {
TestDriver driver = TestDriver.newSimpleApplicationInstance();
OsgiFramework osgi = driver.osgiFramework();
BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
Bundle bundle = installer.installAndStart("my-bundle-activator.jar").get(0);
Class<?> serviceClass = bundle.loadClass("com.yahoo.jdisc.bundle.MyService");
assertNotNull(serviceClass);
BundleContext ctx = osgi.bundleContext();
ServiceReference<?> serviceRef = ctx.getServiceReference(serviceClass.getName());
assertNotNull(serviceRef);
Object service = ctx.getService(serviceRef);
assertNotNull(service);
assertTrue(serviceClass.isInstance(service));
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class BundleActivatorIntegrationTest method requireThatApplicationBundleActivatorHasAccessToCurrentContainer.
@Test
public void requireThatApplicationBundleActivatorHasAccessToCurrentContainer() throws Exception {
TestDriver driver = TestDriver.newApplicationBundleInstance("app-g-act.jar", false);
OsgiFramework osgi = driver.osgiFramework();
Class<?> serviceClass = osgi.bundles().get(1).loadClass("com.yahoo.jdisc.bundle.MyService");
assertNotNull(serviceClass);
BundleContext ctx = osgi.bundleContext();
ServiceReference<?> serviceRef = ctx.getServiceReference(serviceClass.getName());
assertNotNull(serviceRef);
Object service = ctx.getService(serviceRef);
assertNotNull(service);
assertTrue(serviceClass.isInstance(service));
assertTrue(driver.close());
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class GuiceRepositoryIntegrationTest method requireThatInstallFromBundleWorks.
@Test
public void requireThatInstallFromBundleWorks() throws Exception {
MyModule module = new MyModule();
TestDriver driver = TestDriver.newSimpleApplicationInstance(module);
ContainerBuilder builder = driver.newContainerBuilder();
List<Module> prev = new LinkedList<>(builder.guiceModules().collection());
BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
Bundle bundle = installer.installAndStart("my-guice-module.jar").get(0);
builder.guiceModules().install(bundle, "com.yahoo.jdisc.bundle.MyGuiceModule");
List<Module> next = new LinkedList<>(builder.guiceModules().collection());
next.removeAll(prev);
assertEquals(1, next.size());
assertTrue(module.initLatch.await(60, TimeUnit.SECONDS));
assertNotNull(builder.guiceModules().getInstance(Injector.class));
assertTrue(module.configLatch.await(60, TimeUnit.SECONDS));
driver.close();
}
use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.
the class GuiceRepositoryIntegrationTest method requireThatInstallAllFromBundleWorks.
@Test
public void requireThatInstallAllFromBundleWorks() throws Exception {
TestDriver driver = TestDriver.newSimpleApplicationInstance(new MyModule());
ContainerBuilder builder = driver.newContainerBuilder();
List<Module> prev = new LinkedList<>(builder.guiceModules().collection());
BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
Bundle bundle = installer.installAndStart("my-guice-module.jar").get(0);
builder.guiceModules().installAll(bundle, Arrays.asList("com.yahoo.jdisc.bundle.MyGuiceModule", "com.yahoo.jdisc.bundle.MyGuiceModule"));
List<Module> next = new LinkedList<>(builder.guiceModules().collection());
next.removeAll(prev);
assertEquals(2, next.size());
driver.close();
}
Aggregations