use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class PackageRequirementMergerTest method testMergeOptionalResolution.
@Test
public void testMergeOptionalResolution() throws Exception {
Collection<ImportedPackage> reqs = new ArrayList<ImportedPackage>();
reqs.add(newImportedPackage("a", "1.0.0", true));
reqs.add(newImportedPackage("a", "2.0.0", true));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
Assert.assertTrue(merger.isMergeSuccessful());
Assert.assertTrue(merger.getInvalidRequirements().isEmpty());
Collection<ImportedPackage> result = merger.getMergedRequirements();
Collection<ImportedPackage> expected = new ArrayList<ImportedPackage>();
expected.add(newImportedPackage("a", "2.0.0", true));
Assert.assertTrue(result.toString(), isEqual(result, expected));
}
use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class DeployedBundlesImpl method getImportPackage.
/**
* Get the value corresponding to the Import-Package header in the deployment.mf.
* @return a manifest entry, or an empty string if there is no content.
* @throws ResolverException if the requirements could not be resolved.
*/
public String getImportPackage() throws ResolverException {
logger.debug(LOG_ENTRY, "getImportPackage");
String result = cachedImportPackage;
if (result == null) {
Collection<ImportedPackage> externalReqs = new ArrayList<ImportedPackage>(getExternalPackageRequirements());
//Validate that we don't have attributes that will break until RFC138 is used
validateOtherImports(externalReqs);
// Find the matching capabilities from bundles in use bundle, and prune
// matched requirements out of the external requirements collection.
Map<ImportedPackage, ExportedPackage> useBundlePkgs = new HashMap<ImportedPackage, ExportedPackage>();
for (Iterator<ImportedPackage> iter = externalReqs.iterator(); iter.hasNext(); ) {
ImportedPackage req = iter.next();
ExportedPackage match = getPackageMatch(req, deployedUseBundle);
if (match != null) {
useBundlePkgs.put(req, match);
iter.remove();
}
}
StringBuilder useBundleImports = new StringBuilder();
for (Map.Entry<ImportedPackage, ExportedPackage> entry : useBundlePkgs.entrySet()) {
useBundleImports.append(entry.getValue().toDeploymentString());
ImportedPackage key = entry.getKey();
if (key.isOptional())
useBundleImports.append(";" + Constants.RESOLUTION_DIRECTIVE + ":=" + Constants.RESOLUTION_OPTIONAL);
useBundleImports.append(",");
}
result = useBundleImports.toString() + createManifestString(externalReqs);
if (result.endsWith(","))
result = result.substring(0, result.length() - 1);
cachedImportPackage = result;
}
logger.debug(LOG_EXIT, "getImportPackage", result);
return result;
}
use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class ImportedPackageTest method testEqualsForEqualTrivialPackages.
@Test
public void testEqualsForEqualTrivialPackages() throws InvalidAttributeException {
String packageName = "package.name";
String version = "1.0.0";
ImportedPackage package1 = instantiatePackage(packageName, version);
ImportedPackage package2 = instantiatePackage(packageName, version);
assertEquals(package1, package2);
}
Aggregations