Search in sources :

Example 96 with TestDriver

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

the class BundleInstallerIntegrationTest method requireThatInstallWorks.

@Test
public void requireThatInstallWorks() throws Exception {
    TestDriver driver = TestDriver.newSimpleApplicationInstance();
    List<Bundle> prev = new LinkedList<>(driver.osgiFramework().bundles());
    BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
    Bundle bundle = installer.installAndStart("cert-a.jar").get(0);
    assertNotNull(bundle);
    assertEquals("com.yahoo.vespa.jdisc_core.cert-a", bundle.getSymbolicName());
    boolean found = false;
    for (Bundle entry : driver.osgiFramework().bundles()) {
        assertNotNull(entry);
        if (prev.remove(entry)) {
            continue;
        }
        assertFalse(found);
        assertSame(bundle, entry);
        found = true;
    }
    assertTrue(prev.isEmpty());
    assertTrue(found);
    driver.close();
}
Also used : Bundle(org.osgi.framework.Bundle) TestDriver(com.yahoo.jdisc.test.TestDriver) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 97 with TestDriver

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

the class BundleInstallerIntegrationTest method requireThatUninstallAllWorks.

@Test
public void requireThatUninstallAllWorks() throws Exception {
    TestDriver driver = TestDriver.newSimpleApplicationInstance();
    List<Bundle> prev = new LinkedList<>(driver.osgiFramework().bundles());
    BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
    List<Bundle> bundles = installer.installAndStart("cert-a.jar", "cert-b.jar");
    assertNotNull(bundles);
    installer.stopAndUninstall(bundles);
    List<Bundle> next = new LinkedList<>(driver.osgiFramework().bundles());
    next.removeAll(prev);
    assertTrue(next.isEmpty());
    driver.close();
}
Also used : Bundle(org.osgi.framework.Bundle) TestDriver(com.yahoo.jdisc.test.TestDriver) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 98 with TestDriver

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

the class BundleInstallerIntegrationTest method requireThatPrivilegedActivatorInstructionButNoRootPrivilegesKindOfWorksOnABestEffortBasis.

@Test
public void requireThatPrivilegedActivatorInstructionButNoRootPrivilegesKindOfWorksOnABestEffortBasis() throws Exception {
    TestDriver driver = TestDriver.newSimpleApplicationInstance();
    BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
    installer.installAndStart("cert-j-priv.jar");
    driver.close();
}
Also used : TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 99 with TestDriver

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

the class BundleInstallerIntegrationTest method requireThatInstallInstalledThrowsException.

@Test
public void requireThatInstallInstalledThrowsException() throws Exception {
    TestDriver driver = TestDriver.newSimpleApplicationInstance();
    BundleInstaller installer = new BundleInstaller(driver.osgiFramework());
    Bundle bundle = installer.installAndStart("cert-a.jar").get(0);
    assertNotNull(bundle);
    try {
        installer.installAndStart("cert-a.jar");
        fail();
    } catch (BundleException e) {
        assertEquals("OSGi bundle com.yahoo.vespa.jdisc_core.cert-a already started.", e.getMessage());
    }
    driver.close();
}
Also used : Bundle(org.osgi.framework.Bundle) BundleException(org.osgi.framework.BundleException) TestDriver(com.yahoo.jdisc.test.TestDriver) Test(org.junit.Test)

Example 100 with TestDriver

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

the class ServerRepositoryIntegrationTest method requireThatInstallUnknownClassThrows.

@Test
public void requireThatInstallUnknownClassThrows() 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();
    try {
        builder.serverProviders().install(bundle, "class.not.Found");
        fail();
    } catch (ClassNotFoundException e) {
    }
    driver.close();
}
Also used : Bundle(org.osgi.framework.Bundle) 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