Search in sources :

Example 66 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class ServerRepositoryIntegrationTest method requireThatInstallFromBundleWorks.

@Test
public void requireThatInstallFromBundleWorks() throws Exception {
    MyModule module = new MyModule();
    TestDriver driver = TestDriver.newSimpleApplicationInstance(module);
    BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
    Bundle bundle = installer.installAndStart("my-server-provider.jar").get(0);
    ContainerBuilder builder = driver.newContainerBuilder();
    builder.serverProviders().install(bundle, "com.yahoo.jdisc.bundle.MyServerProvider");
    assertTrue(module.init.await(60, TimeUnit.SECONDS));
    Iterator<ServerProvider> it = builder.serverProviders().iterator();
    assertTrue(it.hasNext());
    ServerProvider server = it.next();
    assertNotNull(server);
    server.start();
    assertTrue(module.start.await(60, TimeUnit.SECONDS));
    server.close();
    assertTrue(module.close.await(60, TimeUnit.SECONDS));
    server.release();
    assertTrue(module.destroy.await(60, TimeUnit.SECONDS));
    assertFalse(it.hasNext());
    driver.close();
}
Also used : ServerProvider(com.yahoo.jdisc.service.ServerProvider) Bundle(org.osgi.framework.Bundle) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 67 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class ApplicationLoaderIntegrationTest method requireThatPrivilegedBundleCanBeLoadedPrivileged.

@Test
public void requireThatPrivilegedBundleCanBeLoadedPrivileged() throws Exception {
    MyModule module = new MyModule();
    TestDriver driver = TestDriver.newApplicationBundleInstance("app-b-priv.jar", true, module);
    assertTrue(module.init.await(60, TimeUnit.SECONDS));
    assertEquals("com.yahoo.jdisc.bundle.ApplicationB", driver.application().getClass().getName());
    driver.close();
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 68 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class ApplicationLoaderIntegrationTest method requireThatUnprivilegedBundleCanBeLoadedUnprivileged.

@Test
public void requireThatUnprivilegedBundleCanBeLoadedUnprivileged() throws Exception {
    MyModule module = new MyModule();
    TestDriver driver = TestDriver.newApplicationBundleInstance("app-a.jar", false, module);
    assertTrue(module.init.await(60, TimeUnit.SECONDS));
    assertEquals("com.yahoo.jdisc.bundle.ApplicationA", driver.application().getClass().getName());
    driver.close();
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 69 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class ApplicationLoaderIntegrationTest method requireThatUnprivilegedBundleCanBeLoadedPrivileged.

@Test
public void requireThatUnprivilegedBundleCanBeLoadedPrivileged() throws Exception {
    MyModule module = new MyModule();
    TestDriver driver = TestDriver.newApplicationBundleInstance("app-a.jar", true, module);
    assertTrue(module.init.await(60, TimeUnit.SECONDS));
    assertEquals("com.yahoo.jdisc.bundle.ApplicationA", driver.application().getClass().getName());
    driver.close();
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 70 with TestDriver

use of com.yahoo.jdisc.test.TestDriver in project vespa by vespa-engine.

the class ApplicationLoaderIntegrationTest method requireThatInstallBundleInstructionPropagatesPrivileges.

@Test
public void requireThatInstallBundleInstructionPropagatesPrivileges() throws Exception {
    TestDriver driver = TestDriver.newApplicationBundleInstance("app-ej-priv.jar", true);
    assertEquals("com.yahoo.jdisc.bundle.ApplicationE", driver.application().getClass().getName());
    driver.close();
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Aggregations

TestDriver (com.yahoo.jdisc.test.TestDriver)134 Test (org.junit.Test)128 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)39 Request (com.yahoo.jdisc.Request)22 Bundle (org.osgi.framework.Bundle)14 AbstractModule (com.google.inject.AbstractModule)13 ByteBuffer (java.nio.ByteBuffer)12 Response (com.yahoo.jdisc.Response)10 ContentChannel (com.yahoo.jdisc.handler.ContentChannel)10 RequestHandler (com.yahoo.jdisc.handler.RequestHandler)6 Executor (java.util.concurrent.Executor)6 LinkedList (java.util.LinkedList)5 BundleContext (org.osgi.framework.BundleContext)4 BindingSet (com.yahoo.jdisc.application.BindingSet)3 ServerProvider (com.yahoo.jdisc.service.ServerProvider)3 NonWorkingRequestHandler (com.yahoo.jdisc.test.NonWorkingRequestHandler)3 SimpleMessage (com.yahoo.messagebus.test.SimpleMessage)3 CountDownLatch (java.util.concurrent.CountDownLatch)3 BundleException (org.osgi.framework.BundleException)3 Module (com.google.inject.Module)2