DefaultResourceBuilder builderE = new DefaultResourceBuilder();
Capability icapE = builderE.addIdentityCapability(RESOURCE_E, Version.emptyVersion);
icapE.getAttributes().put(ContentNamespace.CAPABILITY_RUNTIME_NAME_ATTRIBUTE, RESOURCE_E + ".war");
builderE.addContentCapability(deployer.getDeployment(RESOURCE_E));
builderE.addIdentityRequirement("org.apache.camel.core", new VersionRange("[2.11,3.0)"));
Resource res = builderE.getResource();
// Add that resource to the repository
Resource resB = provisioner.getRepository().addResource(res);
Assert.assertEquals(RESOURCE_E + ":0.0.0", resB.getIdentity().toString());
try {
// Provision that resource
Requirement req = new IdentityRequirementBuilder(resB.getIdentity()).getRequirement();
Set<ResourceHandle> result = provisioner.provisionResources(Collections.singleton(req));
List<ResourceHandle> handles = new ArrayList<ResourceHandle>(result);
try {
// Make a call to the HttpService endpoint that goes through a Camel route
String reqspec = "/service?test=Kermit";
String context = RuntimeType.getRuntimeType() == RuntimeType.KARAF ? "" : "/" + RESOURCE_E;
Assert.assertEquals("Hello Kermit", performCall(context, reqspec));
// Verify module available
Runtime runtime = RuntimeLocator.getRequiredRuntime();
ResourceIdentity residA = ResourceIdentity.create("org.apache.camel.core", "2.11.0");
Assert.assertNotNull("Module available", runtime.getModule(residA));
ResourceIdentity residB = ResourceIdentity.create(RESOURCE_E, Version.emptyVersion);
Assert.assertNotNull("Module available", runtime.getModule(residB));
// Verify the wiring
Environment environment = provisioner.getEnvironment();
Map<Resource, Wiring> wirings = environment.getWirings();
Resource resA = environment.getResource(residA);
Assert.assertNotNull("Resource in environment", resA);
Wiring wiringA = wirings.get(resA);
Assert.assertNotNull("Wiring in environment", wiringA);
Assert.assertEquals("Two required wires", 2, wiringA.getRequiredResourceWires(null).size());
Assert.assertEquals("One provided wires", 1, wiringA.getProvidedResourceWires(null).size());