use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_bundleSymbolicNameOK.
@Test
public void testGetImportPackage_bundleSymbolicNameOK() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.CONTENT, ternary.NONE);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.b;version=1.0.0;bundle-symbolic-name=bundle.b;bundle-version=\"[1.0.0,2.0.0)\""), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", new ArrayList<String>(), Arrays.asList("package.b;version=2.0.0")));
// Check that the bundle-symbolic-name attribute for a bundle within deployed-content is ok.
String importPackageEntry = null;
try {
importPackageEntry = deployedBundles.getImportPackage();
} catch (ResolverException e) {
e.printStackTrace();
Assert.fail(e.toString());
}
// All packages are satisfied internally
String expectedResult = "";
Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetUseBundle_Valid.
@Test
public void testGetUseBundle_Valid() throws Exception {
// Get a valid set of deployment information.
DeployedBundles deployedBundles = validDeployedBundles();
packagesResolve(deployedBundles);
// Check the deployed use bundle entry is correct.
String useBundleEntry = deployedBundles.getUseBundle();
String expectedResult = "bundle.c;deployed-version=1.0.0,bundle.d;deployed-version=1.0.0";
Assert.assertTrue("UseBundle=" + useBundleEntry, isEqual(useBundleEntry, expectedResult));
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetProvisionBundle_Valid.
@Test
public void testGetProvisionBundle_Valid() throws Exception {
// Check the provision bundle entry is correct.
DeployedBundles deployedBundles = validDeployedBundles();
packagesResolve(deployedBundles);
String provisionBundleEntry = deployedBundles.getProvisionBundle();
String expectedResult = "bundle.e;deployed-version=1.0.0";
Assert.assertTrue("ProvisionBundle=" + provisionBundleEntry, isEqual(provisionBundleEntry, expectedResult));
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeploymentGeneratorTest method checkBasicCircularDependenciesDetected.
@Test
public void checkBasicCircularDependenciesDetected() throws Exception {
// Override Resolver behaviour.
// ImportedBundle isolated = new ImportedBundleImpl ("test.isolated" , "1.0.0");
// When we resolve isolated, we're going to get another bundle which has a dependency on isolated.
Collection<ModelledResource> cmr = new ArrayList<ModelledResource>();
ExportedPackage testIsolatedPkg = createExportedPackage("test.isolated", "1.0.0", new String[] { "test.shared" }, new String[] { "test.isolated.pkg" });
cmr.add(testIsolatedPkg.getBundle());
ExportedPackage testSharedPkg = createExportedPackage("test.shared", "1.0.0", new String[] { "test.isolated.pkg" }, new String[] { "test.shared" });
cmr.add(testSharedPkg.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.isolated", "1.0.0")));
try {
DeployedBundles deployedBundles = deplMFMgr.generateDeployedBundles(appMetadata, new ArrayList<ModelledResource>(), new ArrayList<Content>());
deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
} catch (ResolverException rx) {
List<String> usr = rx.getUnsatisfiedRequirements();
assertEquals("One unsatisfied requirement expected, not " + usr.size(), usr.size(), 1);
String chkMsg = "Shared bundle test.shared_1.0.0 has a dependency for package " + "test.shared which is exported from application bundle [test.isolated_1.0.0]";
assertTrue(chkMsg + " expected, not " + usr, usr.contains(chkMsg));
return;
}
fail("ResolverException expected");
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeploymentGeneratorTest method checkBundleInAppContentAndProvisionContent.
@Test
public void checkBundleInAppContentAndProvisionContent() throws Exception {
List<ModelledResource> cmr = new ArrayList<ModelledResource>();
cmr.add(createModelledResource("test.api", "1.1.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.1.0")));
cmr.add(createModelledResource("test.api", "1.0.0", Collections.<String>emptyList(), Arrays.asList("test.api.pack;version=1.0.0")));
cmr.add(createModelledResource("test.consumer", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,2.0.0)\""), Collections.<String>emptyList()));
cmr.add(createModelledResource("test.provider", "1.0.0", Arrays.asList("test.api.pack;version=\"[1.0.0,1.1.0)\""), Collections.<String>emptyList()));
// 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.api", "1.1.0"), mockContent("test.consumer", "1.0.0"), mockContent("test.provider", "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[] { cmr.get(0), cmr.get(2), cmr.get(3) }), new ArrayList<Content>());
deplMFMgr.generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
fail("Expected exception because we can't provision an isolated bundle twice");
} catch (ResolverException rx) {
}
}
Aggregations