aboutsummaryrefslogtreecommitdiffstats
path: root/jdisc_core_test/integration_test/src/test/java/com/yahoo/jdisc/application/AbstractApplicationTestCase.java
blob: 267ba63c91b1089f2fdb746d565da58544605c98 (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
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.jdisc.application;

import com.google.inject.Inject;
import com.yahoo.jdisc.service.CurrentContainer;
import com.yahoo.jdisc.test.TestDriver;
import org.junit.Test;
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleException;

import java.util.List;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;


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

    @Test
    public void requireThatBundleInstallerCanBeAccessed() throws BundleException {
        TestDriver driver = TestDriver.newInjectedApplicationInstance(MyApplication.class);
        MyApplication app = (MyApplication)driver.application();
        List<Bundle> lst = app.installAndStartBundle("cert-a.jar");
        assertEquals(1, lst.size());
        assertEquals("com.yahoo.vespa.jdisc_core.cert-a", lst.get(0).getSymbolicName());
        app.stopAndUninstallBundle(lst.get(0));
        assertTrue(driver.close());
    }

    private static class MyApplication extends AbstractApplication {

        @Inject
        public MyApplication(BundleInstaller bundleInstaller, ContainerActivator activator,
                             CurrentContainer container) {
            super(bundleInstaller, activator, container);
        }

        @Override
        public void start() {

        }
    }
}