use of org.apache.aries.subsystem.AriesSubsystem in project aries by apache.
the class AriesSubsystemTest method testAddRequirements.
/*
* Test the AriesSubsystem.addRequirements(Collection<Requirement>) method.
*
* There are several things to consider for this test.
*
* (1) Installing a child subsystem before the requirement has been added
* should fail.
* (2) Installing a child subsystem after the requirement has been added
* should succeed.
* (3) The newly created region should contain all of the bundles from the
* old one.
* (4) The connections between the subsystem with the added requirement and
* its parents should be reestablished.
* (5) The connections between the subsystem with the added requirement and
* its children should be reestablished.
*/
@Test
public void testAddRequirements() throws Exception {
AriesSubsystem compositeA = (AriesSubsystem) installSubsystemFromFile(COMPOSITE_A);
try {
startSubsystem(compositeA);
assertCompositeABefore(compositeA);
// Test that the installation of applicationA fails.
try {
installSubsystemFromFile(compositeA, APPLICATION_A);
fail("Subsystem should not have installed due to unresolved org.osgi.framework package requirement");
} catch (SubsystemException e) {
// Okay.
}
// Add the org.osgi.framework package requirement.
Requirement requirement = new BasicRequirement.Builder().namespace(PackageNamespace.PACKAGE_NAMESPACE).directive(PackageNamespace.REQUIREMENT_FILTER_DIRECTIVE, "(osgi.wiring.package=org.osgi.framework)").resource(EasyMock.createMock(Resource.class)).build();
compositeA.addRequirements(Collections.singleton(requirement));
// Test that the bundles were copied over to the newly created region.
assertCompositeABefore(compositeA);
// Test that the parent connections were reestablished.
assertRefreshAndResolve(Collections.singletonList(getConstituentAsBundle(compositeA, BUNDLE_B, null, null)));
// Test that the child connections were reestablished.
assertRefreshAndResolve(Collections.singletonList(getConstituentAsBundle(getConstituentAsSubsystem(compositeA, APPLICATION_B, null, SubsystemConstants.SUBSYSTEM_TYPE_APPLICATION), BUNDLE_B, null, null)));
// Test that the installation of applicationA succeeds.
AriesSubsystem applicationA;
try {
applicationA = (AriesSubsystem) installSubsystemFromFile(compositeA, APPLICATION_A);
startSubsystem(applicationA);
} catch (SubsystemException e) {
fail("Subsystem should have installed and started");
}
assertCompositeAAfter(compositeA);
} finally {
stopAndUninstallSubsystemSilently(compositeA);
}
}
use of org.apache.aries.subsystem.AriesSubsystem in project aries by apache.
the class AriesSubsystemTest method testServiceRegistrations.
@Test
public void testServiceRegistrations() {
Subsystem root1 = null;
try {
root1 = getRootSubsystem();
} catch (Exception e) {
fail(Subsystem.class.getName() + " service not registered");
}
AriesSubsystem root2 = null;
try {
root2 = getRootAriesSubsystem();
} catch (Exception e) {
fail(AriesSubsystem.class.getName() + " service not registered");
}
assertSame("Services should be the same instance", root1, root2);
}
Aggregations