use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeploymentGeneratorTest method checkMultipleCircularDependenciesDetected.
/**
* This method checks that the a more complicated circular dependency issues the correct error message
* and checks that the details listed in the exception are correct.
* @throws Exception
*/
@Test
public void checkMultipleCircularDependenciesDetected() throws Exception {
Collection<ModelledResource> cmr = new ArrayList<ModelledResource>();
ExportedPackage testIsolated1 = createExportedPackage("test.isolated1", "1.0.0", new String[] { "test.isolated1", "test.isolated2" }, new String[] { "test.shared1", "test.shared2" });
cmr.add(testIsolated1.getBundle());
ExportedPackage testIsolated2 = createExportedPackage("test.isolated2", "1.0.0", new String[] { "test.isolated1", "test.isolated2" }, new String[] { "test.shared1", "test.shared2" });
cmr.add(testIsolated2.getBundle());
ExportedPackage testShared1 = createExportedPackage("test.shared1", "1.0.0", new String[] { "test.shared1", "test.shared2" }, new String[] { "test.isolated1", "test.isolated2" });
cmr.add(testShared1.getBundle());
ExportedPackage testShared2 = createExportedPackage("test.shared2", "1.0.0", new String[] { "test.shared1", "test.shared2" }, new String[] { "test.isolated1", "test.isolated2" });
cmr.add(testShared2.getBundle());
_resolver.addResult(cmr);
// The second time DeploymentGenerator calls the Resolver, it will provide just
// test.shared. The resolver will return test.shared _plus_ test.isolated.
_resolver.addResult(cmr);
Skeleton.getSkeleton(appMetadata).setReturnValue(new MethodCall(ApplicationMetadata.class, "getApplicationContents"), Arrays.asList(mockContent("test.isolated1", "1.0.0"), mockContent("test.isolated2", "1.0.0")));
app = Skeleton.newMock(AriesApplication.class);
Skeleton.getSkeleton(app).setReturnValue(new MethodCall(AriesApplication.class, "getApplicationMetadata"), appMetadata);
try {
DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles(appMetadata, Arrays.asList(new ModelledResource[] { testIsolated1.getBundle(), testIsolated2.getBundle() }), new ArrayList<Content>());
deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
} catch (ResolverException rx) {
// Get the unsatisfied Requirements
List<String> unsatisfiedReqs = rx.getUnsatisfiedRequirements();
// Ensure we've got 4 unsatisfied Requirements
assertEquals("4 unsatisfied requirements expected, but got " + Arrays.toString(unsatisfiedReqs.toArray()), 4, unsatisfiedReqs.size());
List<String> checkMessages = new ArrayList<String>();
// Now load an array with the expected messages.
checkMessages.add("Shared bundle test.shared1_1.0.0 has a dependency for package test.isolated1 which " + "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
checkMessages.add("Shared bundle test.shared1_1.0.0 has a dependency for package test.isolated2 which " + "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
checkMessages.add("Shared bundle test.shared2_1.0.0 has a dependency for package test.isolated1 which " + "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
checkMessages.add("Shared bundle test.shared2_1.0.0 has a dependency for package test.isolated2 which " + "is exported from application bundles [test.isolated1_1.0.0, test.isolated2_1.0.0]");
// because some unsatisfied reqs have spaces at the end of the string.
for (String unsatisfiedReq : unsatisfiedReqs) {
assertTrue(unsatisfiedReq + " is not an expected msg", checkMessages.contains(unsatisfiedReq.trim()));
}
}
}
Aggregations