Search in sources :

Example 1 with CapabilitySet

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);
}
Also used : Capability(org.osgi.resource.Capability) Resource(org.osgi.resource.Resource) SimpleFilter(org.apache.aries.subsystem.core.capabilityset.SimpleFilter) CapabilitySet(org.apache.aries.subsystem.core.capabilityset.CapabilitySet) List(java.util.List) Test(org.junit.Test)

Aggregations

List (java.util.List)1 CapabilitySet (org.apache.aries.subsystem.core.capabilityset.CapabilitySet)1 SimpleFilter (org.apache.aries.subsystem.core.capabilityset.SimpleFilter)1 Test (org.junit.Test)1 Capability (org.osgi.resource.Capability)1 Resource (org.osgi.resource.Resource)1