Search in sources :

Example 71 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 72 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 73 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 74 with Subsystem

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

the class TargetRegion method add.

private void add(Collection<Subsystem> children) {
    for (Subsystem child : children) {
        region.add(child);
        if (((BasicSubsystem) child).isScoped()) {
            // Children of scoped children are not part of the target region.
            continue;
        }
        // Children of unscoped children are part of the target region.
        add(child.getChildren());
    }
}
Also used : Subsystem(org.osgi.service.subsystem.Subsystem)

Example 75 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)

Aggregations

Subsystem (org.osgi.service.subsystem.Subsystem)202 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)13 Hashtable (java.util.Hashtable)9 ServiceReference (org.osgi.framework.ServiceReference)8 File (java.io.File)7 BundleContext (org.osgi.framework.BundleContext)7 ArrayList (java.util.ArrayList)6 TestCapability (org.apache.aries.subsystem.itests.util.TestCapability)6 ByteArrayInputStream (java.io.ByteArrayInputStream)5 FileInputStream (java.io.FileInputStream)5 Callable (java.util.concurrent.Callable)5 BundleException (org.osgi.framework.BundleException)5