aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/test/TestDriverIntegrationTest.java
blob: d1ca6fa964f1d56c94db68d0e150daea69a0178e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.test;

import com.google.inject.AbstractModule;
import com.google.inject.name.Names;
import org.junit.Test;

import java.util.concurrent.CountDownLatch;

/**
 * @author Simon Thoresen Hult
 */
public class TestDriverIntegrationTest {

    @Test
    public void requireThatFactoryMethodsWork() {
        TestDriver.newApplicationBundleInstance("app-a.jar", false, new MyModule()).close();
        TestDriver.newInstance(TestDriver.newOsgiFramework(), "app-a.jar", false, new MyModule()).close();
    }

    private static class MyModule extends AbstractModule {

        final CountDownLatch latch = new CountDownLatch(1);

        @Override
        protected void configure() {
            bind(CountDownLatch.class).annotatedWith(Names.named("Init")).toInstance(latch);
            bind(CountDownLatch.class).annotatedWith(Names.named("Start")).toInstance(latch);
            bind(CountDownLatch.class).annotatedWith(Names.named("Stop")).toInstance(latch);
            bind(CountDownLatch.class).annotatedWith(Names.named("Destroy")).toInstance(latch);
        }
    }
}