use of org.osgi.service.subsystem.SubsystemException in project aries by apache.
the class Aries1383Test method testMatchingCapabilityInDisconnectedRegion.
@Test
public void testMatchingCapabilityInDisconnectedRegion() throws Exception {
Subsystem root = getRootSubsystem();
BundleArchiveBuilder b1Builder = new BundleArchiveBuilder().symbolicName("b1").exportPackage("b1");
Bundle b1 = root.getBundleContext().installBundle("b1", b1Builder.build());
try {
Subsystem a1 = installSubsystem(root, "a1", new SubsystemArchiveBuilder().symbolicName("a1").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION + ';' + AriesProvisionDependenciesDirective.RESOLVE.toString() + ';' + SubsystemConstants.PROVISION_POLICY_DIRECTIVE + ":=" + SubsystemConstants.PROVISION_POLICY_ACCEPT_DEPENDENCIES).build(), false);
uninstallableSubsystems.add(a1);
startSubsystem(a1, false);
stoppableSubsystems.add(a1);
removeConnectionWithParent(a1);
Subsystem a2 = installSubsystem(a1, "a2", new SubsystemArchiveBuilder().symbolicName("a2").type(SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION).content("b2").bundle("b2", new BundleArchiveBuilder().symbolicName("b2").importPackage("b1").build()).bundle("b1", b1Builder.build()).build(), false);
uninstallableSubsystems.add(a2);
assertState(State.INSTALLING, a2);
assertNotConstituent(a1, "b1");
try {
startSubsystem(a2, false);
stoppableSubsystems.add(a2);
assertConstituent(a1, "b1");
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have started");
}
} finally {
uninstallSilently(b1);
}
}
use of org.osgi.service.subsystem.SubsystemException in project aries by apache.
the class Aries1383Test method test12.
/*
* (12) Subsystem with apache-aries-provision-dependencies:=resolve undergoes
* the following state transitions when starting fails due to a start
* failure: INSTALLING -> INSTALLED -> RESOLVING -> RESOLVED -> STARTING ->
* RESOLVED.
*/
@Test
public void test12() throws Exception {
Subsystem root = getRootSubsystem();
subsystemEvents.clear();
Subsystem subsystem = root.install(APPLICATION_START_FAILURE, applicationStartFailure());
try {
subsystem.start();
stopSubsystemSilently(subsystem);
fail("Subsystem should not have started");
} catch (SubsystemException e) {
e.printStackTrace();
long id = lastSubsystemId();
assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLING, subsystemEvents.poll(id, 5000), ServiceEvent.REGISTERED);
assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.INSTALLED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.RESOLVING, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.RESOLVED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.STARTING, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
assertEvent(id, APPLICATION_START_FAILURE, Version.emptyVersion, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION, State.RESOLVED, subsystemEvents.poll(id, 5000), ServiceEvent.MODIFIED);
} finally {
uninstallSubsystemSilently(subsystem);
}
}
use of org.osgi.service.subsystem.SubsystemException in project aries by apache.
the class Aries1383Test method test9.
/*
* (9) Subsystem with apache-aries-provision-dependencies:=resolve is in the
* INSTALLING state when dependencies cannot be provisioned after invoking
* the start method.
*/
@Test
public void test9() throws Exception {
Subsystem root = getRootSubsystem();
Subsystem subsystem = installSubsystem(root, APPLICATION_MISSING_DEPENDENCY, applicationMissingDependency(), false);
try {
startSubsystem(subsystem, false);
stopSubsystemSilently(subsystem);
fail("Subsystem should not have started");
} catch (SubsystemException e) {
e.printStackTrace();
assertState(State.INSTALLING, subsystem);
} finally {
uninstallSubsystemSilently(subsystem);
}
}
use of org.osgi.service.subsystem.SubsystemException in project aries by apache.
the class Aries1338Test method test.
private void test(String importPackage, String exportPackage, boolean shouldFail) throws Exception {
Subsystem root = getRootSubsystem();
try {
Subsystem subsystem = installSubsystem(root, "subsystem", new SubsystemArchiveBuilder().symbolicName("subsystem").bundle("a", new BundleArchiveBuilder().symbolicName("a").importPackage(importPackage).build()).bundle("b", new BundleArchiveBuilder().symbolicName("b").exportPackage(exportPackage).build()).build());
uninstallableSubsystems.add(subsystem);
if (shouldFail) {
fail("Subsystem should not have installed");
}
} catch (SubsystemException e) {
e.printStackTrace();
if (!shouldFail) {
fail("Subsystem should have installed");
}
}
}
use of org.osgi.service.subsystem.SubsystemException in project aries by apache.
the class Aries1383Test method testProvideCapabilityNamespaceOnly.
@Test
public void testProvideCapabilityNamespaceOnly() throws Exception {
Subsystem root = getRootSubsystem();
Subsystem c1 = installSubsystem(root, "c1", new SubsystemArchiveBuilder().symbolicName("c1").type(SubsystemConstants.SUBSYSTEM_TYPE_COMPOSITE).provideCapability("y").build());
uninstallableSubsystems.add(c1);
try {
startSubsystem(c1);
stoppableSubsystems.add(c1);
} catch (SubsystemException e) {
e.printStackTrace();
fail("Subsystem should have started");
}
}
Aggregations