use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class ImportedPackageTest method testEqualsForIdenticalPackages.
@Test
public void testEqualsForIdenticalPackages() throws InvalidAttributeException {
String packageName = "package.name";
String version = "1.0.0";
ImportedPackage package1 = instantiatePackage(packageName, version);
// I should hope so!
assertEquals(package1, package1);
}
use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class ImportedPackageTest method testEqualsForEqualPackagesWithVersionRange.
@Test
public void testEqualsForEqualPackagesWithVersionRange() throws InvalidAttributeException {
String packageName = "package.name";
String version = "[1.0.0, 1.6.3)";
ImportedPackage package1 = instantiatePackage(packageName, version);
ImportedPackage package2 = instantiatePackage(packageName, version);
assertEquals(package1, package2);
}
use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class PackageRequirementMergerTest method testMergeMandatoryResolution.
@Test
public void testMergeMandatoryResolution() throws Exception {
Collection<ImportedPackage> reqs = new ArrayList<ImportedPackage>();
reqs.add(newImportedPackage("a", "1.0.0", true));
reqs.add(newImportedPackage("a", "2.0.0", false));
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"));
Assert.assertTrue(result.toString(), isEqual(result, expected));
}
use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class PackageRequirementMergerTest method testMergeInvalidAdditionalAttributes.
@Test
public void testMergeInvalidAdditionalAttributes() throws Exception {
Collection<ImportedPackage> reqs = new ArrayList<ImportedPackage>();
reqs.add(newImportedPackage("a", "1.0.0", "foo=bar"));
reqs.add(newImportedPackage("a", "2.0.0", "foo=blah"));
reqs.add(newImportedPackage("b", "1.0.0"));
PackageRequirementMerger merger = new PackageRequirementMerger(reqs);
Assert.assertFalse(merger.isMergeSuccessful());
try {
merger.getMergedRequirements();
Assert.fail("getMergedRequirements should throw IllegalStateException.");
} catch (IllegalStateException e) {
}
Set<String> result = merger.getInvalidRequirements();
Set<String> expected = new HashSet<String>();
expected.add("a");
Assert.assertEquals(expected, result);
}
use of org.apache.aries.application.modelling.ImportedPackage in project aries by apache.
the class PackageRequirementMergerTest method isEqual.
private static boolean isEqual(Collection<ImportedPackage> reqs1, Collection<ImportedPackage> reqs2) {
boolean result = true;
if (reqs1.size() != reqs2.size()) {
result = false;
} else {
for (ImportedPackage r1 : reqs1) {
boolean foundMatch = false;
for (ImportedPackage r2 : reqs2) {
if (!r1.getPackageName().equals(r2.getPackageName())) {
continue;
}
if (r1.isOptional() != r2.isOptional()) {
continue;
}
Map<String, String> attribs1 = new HashMap<String, String>(r1.getAttributes());
Map<String, String> attribs2 = new HashMap<String, String>(r2.getAttributes());
VersionRange v1 = ManifestHeaderProcessor.parseVersionRange(attribs1.remove(Constants.VERSION_ATTRIBUTE));
VersionRange v2 = ManifestHeaderProcessor.parseVersionRange(attribs2.remove(Constants.VERSION_ATTRIBUTE));
if (!v1.equals(v2)) {
continue;
}
if (!attribs1.equals(attribs2)) {
continue;
}
foundMatch = true;
break;
}
if (!foundMatch) {
result = false;
break;
}
}
}
return result;
}
Aggregations