use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeploymentManifestManagerImpl method generateDeploymentManifest.
/**
* Perform provisioning to work out the 'freeze dried list' of the eba
* @param app - Aries application
* @param ResolveConstraint - resolver constraint for limiting the resolving results
* @return manifest the generated deployment manifest
* @throws ResolverException
*/
@Override
public Manifest generateDeploymentManifest(AriesApplication app, ResolveConstraint... constraints) throws ResolverException {
_logger.debug(LOG_ENTRY, "generateDeploymentManifest", new Object[] { app, constraints });
ApplicationMetadata appMetadata = app.getApplicationMetadata();
Collection<ModelledResource> byValueBundles = null;
try {
// find out blueprint information
byValueBundles = getByValueBundles(app);
// find out by value bundles and then by reference bundles
} catch (Exception e) {
throw new ResolverException(e);
}
Collection<Content> bundlesToResolve = new ArrayList<Content>();
bundlesToResolve.addAll(appMetadata.getApplicationContents());
bundlesToResolve.addAll(app.getApplicationMetadata().getUseBundles());
// If we pass in provision bundles (e.g. import deployment manifest sanity check), we add them into our bundlesToResolve set.
// This is because we want to make sure all bundles we passed into resolver the same as what we are going to get from resolver.
List<Content> restrictedReqs = new ArrayList<Content>();
for (ResolveConstraint constraint : constraints) {
Content content = ContentFactory.parseContent(constraint.getBundleName(), constraint.getVersionRange().toString());
restrictedReqs.add(content);
}
DeployedBundles deployedBundles = generateDeployedBundles(appMetadata, byValueBundles, restrictedReqs);
Manifest man = generateDeploymentManifest(appMetadata.getApplicationSymbolicName(), appMetadata.getApplicationVersion().toString(), deployedBundles);
_logger.debug(LOG_EXIT, "generateDeploymentManifest", new Object[] { man });
return man;
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_rfc138PreventsBundleSymbolicNameWorking.
@Test
public void testGetImportPackage_rfc138PreventsBundleSymbolicNameWorking() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.USES, ternary.NONE);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.b;version=1.0.0;bundle-symbolic-name=bundle.b"), 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 outside use-bundle causes an exception.
String importPackageEntry = null;
try {
importPackageEntry = deployedBundles.getImportPackage();
Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
} catch (ResolverException e) {
// We expect to reach this point if the test passes.
}
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetRequiredUseBundle_RedundantEntry.
@Test
public void testGetRequiredUseBundle_RedundantEntry() throws Exception {
// Bundle A requires package B from bundle B with no version requirement.
// Bundle B requires package C from bundle C with no version requirement.
// Bundle C requires package B from bundle B with explicit version requirement.
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.USES, ternary.USES);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.b"), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", Arrays.asList("package.c"), Arrays.asList("package.b;version=1.0.0")));
deployedBundles.addBundle(createModelledResource("bundle.c", "1.0.0", Arrays.asList("package.b;version=1.0.0"), Arrays.asList("package.c;version=1.0.0")));
// Check the redundant use-bundle entry is identified.
// Bundle C is not required by app content, although it is specified in use-bundle.
Collection<ModelledResource> requiredUseBundle = null;
try {
requiredUseBundle = deployedBundles.getRequiredUseBundle();
} catch (ResolverException e) {
e.printStackTrace();
Assert.fail(e.toString());
}
Assert.assertTrue("RequiredUseBundle=" + requiredUseBundle, requiredUseBundle.size() == 1);
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_InvalidBundleVersion.
// Inside cannot bundle-symbolic-name an outside bundle until the new RFC 138!
@Test
public void testGetImportPackage_InvalidBundleVersion() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.USES, ternary.NONE);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.b;version=\"[1.0.0,1.0.0]\";bundle-symbolic-name=bundle.b;bundle-version=\"[0.0.0,1.0.0)\""), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", new ArrayList<String>(), Arrays.asList("package.b;version=1.0.0")));
// Check that the bundle version requirement generates an error because it doesn't match the a bundle in use-bundle.
String importPackageEntry = null;
try {
importPackageEntry = deployedBundles.getImportPackage();
Assert.fail("Expected exception. ImportPackage=" + importPackageEntry);
} catch (ResolverException e) {
// We expect to reach this point if the test passes.
}
}
use of org.apache.aries.application.modelling.DeployedBundles in project aries by apache.
the class DeployedBundlesTest method testGetImportPackage_ValidDuplicatesWithAttributes.
@Test
public void testGetImportPackage_ValidDuplicatesWithAttributes() throws Exception {
DeployedBundles deployedBundles = getSimpleDeployedBundles(ternary.CONTENT, ternary.CONTENT, ternary.NONE);
deployedBundles.addBundle(createModelledResource("bundle.a", "1.0.0", Arrays.asList("package.c;version=1.0.0;was_internal=true"), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.b", "1.0.0", Arrays.asList("package.c;version=2.0.0;was_internal=true"), new ArrayList<String>()));
deployedBundles.addBundle(createModelledResource("bundle.c", "1.0.0", new ArrayList<String>(), Arrays.asList("package.c;version=2.0.0;was_internal=true")));
// Check that package C is not duplicated in Import-Package, and that the version range
// has been narrowed to the intersection of the original requirements.
String importPackageEntry = null;
try {
importPackageEntry = deployedBundles.getImportPackage();
} catch (ResolverException e) {
e.printStackTrace();
Assert.fail(e.toString());
}
String expectedResult = "package.c;was_internal=\"true\";version=\"2.0.0\"";
Assert.assertTrue("ImportPackage=" + importPackageEntry, isEqual(importPackageEntry, expectedResult));
}
Aggregations