mirror of https://github.com/apache/maven.git
PR: MNG-505
test multiple ranges on each side git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219808 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
11082da5f4
commit
407c29c3e0
|
@ -219,7 +219,7 @@ public class VersionRange
|
|||
|
||||
private List intersection( List r1, List r2 )
|
||||
{
|
||||
List restrictions = new ArrayList( Math.min( r1.size(), r2.size() ) );
|
||||
List restrictions = new ArrayList( r1.size() + r2.size() );
|
||||
Iterator i1 = r1.iterator();
|
||||
Iterator i2 = r2.iterator();
|
||||
Restriction res1 = (Restriction) i1.next();
|
||||
|
|
|
@ -411,7 +411,179 @@ public class VersionRangeTest
|
|||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
|
||||
|
||||
// TODO: multiple on one side, multiple on both sides, boundaries
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.1]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.1", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.4]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 1, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.4", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 1 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
|
||||
assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 1 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
|
||||
assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 1 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2),(1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
|
||||
assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 1 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
|
||||
assertFalse( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertFalse( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "(,1.1),(1.4,)" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "(,1.1],[1.4,)" );
|
||||
range2 = VersionRange.createFromVersionSpec( "(1.1,1.4)" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[,1.1],[1.4,]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.2,1.3]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 0, restrictions.size() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.6,]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 2, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 1 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.5]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 1 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 2 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.5", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
|
||||
range1 = VersionRange.createFromVersionSpec( "[1.0,1.2],[1.3,1.7]" );
|
||||
range2 = VersionRange.createFromVersionSpec( "[1.1,1.4],[1.5,1.6]" );
|
||||
mergedRange = range1.restrict( range2 );
|
||||
assertNull( CHECK_VERSION_RECOMMENDATION, mergedRange.getRecommendedVersion() );
|
||||
restrictions = mergedRange.getRestrictions();
|
||||
assertEquals( CHECK_NUM_RESTRICTIONS, 3, restrictions.size() );
|
||||
restriction = (Restriction) restrictions.get( 0 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.1", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.2", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 1 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.3", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.4", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
restriction = (Restriction) restrictions.get( 2 );
|
||||
assertEquals( CHECK_LOWER_BOUND, "1.5", restriction.getLowerBound().toString() );
|
||||
assertTrue( CHECK_LOWER_BOUND_INCLUSIVE, restriction.isLowerBoundInclusive() );
|
||||
assertEquals( CHECK_UPPER_BOUND, "1.6", restriction.getUpperBound().toString() );
|
||||
assertTrue( CHECK_UPPER_BOUND_INCLUSIVE, restriction.isUpperBoundInclusive() );
|
||||
}
|
||||
|
||||
private void checkInvalidRange( String version )
|
||||
|
|
Loading…
Reference in New Issue