Search in sources :

Example 6 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class Aries1435Test method testNoProviders.

@Test
public void testNoProviders() throws Exception {
    registerWeavingHook("b");
    Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
    try {
        Bundle bundleA = getConstituentAsBundle(applicationB, BUNDLE_A, null, null);
        bundleA.loadClass("a.A");
        try {
            bundleA.loadClass("b.B");
            fail("Class should not have loaded");
        } catch (ClassNotFoundException e) {
        // Okay.
        }
        testSharingPolicy(applicationB, "b", false);
    } finally {
        uninstallSubsystemSilently(applicationB);
    }
}
Also used : Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 7 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class Aries1538Test method testEffectiveActive.

private void testEffectiveActive(AriesProvisionDependenciesDirective provisionDependencies) throws Exception {
    boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
    BundleArchiveBuilder bab = new BundleArchiveBuilder();
    bab.symbolicName("bundle");
    bab.requireCapability("osgi.service;filter:=\"(&(objectClass=java.lang.Object)(foo=bar))\";effective:=active");
    bab.exportPackage("foo");
    Subsystem root = getRootSubsystem();
    Bundle a = root.getBundleContext().installBundle("a", bab.build());
    uninstallableBundles.add(a);
    startBundle(a);
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + provisionDependencies.toString()).bundle("b", new BundleArchiveBuilder().symbolicName("b").importPackage("foo").build()).build(), flag);
        uninstallableSubsystems.add(subsystem);
        startSubsystem(subsystem, flag);
        stoppableSubsystems.add(subsystem);
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed and started");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) BundleArchiveBuilder(org.apache.aries.subsystem.itests.util.BundleArchiveBuilder) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Example 8 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class ManyFeaturesWithSharedBundlesTest method testInstallOneFeatureAfterAll.

@Test
@org.junit.Ignore
public void testInstallOneFeatureAfterAll() throws Exception {
    Collection<Callable<Subsystem>> callables = createInstallFeatureCallables();
    Collection<Future<Subsystem>> futures = executor.invokeAll(callables);
    Callable<Subsystem> callable = new Callable<Subsystem>() {

        @Override
        public Subsystem call() throws Exception {
            Subsystem feature = getRootSubsystem().install("onefeature", createFeature("onefeature"));
            return feature;
        }
    };
    runTrials(Collections.singletonList(callable));
    uninstallSubsystems(futures);
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Future(java.util.concurrent.Future) Callable(java.util.concurrent.Callable) Test(org.junit.Test)

Example 9 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class Aries1435Test method testChildExportsPackage.

@Test
public void testChildExportsPackage() throws Exception {
    registerWeavingHook("b");
    Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
    try {
        Subsystem compositeE = installSubsystemFromFile(applicationB, COMPOSITE_E);
        try {
            startSubsystem(compositeE);
            try {
                testSharingPolicy(applicationB, "b", true);
                testDynamicImport(applicationB, "b.B");
                testSharingPolicy(applicationB, "b", true);
                testSharingPolicy(compositeE, "b", false);
                testSharingPolicy(getRootSubsystem(), "b", false);
            } finally {
                stopSubsystemSilently(compositeE);
            }
        } finally {
            uninstallSubsystemSilently(compositeE);
        }
    } finally {
        uninstallSubsystemSilently(applicationB);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 10 with Subsystem

use of org.osgi.service.subsystem.Subsystem in project aries by apache.

the class Aries1435Test method testDisconnectedEdgeWithParent.

@Test
public void testDisconnectedEdgeWithParent() throws Exception {
    registerWeavingHook("b");
    Bundle bundleB = getRootSubsystem().getBundleContext().installBundle(BUNDLE_B, new ByteArrayInputStream(createBundleBContent()));
    try {
        Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
        try {
            Subsystem applicationB = getChild(applicationA, APPLICATION_B);
            uninstallSubsystem(applicationB);
            removeConnectionWithParent(applicationA);
            applicationB = installSubsystemFromFile(applicationA, APPLICATION_B);
            try {
                try {
                    testDynamicImport(applicationB, "b.B");
                    fail("Dynamic import should have failed");
                } catch (AssertionError e) {
                // Okay.
                }
                testSharingPolicy(applicationB, "b", true);
                testSharingPolicy(applicationA, "b", false);
                testSharingPolicy(getRootSubsystem(), "b", false);
            } finally {
                uninstallSubsystemSilently(applicationB);
            }
        } finally {
            uninstallSubsystemSilently(applicationA);
        }
    } finally {
        uninstallSilently(bundleB);
    }
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) Bundle(org.osgi.framework.Bundle) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Aggregations

Subsystem (org.osgi.service.subsystem.Subsystem)187 Test (org.junit.Test)151 SubsystemTest (org.apache.aries.subsystem.itests.SubsystemTest)78 AriesSubsystem (org.apache.aries.subsystem.AriesSubsystem)52 SubsystemException (org.osgi.service.subsystem.SubsystemException)50 Bundle (org.osgi.framework.Bundle)48 SubsystemArchiveBuilder (org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder)31 BundleArchiveBuilder (org.apache.aries.subsystem.itests.util.BundleArchiveBuilder)22 BasicSubsystem (org.apache.aries.subsystem.core.internal.BasicSubsystem)19 IOException (java.io.IOException)11 Hashtable (java.util.Hashtable)8 BundleContext (org.osgi.framework.BundleContext)7 File (java.io.File)6 ArrayList (java.util.ArrayList)6 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 Callable (java.util.concurrent.Callable)5 BundleException (org.osgi.framework.BundleException)5 FileInputStream (java.io.FileInputStream)4 Future (java.util.concurrent.Future)4