use of org.apache.aries.subsystem.core.capabilityset.CapabilitySet in project aries by apache.
the class Aries1453Test method shouldResolveFragmentHostWithVersionRangeAndMatchWithBundlesInThatRange.
@Test
public void shouldResolveFragmentHostWithVersionRangeAndMatchWithBundlesInThatRange() {
FragmentHostHeader header = new FragmentHostHeader("host-bundle;bundle-version=\"[9.6.0,10)\"");
FragmentHostRequirement requirement = new FragmentHostRequirement(header.getClauses().iterator().next(), null);
FragmentHostCapability capability = new FragmentHostCapability(new BundleSymbolicNameHeader("host-bundle"), new BundleVersionHeader("9.6.1"), new Resource() {
@Override
public List<Capability> getCapabilities(String namespace) {
return null;
}
@Override
public List<Requirement> getRequirements(String namespace) {
return null;
}
});
String filterDirective = requirement.getDirectives().get(Namespace.REQUIREMENT_FILTER_DIRECTIVE);
SimpleFilter simpleFilter = SimpleFilter.parse(filterDirective);
CapabilitySet capabilitySet = new CapabilitySet(Arrays.asList(HostNamespace.HOST_NAMESPACE), true);
capabilitySet.addCapability(capability);
Set<Capability> capabilities = capabilitySet.match(simpleFilter, true);
Assert.assertTrue(capabilities.size() == 1);
Assert.assertSame(capabilities.iterator().next(), capability);
}
Aggregations