Search in sources :

Example 1 with NonWorkingOsgiFramework

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

the class ApplicationLoaderTestCase method requireThatApplicationStartExceptionUnsetsAndDestroysApplication.

@Test
public void requireThatApplicationStartExceptionUnsetsAndDestroysApplication() throws Exception {
    MyApplication app = MyApplication.newStartException();
    ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), Arrays.asList(new MyApplicationModule(app)));
    loader.init(null, false);
    try {
        loader.start();
        fail();
    } catch (MyException e) {
    }
    assertNull(loader.application());
    assertFalse(app.stop.await(100, TimeUnit.MILLISECONDS));
    assertTrue(app.destroy.await(600, TimeUnit.SECONDS));
    try {
        loader.activateContainer(loader.newContainerBuilder());
        fail();
    } catch (ApplicationNotReadyException e) {
    }
    loader.stop();
    loader.destroy();
}
Also used : NonWorkingOsgiFramework(com.yahoo.jdisc.test.NonWorkingOsgiFramework) ApplicationNotReadyException(com.yahoo.jdisc.application.ApplicationNotReadyException) Test(org.junit.Test)

Example 2 with NonWorkingOsgiFramework

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

the class ApplicationEnvironmentModuleTestCase method requireThatContainerBuilderCanBeInjected.

@Test
public void requireThatContainerBuilderCanBeInjected() {
    ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), Collections.<Module>emptyList());
    assertNotNull(new ApplicationEnvironmentModule(loader).containerBuilder());
    assertNotNull(Guice.createInjector(new ApplicationEnvironmentModule(loader)).getInstance(ContainerBuilder.class));
}
Also used : ContainerBuilder(com.yahoo.jdisc.application.ContainerBuilder) NonWorkingOsgiFramework(com.yahoo.jdisc.test.NonWorkingOsgiFramework) Test(org.junit.Test)

Example 3 with NonWorkingOsgiFramework

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

the class ApplicationEnvironmentModuleTestCase method requireThatBindingsExist.

@Test
public void requireThatBindingsExist() {
    List<Class<?>> expected = new LinkedList<>();
    expected.add(ContainerActivator.class);
    expected.add(ContainerBuilder.class);
    expected.add(CurrentContainer.class);
    expected.add(OsgiFramework.class);
    expected.add(ThreadFactory.class);
    Injector injector = Guice.createInjector();
    for (Map.Entry<Key<?>, Binding<?>> entry : injector.getBindings().entrySet()) {
        expected.add(entry.getKey().getTypeLiteral().getRawType());
    }
    ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), Collections.<Module>emptyList());
    injector = Guice.createInjector(new ApplicationEnvironmentModule(loader));
    for (Map.Entry<Key<?>, Binding<?>> entry : injector.getBindings().entrySet()) {
        assertNotNull(expected.remove(entry.getKey().getTypeLiteral().getRawType()));
    }
    assertTrue(expected.isEmpty());
}
Also used : NonWorkingOsgiFramework(com.yahoo.jdisc.test.NonWorkingOsgiFramework) Map(java.util.Map) LinkedList(java.util.LinkedList) Test(org.junit.Test)

Example 4 with NonWorkingOsgiFramework

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

the class ApplicationLoaderTestCase method requireThatStopDoesNotFailWithoutStart.

@Test
public void requireThatStopDoesNotFailWithoutStart() throws Exception {
    ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), Collections.<Module>emptyList());
    loader.stop();
    loader.destroy();
}
Also used : NonWorkingOsgiFramework(com.yahoo.jdisc.test.NonWorkingOsgiFramework) Test(org.junit.Test)

Example 5 with NonWorkingOsgiFramework

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

the class ApplicationLoaderTestCase method requireThatApplicationStopExceptionDestroysApplication.

@Test
public void requireThatApplicationStopExceptionDestroysApplication() throws Exception {
    MyApplication app = MyApplication.newStopException();
    ApplicationLoader loader = new ApplicationLoader(new NonWorkingOsgiFramework(), Arrays.asList(new MyApplicationModule(app)));
    loader.init(null, false);
    loader.start();
    try {
        loader.stop();
    } catch (MyException e) {
    }
    assertTrue(app.destroy.await(600, TimeUnit.SECONDS));
    loader.destroy();
}
Also used : NonWorkingOsgiFramework(com.yahoo.jdisc.test.NonWorkingOsgiFramework) Test(org.junit.Test)

Aggregations

NonWorkingOsgiFramework (com.yahoo.jdisc.test.NonWorkingOsgiFramework)6 Test (org.junit.Test)6 ConfigurationException (com.google.inject.ConfigurationException)1 ApplicationNotReadyException (com.yahoo.jdisc.application.ApplicationNotReadyException)1 ContainerBuilder (com.yahoo.jdisc.application.ContainerBuilder)1 LinkedList (java.util.LinkedList)1 Map (java.util.Map)1