use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1416Test method testSystemRepositoryBundlePreferredProvider.
@Test
public void testSystemRepositoryBundlePreferredProvider() throws Exception {
Subsystem root = getRootSubsystem();
// Install bundle B providing capability b into the root subsystem's
// region.
Bundle bundleB = installBundleFromFile(BUNDLE_B, root);
try {
// Install application A containing content bundle A requiring
// capability b and dependency bundle B providing capability b.
// Bundle B is not content but will become part of the local
// repository. The preferred provider is bundle B. Bundle B from the
// system repository should be used. Bundle B from the local
// repository should not be provisioned.
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
uninstallSubsystemSilently(applicationA);
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have installed");
} finally {
uninstallSilently(bundleB);
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1383Test method test16c.
/*
* (16) Unscoped subsystem with a value of apache-aries-provision-dependencies
* that is the same as the scoped parent installs successfully.
*/
@Test
public void test16c() throws Exception {
Subsystem root = getRootSubsystem();
try {
Subsystem subsystem = installSubsystem(root, "application", new SubsystemArchiveBuilder().symbolicName("application").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).subsystem("feature", new SubsystemArchiveBuilder().symbolicName("feature").type(SubsystemConstants.SUBSYSTEM_TYPE_FEATURE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).build()).build(), false);
uninstallSubsystemSilently(subsystem);
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have installed");
}
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1383Test method test13.
/*
* (13) The root subsystem has apache-aries-provision-dependencies:=install.
*/
@Test
public void test13() throws Exception {
Subsystem root = getRootSubsystem();
Map<String, String> headers = root.getSubsystemHeaders(null);
String headerStr = headers.get(SubsystemConstants.SUBSYSTEM_TYPE);
SubsystemTypeHeader header = new SubsystemTypeHeader(headerStr);
AriesProvisionDependenciesDirective directive = header.getAriesProvisionDependenciesDirective();
assertEquals("Wrong directive", AriesProvisionDependenciesDirective.INSTALL, directive);
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1383Test method testComApiComImplAppClient.
@Test
public void testComApiComImplAppClient() throws Exception {
Subsystem root = getRootSubsystem();
final Subsystem shared = installSubsystem(root, "shared", new SubsystemArchiveBuilder().symbolicName("shared").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString() + ';' + SubsystemConstants.PROVISION_POLICY_DIRECTIVE + ":=" + SubsystemConstants.PROVISION_POLICY_ACCEPT_DEPENDENCIES).importPackage("org.osgi.framework").build(), false);
uninstallableSubsystems.add(shared);
shared.start();
stoppableSubsystems.add(shared);
@SuppressWarnings("unchecked") Callable<Subsystem>[] installCallables = new Callable[] { new Callable<Subsystem>() {
@Override
public Subsystem call() throws Exception {
Subsystem result = installSubsystem(shared, "client", new SubsystemArchiveBuilder().symbolicName("client").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION).bundle("client", new BundleArchiveBuilder().symbolicName("client").importPackage("org.apache.aries.subsystem.itests.defect").requireCapability("osgi.service;filter:=\"(objectClass=" + TestService.class.getName() + ")\";effective:=active").build()).build(), false);
uninstallableSubsystems.add(result);
return result;
}
}, new Callable<Subsystem>() {
@Override
public Subsystem call() throws Exception {
Subsystem result = installSubsystem(shared, "impl", new SubsystemArchiveBuilder().symbolicName("impl").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE).content("impl;version=\"[0,0]\"").provideCapability("osgi.service;objectClass:List<String>=\"" + TestService.class.getName() + "\"").importPackage("org.osgi.framework").requireBundle("api").bundle("impl", new BundleArchiveBuilder().symbolicName("impl").provideCapability("osgi.service;objectClass:List<String>=\"" + TestService.class.getName() + "\"").importPackage("org.osgi.framework").requireBundle("api").clazz(TestServiceImpl.class).activator(TestServiceImplActivator.class).build()).build(), false);
uninstallableSubsystems.add(result);
return result;
}
}, new Callable<Subsystem>() {
@Override
public Subsystem call() throws Exception {
Subsystem result = installSubsystem(shared, "api", new SubsystemArchiveBuilder().symbolicName("api").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE).content("api;version=\"[0,0]\"").exportPackage("org.apache.aries.subsystem.itests.defect").provideCapability("osgi.wiring.bundle;osgi.wiring.bundle=api;bundle-version=0").bundle("api", new BundleArchiveBuilder().symbolicName("api").exportPackage("org.apache.aries.subsystem.itests.defect").clazz(TestService.class).build()).build(), false);
uninstallableSubsystems.add(result);
return result;
}
} };
ExecutorService executor = Executors.newFixedThreadPool(3);
List<Future<Subsystem>> installFutures = executor.invokeAll(Arrays.asList(installCallables));
final Subsystem a1 = installFutures.get(0).get();
final Subsystem c1 = installFutures.get(1).get();
final Subsystem c2 = installFutures.get(2).get();
@SuppressWarnings("unchecked") Callable<Void>[] startCallables = new Callable[] { new Callable<Void>() {
@Override
public Void call() throws Exception {
a1.start();
stoppableSubsystems.add(a1);
assertEvent(a1, State.INSTALLED, subsystemEvents.poll(a1.getSubsystemId(), 5000));
assertEvent(a1, State.RESOLVING, subsystemEvents.poll(a1.getSubsystemId(), 5000));
assertEvent(a1, State.RESOLVED, subsystemEvents.poll(a1.getSubsystemId(), 5000));
assertEvent(a1, State.STARTING, subsystemEvents.poll(a1.getSubsystemId(), 5000));
assertEvent(a1, State.ACTIVE, subsystemEvents.poll(a1.getSubsystemId(), 5000));
return null;
}
}, new Callable<Void>() {
@Override
public Void call() throws Exception {
c1.start();
stoppableSubsystems.add(c1);
assertEvent(c1, State.INSTALLED, subsystemEvents.poll(c1.getSubsystemId(), 5000));
assertEvent(c1, State.RESOLVING, subsystemEvents.poll(c1.getSubsystemId(), 5000));
assertEvent(c1, State.RESOLVED, subsystemEvents.poll(c1.getSubsystemId(), 5000));
assertEvent(c1, State.STARTING, subsystemEvents.poll(c1.getSubsystemId(), 5000));
assertEvent(c1, State.ACTIVE, subsystemEvents.poll(c1.getSubsystemId(), 5000));
return null;
}
}, new Callable<Void>() {
@Override
public Void call() throws Exception {
c2.start();
stoppableSubsystems.add(c2);
assertEvent(c2, State.INSTALLED, subsystemEvents.poll(c2.getSubsystemId(), 5000));
assertEvent(c2, State.RESOLVING, subsystemEvents.poll(c2.getSubsystemId(), 5000));
assertEvent(c2, State.RESOLVED, subsystemEvents.poll(c2.getSubsystemId(), 5000));
assertEvent(c2, State.STARTING, subsystemEvents.poll(c2.getSubsystemId(), 5000));
assertEvent(c2, State.ACTIVE, subsystemEvents.poll(c2.getSubsystemId(), 5000));
return null;
}
} };
List<Future<Void>> startFutures = executor.invokeAll(Arrays.asList(startCallables));
startFutures.get(0).get();
startFutures.get(1).get();
startFutures.get(2).get();
}
use of org.osgi.service.subsystem.Subsystem in project aries by apache.
the class Aries1419Test method testProvideCapability.
@Test
public void testProvideCapability() throws Exception {
Bundle bundleB = installBundleFromFile(BUNDLE_B);
try {
Subsystem applicationB = installSubsystemFromFile(APPLICATION_B);
uninstallSubsystemSilently(applicationB);
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have installed");
} finally {
uninstallSilently(bundleB);
}
}
Aggregations