mirror of https://github.com/apache/maven.git
PR: MNG-505
test for correct ordering and overlap git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@219631 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
27cdfc3cd1
commit
d7d6c11a4b
|
@ -54,6 +54,8 @@ public class VersionRange
|
|||
List restrictions = new ArrayList();
|
||||
String process = spec;
|
||||
ArtifactVersion version = null;
|
||||
ArtifactVersion upperBound = null;
|
||||
ArtifactVersion lowerBound = null;
|
||||
|
||||
while ( process.startsWith( "[" ) || process.startsWith( "(" ) )
|
||||
{
|
||||
|
@ -74,7 +76,20 @@ public class VersionRange
|
|||
throw new InvalidVersionSpecificationException( "Unbounded range: " + spec );
|
||||
}
|
||||
|
||||
restrictions.add( parseRestriction( process.substring( 0, index + 1 ) ) );
|
||||
Restriction restriction = parseRestriction( process.substring( 0, index + 1 ) );
|
||||
if ( lowerBound == null )
|
||||
{
|
||||
lowerBound = restriction.getLowerBound();
|
||||
}
|
||||
if ( upperBound != null )
|
||||
{
|
||||
if ( restriction.getLowerBound() == null || restriction.getLowerBound().compareTo( upperBound ) < 0 )
|
||||
{
|
||||
throw new InvalidVersionSpecificationException( "Ranges overlap: " + spec );
|
||||
}
|
||||
}
|
||||
restrictions.add( restriction );
|
||||
upperBound = restriction.getUpperBound();
|
||||
|
||||
process = process.substring( index + 1 ).trim();
|
||||
|
||||
|
@ -143,6 +158,11 @@ public class VersionRange
|
|||
upperVersion = new DefaultArtifactVersion( upperBound );
|
||||
}
|
||||
|
||||
if ( upperVersion != null && lowerVersion != null && upperVersion.compareTo( lowerVersion ) < 0 )
|
||||
{
|
||||
throw new InvalidVersionSpecificationException( "Range defies version ordering: " + spec );
|
||||
}
|
||||
|
||||
restriction = new Restriction( lowerVersion, lowerBoundInclusive, upperVersion, upperBoundInclusive );
|
||||
}
|
||||
|
||||
|
|
|
@ -124,15 +124,14 @@ public class VersionRangeTest
|
|||
checkInvalidRange( "(1.0,1.0]" );
|
||||
checkInvalidRange( "[1.0,1.0)" );
|
||||
checkInvalidRange( "(1.0,1.0)" );
|
||||
checkInvalidRange( "[1.1,1.0]" );
|
||||
checkInvalidRange( "[1.0,1.2),1.3" );
|
||||
/* TODO: not testing this presently
|
||||
// overlap
|
||||
checkInvalidRange( "[1.0,1.2),(1.1,1.3]" );
|
||||
// overlap
|
||||
checkInvalidRange( "[1.1,1.3),(1.0,1.2]" );
|
||||
// ordering
|
||||
checkInvalidRange( "(1.1,1.2],[1.0,1.1)" );
|
||||
*/
|
||||
}
|
||||
|
||||
public void testIntersections()
|
||||
|
|
Loading…
Reference in New Issue