use of org.apache.aries.subsystem.core.archive.Clause in project aries by apache.
the class ResolutionTest method testContentWithNonConstituentDependencyWithNonConstituentDependency.
/*
* Test that the right regions are used when validating capabilities.
*
* Application A contains a content bundle requiring capability A. Bundle B
* provides capability A and is available as an installable resource from a
* repository service. Bundle B also requires capability B. Bundle C is an
* already installed resource in the root subsystem providing capability B.
* When validating capability A, the subsystem should use the root region as
* the from region, and its own region as the to region. When validating
* capability B, the subsystem should use the root region as the from region
* as well as for the to region.
*/
@Test
public void testContentWithNonConstituentDependencyWithNonConstituentDependency() throws Exception {
// Register a repository service containing bundle B requiring
// capability B and providing capability A.
registerRepositoryService(BUNDLE_B);
Subsystem root = getRootSubsystem();
// Install unmanaged bundle C providing capability B as a constituent
// of the root subsystem.
Bundle bundleC = installBundleFromFile(BUNDLE_C, root);
try {
// Install application A with content bundle A requiring
// capability A.
Subsystem applicationA = installSubsystemFromFile(APPLICATION_A);
// Make sure the Require-Capability exists for capability a...
assertHeaderExists(applicationA, Constants.REQUIRE_CAPABILITY);
// ...but not for capability b.
RequireCapabilityHeader header = new RequireCapabilityHeader(applicationA.getSubsystemHeaders(null).get(Constants.REQUIRE_CAPABILITY));
assertEquals("Wrong number of clauses", 1, header.getClauses().size());
Clause clause = header.getClauses().iterator().next();
assertEquals("Wrong path", "a", clause.getPath());
assertEquals("Wrong resolution directive", Constants.RESOLUTION_MANDATORY, clause.getDirective(Constants.RESOLUTION_DIRECTIVE).getValue());
assertEquals("Wrong effective directive", Constants.EFFECTIVE_RESOLVE, clause.getDirective(Constants.EFFECTIVE_DIRECTIVE).getValue());
try {
// Make sure the runtime resolution works as well.
applicationA.start();
} catch (SubsystemException e) {
fail("Application A should have started");
} finally {
stopAndUninstallSubsystemSilently(applicationA);
}
} catch (SubsystemException e) {
fail("Application A should have installed." + e.getMessage());
} finally {
uninstallSilently(bundleC);
}
}
Aggregations