use of org.apache.felix.resolver.test.util.ResourceImpl in project felix by apache.
the class ResolverTest method populateScenario18.
private ResolveContext populateScenario18() {
Map<Requirement, List<Capability>> candMap = new HashMap<Requirement, List<Capability>>();
ResourceImpl core1 = new ResourceImpl("core1");
Capability core1_pkgCap1 = addCap(core1, PackageNamespace.PACKAGE_NAMESPACE, "corepkg1");
Capability core1_pkgCap2 = addCap(core1, PackageNamespace.PACKAGE_NAMESPACE, "corepkg2", "corepkg1");
Capability core1_pkgCap3 = addCap(core1, PackageNamespace.PACKAGE_NAMESPACE, "corepkg3", "corepkg2");
ResourceImpl core2 = new ResourceImpl("core2");
Capability core2_pkgCap1 = addCap(core2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg1");
Capability core2_pkgCap2 = addCap(core2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg2", "corepkg1");
Capability core2_pkgCap3 = addCap(core2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg3", "corepkg2");
Requirement core2_pkgReq1 = addReq(core2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg1");
Requirement core2_pkgReq2 = addReq(core2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg2");
Requirement core2_pkgReq3 = addReq(core2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg3");
ResourceImpl core3 = new ResourceImpl("core3");
Capability core3_pkgCap1 = addCap(core3, PackageNamespace.PACKAGE_NAMESPACE, "corepkg1");
Capability core3_pkgCap2 = addCap(core3, PackageNamespace.PACKAGE_NAMESPACE, "corepkg2", "corepkg1");
Capability core3_pkgCap3 = addCap(core3, PackageNamespace.PACKAGE_NAMESPACE, "corepkg3", "corepkg2");
Requirement core3_pkgReq1 = addReq(core3, PackageNamespace.PACKAGE_NAMESPACE, "corepkg1");
Requirement core3_pkgReq2 = addReq(core3, PackageNamespace.PACKAGE_NAMESPACE, "corepkg2");
Requirement core3_pkgReq3 = addReq(core3, PackageNamespace.PACKAGE_NAMESPACE, "corepkg3");
ResourceImpl client1 = new ResourceImpl("client1");
Capability client1_pkgCap = addCap(client1, PackageNamespace.PACKAGE_NAMESPACE, "clientpkg1", "corepkg3");
Requirement client1_pkgReq1 = addReq(client1, PackageNamespace.PACKAGE_NAMESPACE, "corepkg3");
ResourceImpl client2 = new ResourceImpl("client2");
Capability client2_pkgCap = addCap(client2, PackageNamespace.PACKAGE_NAMESPACE, "clientpkg1", "corepkg3");
Requirement client2_pkgReq1 = addReq(client2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg3");
ResourceImpl bundle1 = new ResourceImpl("bundle1");
Requirement bundle1_pkgReq1 = addReq(bundle1, PackageNamespace.PACKAGE_NAMESPACE, "corepkg1");
Requirement bundle1_pkgReq2 = addReq(bundle1, PackageNamespace.PACKAGE_NAMESPACE, "clientpkg1");
ResourceImpl bundle2 = new ResourceImpl("bundle2");
Requirement bundle2_pkgReq1 = addReq(bundle2, PackageNamespace.PACKAGE_NAMESPACE, "corepkg1");
candMap.put(core2_pkgReq1, Arrays.asList(core3_pkgCap1, core2_pkgCap1));
candMap.put(core2_pkgReq2, Arrays.asList(core3_pkgCap2, core2_pkgCap2));
candMap.put(core2_pkgReq3, Arrays.asList(core3_pkgCap3, core2_pkgCap3));
candMap.put(core3_pkgReq1, Arrays.asList(core3_pkgCap1, core2_pkgCap1));
candMap.put(core3_pkgReq2, Arrays.asList(core3_pkgCap2, core2_pkgCap2));
candMap.put(core3_pkgReq3, Arrays.asList(core3_pkgCap3, core2_pkgCap3));
candMap.put(client1_pkgReq1, Arrays.asList(core3_pkgCap3, core2_pkgCap3, core1_pkgCap3));
candMap.put(client2_pkgReq1, Arrays.asList(core3_pkgCap3));
candMap.put(bundle1_pkgReq1, Arrays.asList(core1_pkgCap1));
candMap.put(bundle1_pkgReq2, Arrays.asList(client1_pkgCap));
candMap.put(bundle2_pkgReq1, Arrays.asList(core3_pkgCap1));
Collection<Resource> mandatory = Arrays.<Resource>asList(core1, core2, core3, client1, client2, bundle1, bundle2);
return new ResolveContextImpl(Collections.<Resource, Wiring>emptyMap(), candMap, mandatory, Collections.<Resource>emptyList());
}
use of org.apache.felix.resolver.test.util.ResourceImpl in project felix by apache.
the class ResolverTest method testScenario12.
/**
* Test dynamic resolution with an unresolvable host
*/
@Test(expected = ResolutionException.class)
public void testScenario12() throws Exception {
ResolverImpl resolver = new ResolverImpl(new Logger(Logger.LOG_DEBUG), 1);
Map<Resource, Wiring> wirings = new HashMap<Resource, Wiring>();
Map<Requirement, List<Capability>> candMap = new HashMap<Requirement, List<Capability>>();
ResourceImpl a1 = new ResourceImpl("A");
Capability a1_hostCap = addCap(a1, HostNamespace.HOST_NAMESPACE, "A");
ResourceImpl b1 = new ResourceImpl("B");
Requirement b_pkgReq1 = addReq(b1, PackageNamespace.PACKAGE_NAMESPACE, "org.foo.a");
ResourceImpl c1 = new ResourceImpl("C");
Capability c_hostCap = addCap(c1, HostNamespace.HOST_NAMESPACE, "A");
Capability c_pkgCap = addCap(c1, PackageNamespace.PACKAGE_NAMESPACE, "org.foo.a");
Requirement c_pkgReq1 = addReq(c1, PackageNamespace.PACKAGE_NAMESPACE, "org.foo.b");
candMap.put(b_pkgReq1, Collections.singletonList(c_pkgCap));
candMap.put(c_pkgReq1, Collections.<Capability>emptyList());
Map<Resource, List<Wire>> wires = new HashMap<Resource, List<Wire>>();
wires.put(a1, new ArrayList<Wire>());
wires.put(b1, new ArrayList<Wire>());
Map<Resource, List<Wire>> invertedWires = new HashMap<Resource, List<Wire>>();
invertedWires.put(a1, new ArrayList<Wire>());
invertedWires.put(b1, new ArrayList<Wire>());
wirings.put(a1, new SimpleWiring(a1, Collections.<Capability>emptyList(), wires, invertedWires));
wirings.put(b1, new SimpleWiring(b1, Collections.<Capability>emptyList(), wires, invertedWires));
ResolveContextImpl rci = new ResolveContextImpl(wirings, candMap, Collections.<Resource>emptyList(), Collections.<Resource>emptyList());
List<Capability> caps = new ArrayList<Capability>();
caps.add(c_pkgCap);
Map<Resource, List<Wire>> wireMap = resolver.resolve(rci, b1, b_pkgReq1, caps);
assertEquals(0, wireMap.size());
}
Aggregations