Search in sources :

Example 6 with PackageRequirementMerger

use of org.apache.aries.application.modelling.internal.PackageRequirementMerger 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);
}
Also used : ArrayList(java.util.ArrayList) ImportedPackage(org.apache.aries.application.modelling.ImportedPackage) PackageRequirementMerger(org.apache.aries.application.modelling.internal.PackageRequirementMerger) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 7 with PackageRequirementMerger

use of org.apache.aries.application.modelling.internal.PackageRequirementMerger 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));
}
Also used : ArrayList(java.util.ArrayList) ImportedPackage(org.apache.aries.application.modelling.ImportedPackage) PackageRequirementMerger(org.apache.aries.application.modelling.internal.PackageRequirementMerger) Test(org.junit.Test)

Aggregations

ArrayList (java.util.ArrayList)7 ImportedPackage (org.apache.aries.application.modelling.ImportedPackage)7 PackageRequirementMerger (org.apache.aries.application.modelling.internal.PackageRequirementMerger)7 Test (org.junit.Test)6 HashSet (java.util.HashSet)2 ResolverException (org.apache.aries.application.management.ResolverException)1 ExportedPackage (org.apache.aries.application.modelling.ExportedPackage)1 ModelledResource (org.apache.aries.application.modelling.ModelledResource)1