Search in sources :

Example 6 with GenericCapability

use of org.apache.felix.resolver.test.util.GenericCapability in project felix by apache.

the class ResolverTest method populateScenario7.

private static List<Resource> populateScenario7(Map<Resource, Wiring> wirings, Map<Requirement, List<Capability>> candMap) {
    ResourceImpl a1 = new ResourceImpl("A");
    GenericCapability a1_hostCap = new GenericCapability(a1, HostNamespace.HOST_NAMESPACE);
    a1_hostCap.addAttribute(HostNamespace.HOST_NAMESPACE, "A");
    a1.addCapability(a1_hostCap);
    ResourceImpl f1 = new ResourceImpl("F1", IdentityNamespace.TYPE_FRAGMENT, Version.emptyVersion);
    GenericRequirement f1_hostReq = new GenericRequirement(f1, HostNamespace.HOST_NAMESPACE);
    f1_hostReq.addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, "(" + HostNamespace.HOST_NAMESPACE + "=A)");
    f1.addRequirement(f1_hostReq);
    ResourceImpl f2 = new ResourceImpl("F2", IdentityNamespace.TYPE_FRAGMENT, Version.emptyVersion);
    GenericRequirement f2_hostReq = new GenericRequirement(f2, HostNamespace.HOST_NAMESPACE);
    f2_hostReq.addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, "(" + HostNamespace.HOST_NAMESPACE + "=A)");
    f2.addRequirement(f2_hostReq);
    ResourceImpl b1 = new ResourceImpl("B");
    GenericRequirement b1_identityReq = new GenericRequirement(b1, IdentityNamespace.IDENTITY_NAMESPACE);
    b1_identityReq.addDirective(Namespace.REQUIREMENT_FILTER_DIRECTIVE, "(" + IdentityNamespace.IDENTITY_NAMESPACE + "=F2)");
    b1.addRequirement(b1_identityReq);
    candMap.put(f1.getRequirements(null).get(0), a1.getCapabilities(HostNamespace.HOST_NAMESPACE));
    candMap.put(f2.getRequirements(null).get(0), a1.getCapabilities(HostNamespace.HOST_NAMESPACE));
    candMap.put(b1.getRequirements(null).get(0), f2.getCapabilities(IdentityNamespace.IDENTITY_NAMESPACE));
    List<Resource> resources = new ArrayList<Resource>();
    resources.add(a1);
    resources.add(f1);
    resources.add(f2);
    resources.add(b1);
    return resources;
}
Also used : ResourceImpl(org.apache.felix.resolver.test.util.ResourceImpl) GenericRequirement(org.apache.felix.resolver.test.util.GenericRequirement) Resource(org.osgi.resource.Resource) ArrayList(java.util.ArrayList) GenericCapability(org.apache.felix.resolver.test.util.GenericCapability)

Aggregations

GenericCapability (org.apache.felix.resolver.test.util.GenericCapability)6 ArrayList (java.util.ArrayList)4 GenericRequirement (org.apache.felix.resolver.test.util.GenericRequirement)4 ResourceImpl (org.apache.felix.resolver.test.util.ResourceImpl)4 Resource (org.osgi.resource.Resource)4 BundleCapability (org.apache.felix.resolver.test.util.BundleCapability)2 BundleRequirement (org.apache.felix.resolver.test.util.BundleRequirement)2 PackageCapability (org.apache.felix.resolver.test.util.PackageCapability)2 PackageRequirement (org.apache.felix.resolver.test.util.PackageRequirement)2 Capability (org.osgi.resource.Capability)2 Requirement (org.osgi.resource.Requirement)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ClauseParser (org.apache.felix.resolver.test.util.ClauseParser)1