use of org.apache.aries.subsystem.itests.util.BundleArchiveBuilder 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");
}
}
use of org.apache.aries.subsystem.itests.util.BundleArchiveBuilder in project aries by apache.
the class Aries1442Test method createFeature.
private Subsystem createFeature() throws Exception {
Subsystem root = getRootSubsystem();
Subsystem feature = installSubsystem(root, "feature", new SubsystemArchiveBuilder().symbolicName("feature").type(SubsystemConstants.SUBSYSTEM_TYPE_FEATURE).bundle("a", new BundleArchiveBuilder().symbolicName("a").exportPackage("a").build()).build(), true);
uninstallableSubsystems.add(feature);
startSubsystem(feature, true);
stoppableSubsystems.add(feature);
return feature;
}
use of org.apache.aries.subsystem.itests.util.BundleArchiveBuilder in project aries by apache.
the class Aries1445Test method buildSubsystem.
private InputStream buildSubsystem(Subsystem parent, String symbolicName, String type) throws IOException {
SubsystemArchiveBuilder builder = new SubsystemArchiveBuilder();
builder.symbolicName(symbolicName);
builder.type(type);
if (SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE.equals(type)) {
builder.importPackage("b.package");
}
builder.bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage("b.package").build());
return builder.build();
}
use of org.apache.aries.subsystem.itests.util.BundleArchiveBuilder in project aries by apache.
the class Aries1383Test method testComApiComImplComClient.
@Test
public void testComApiComImplComClient() 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_COMPOSITE).content("client;version=\"[0,0]\"").importPackage("org.osgi.framework").requireCapability("osgi.service;filter:=\"(objectClass=" + TestService.class.getName() + ")\";effective:=active").importService(TestService.class.getName()).requireBundle("api,impl").bundle("client", new BundleArchiveBuilder().symbolicName("client").importPackage("org.osgi.framework").requireCapability("osgi.service;filter:=\"(objectClass=" + TestService.class.getName() + ")\";effective:=active").requireBundle("api,impl").activator(TestServiceClientActivator.class).build()).build(), false);
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() + "\"").exportService(TestService.class.getName()).importPackage("org.osgi.framework").requireBundle("api").provideCapability("osgi.wiring.bundle;osgi.wiring.bundle=impl;bundle-version=0").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);
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);
return result;
}
} };
ExecutorService executor = Executors.newFixedThreadPool(3);
List<Future<Subsystem>> installFutures = executor.invokeAll(Arrays.asList(installCallables));
final Subsystem client = installFutures.get(0).get();
final Subsystem impl = installFutures.get(1).get();
final Subsystem api = installFutures.get(2).get();
@SuppressWarnings("unchecked") Callable<Void>[] startCallables = new Callable[] { new Callable<Void>() {
@Override
public Void call() throws Exception {
client.start();
assertEvent(client, State.INSTALLED, subsystemEvents.poll(client.getSubsystemId(), 5000));
assertEvent(client, State.RESOLVING, subsystemEvents.poll(client.getSubsystemId(), 5000));
assertEvent(client, State.RESOLVED, subsystemEvents.poll(client.getSubsystemId(), 5000));
assertEvent(client, State.STARTING, subsystemEvents.poll(client.getSubsystemId(), 5000));
assertEvent(client, State.ACTIVE, subsystemEvents.poll(client.getSubsystemId(), 5000));
return null;
}
}, new Callable<Void>() {
@Override
public Void call() throws Exception {
impl.start();
assertEvent(impl, State.INSTALLED, subsystemEvents.poll(impl.getSubsystemId(), 5000));
assertEvent(impl, State.RESOLVING, subsystemEvents.poll(impl.getSubsystemId(), 5000));
assertEvent(impl, State.RESOLVED, subsystemEvents.poll(impl.getSubsystemId(), 5000));
assertEvent(impl, State.STARTING, subsystemEvents.poll(impl.getSubsystemId(), 5000));
assertEvent(impl, State.ACTIVE, subsystemEvents.poll(impl.getSubsystemId(), 5000));
return null;
}
}, new Callable<Void>() {
@Override
public Void call() throws Exception {
api.start();
assertEvent(api, State.INSTALLED, subsystemEvents.poll(api.getSubsystemId(), 5000));
assertEvent(api, State.RESOLVING, subsystemEvents.poll(api.getSubsystemId(), 5000));
assertEvent(api, State.RESOLVED, subsystemEvents.poll(api.getSubsystemId(), 5000));
assertEvent(api, State.STARTING, subsystemEvents.poll(api.getSubsystemId(), 5000));
assertEvent(api, State.ACTIVE, subsystemEvents.poll(api.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.apache.aries.subsystem.itests.util.BundleArchiveBuilder in project aries by apache.
the class Aries1383Test method testRestart.
@Test
public void testRestart() throws Exception {
Subsystem root = getRootSubsystem();
Subsystem a1 = installSubsystem(root, "a1", new SubsystemArchiveBuilder().symbolicName("a1").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).content("b1,c1;type=osgi.subsystem.composite").bundle("b1", new BundleArchiveBuilder().symbolicName("b1").importPackage("b2").build()).bundle("b2", new BundleArchiveBuilder().symbolicName("b2").exportPackage("b2").build()).subsystem("c1", new SubsystemArchiveBuilder().symbolicName("c1").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString()).content("b1;version=\"[0,0]\"").importPackage("b2").bundle("b1", new BundleArchiveBuilder().symbolicName("b1").importPackage("b2").build()).build()).build(), false);
uninstallableSubsystems.add(a1);
assertChild(root, "a1");
assertState(State.INSTALLING, a1);
Subsystem c1 = getChild(a1, "c1", null, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
assertNotNull("Missing child", c1);
assertState(State.INSTALLING, c1);
restartSubsystemsImplBundle();
root = getRootSubsystem();
a1 = getChild(root, "a1");
assertNotNull("Missing child", a1);
uninstallableSubsystems.add(a1);
assertState(State.INSTALLING, a1);
assertConstituent(a1, "b1");
assertNotConstituent(root, "b2");
c1 = getChild(a1, "c1", null, SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE);
assertNotNull("Missing child", c1);
uninstallableSubsystems.add(c1);
assertConstituent(c1, "b1");
startSubsystem(c1, false);
stoppableSubsystems.add(c1);
assertState(State.INSTALLED, a1);
stoppableSubsystems.add(a1);
assertConstituent(root, "b2");
}
Aggregations