Search in sources :

Example 26 with Subsystem

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

the class BasicSubsystem method getParents.

@Override
public Collection<Subsystem> getParents() {
    AriesSubsystemParentsHeader header = getDeploymentManifest().getAriesSubsystemParentsHeader();
    if (header == null)
        return Collections.emptyList();
    Collection<Subsystem> result = new ArrayList<Subsystem>(header.getClauses().size());
    for (AriesSubsystemParentsHeader.Clause clause : header.getClauses()) {
        BasicSubsystem subsystem = Activator.getInstance().getSubsystems().getSubsystemById(clause.getId());
        if (subsystem == null)
            continue;
        result.add(subsystem);
    }
    return result;
}
Also used : AriesSubsystem(org.apache.aries.subsystem.AriesSubsystem) Subsystem(org.osgi.service.subsystem.Subsystem) ArrayList(java.util.ArrayList) AriesSubsystemParentsHeader(org.apache.aries.subsystem.core.archive.AriesSubsystemParentsHeader)

Example 27 with Subsystem

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

the class Aries1608Test method test.

private void test(AriesProvisionDependenciesDirective provisionDependencies) throws Exception {
    boolean flag = AriesProvisionDependenciesDirective.INSTALL.equals(provisionDependencies);
    Subsystem root = getRootSubsystem();
    try {
        Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + provisionDependencies.toString()).content("org.apache.aries.subsystem.itests.aries1608provider,org.apache.aries.subsystem.itests.aries1608required").bundle("aries1608required", getClass().getClassLoader().getResourceAsStream("aries1608/aries1608required.jar")).build(), flag);
        try {
            startSubsystem(subsystem, flag);
            stopSubsystem(subsystem);
        } catch (SubsystemException e) {
            e.printStackTrace();
            fail("Subsystem should have started");
        } finally {
            uninstallSubsystemSilently(subsystem);
        }
    } catch (SubsystemException e) {
        e.printStackTrace();
        fail("Subsystem should have installed");
    }
}
Also used : SubsystemArchiveBuilder(org.apache.aries.subsystem.itests.util.SubsystemArchiveBuilder) Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemException(org.osgi.service.subsystem.SubsystemException)

Example 28 with Subsystem

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

the class Aries1434Test method testActiveChild.

@Test
public void testActiveChild() throws Exception {
    Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
    try {
        Subsystem compositeA = getChild(applicationA, COMPOSITE_A, null, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
        startSubsystem(compositeA);
        try {
            assertState(State.ACTIVE, compositeA);
            startSubsystem(applicationA);
            try {
                assertState(State.ACTIVE, applicationA);
                assertState(State.ACTIVE, compositeA);
            } finally {
                stopSubsystemSilently(applicationA);
            }
        } finally {
            stopSubsystemSilently(compositeA);
        }
    } finally {
        uninstallSubsystemSilently(applicationA);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) Test(org.junit.Test) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest)

Example 29 with Subsystem

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

the class Aries1435Test method testWovenSubsystemContainsProvider.

@Test
public void testWovenSubsystemContainsProvider() throws Exception {
    registerWeavingHook("b");
    Subsystem applicationE = installSubsystemFromFile(APPLICATION_E);
    try {
        assertConstituent(applicationE, BUNDLE_B);
        testDynamicImport(applicationE, "b.B");
        testSharingPolicy(applicationE, "b", false);
    } finally {
        uninstallSubsystemSilently(applicationE);
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem) SubsystemTest(org.apache.aries.subsystem.itests.SubsystemTest) Test(org.junit.Test)

Example 30 with Subsystem

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

the class Aries1435Test method testWildcardEverything.

@Test
public void testWildcardEverything() throws Exception {
    registerWeavingHook("b", "*");
    Subsystem compositeB = installSubsystemFromFile(COMPOSITE_B);
    try {
        Bundle bundleB = compositeB.getBundleContext().installBundle(BUNDLE_B, new ByteArrayInputStream(createBundleBContent()));
        try {
            Subsystem applicationB = installSubsystemFromFile(compositeB, APPLICATION_B);
            Subsystem featureB = installSubsystemFromFile(applicationB, FEATURE_B);
            Subsystem applicationE = installSubsystemFromFile(featureB, APPLICATION_E);
            testSharingPolicy(applicationE, "b", false);
            testSharingPolicy(applicationE, "org.osgi.framework.Constants", false);
            testSharingPolicy(applicationB, "b", false);
            testSharingPolicy(applicationB, "org.osgi.framework.Constants", false);
            testSharingPolicy(compositeB, "b", false);
            testSharingPolicy(compositeB, "org.osgi.framework.Constants", false);
            testSharingPolicy(getRootSubsystem(), "b", false);
            testSharingPolicy(getRootSubsystem(), "org.osgi.framework.Constants", false);
            testDynamicImport(applicationE, "b.B");
            testDynamicImport(applicationE, "org.osgi.framework.Constants");
            testDynamicImport(featureB, "b.B");
            testDynamicImport(featureB, "org.osgi.framework.Constants");
            testDynamicImport(applicationB, "b.B");
            testDynamicImport(applicationB, "org.osgi.framework.Constants");
            testDynamicImport(compositeB, "b.B");
            testDynamicImport(compositeB, "org.osgi.framework.Constants");
            testSharingPolicy(applicationE, "b", true);
            testSharingPolicy(applicationE, "org.osgi.framework.Constants", true);
            testSharingPolicy(applicationB, "b", true);
            testSharingPolicy(applicationB, "org.osgi.framework.Constants", true);
            testSharingPolicy(compositeB, "b", true);
            testSharingPolicy(compositeB, "org.osgi.framework.Constants", true);
            testSharingPolicy(getRootSubsystem(), "b", false);
            testSharingPolicy(getRootSubsystem(), "org.osgi.framework.Constants", false);
            uninstallSubsystemSilently(applicationE);
            uninstallSubsystemSilently(featureB);
            uninstallSubsystemSilently(applicationB);
        } finally {
            uninstallSilently(bundleB);
        }
    } finally {
        uninstallSubsystemSilently(compositeB);
    }
}
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