mirror of https://github.com/apache/maven.git
Added some tests; also add test for MNG-3001 where it's claimed that [1.0,) includes 1.0-SNAPSHOT, which it doesn't.
git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@547874 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
3efdafe6a8
commit
811de4eb41
|
@ -41,6 +41,7 @@ import org.apache.maven.artifact.resolver.filter.ExclusionSetFilter;
|
|||
import org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter;
|
||||
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
|
||||
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
|
||||
import org.apache.maven.artifact.versioning.OverConstrainedVersionException;
|
||||
import org.apache.maven.artifact.versioning.VersionRange;
|
||||
import org.codehaus.plexus.PlexusTestCase;
|
||||
|
||||
|
@ -667,6 +668,24 @@ public class DefaultArtifactCollectorTest
|
|||
assertEquals( "Check artifact list", createSet( new Object[]{a.artifact, b.artifact} ), res.getArtifacts() );
|
||||
}
|
||||
|
||||
public void testSnapshotNotIncluded()
|
||||
throws ArtifactResolutionException, InvalidVersionSpecificationException
|
||||
{
|
||||
ArtifactSpec a = createArtifact( "a", "1.0" );
|
||||
a.addDependency( "b", "[1.0,)" );
|
||||
createArtifact( "b", "1.0-SNAPSHOT" );
|
||||
|
||||
try
|
||||
{
|
||||
ArtifactResolutionResult res = collect( a );
|
||||
fail( "Expected b not to resolve: " + res );
|
||||
}
|
||||
catch ( OverConstrainedVersionException e )
|
||||
{
|
||||
assertTrue( e.getMessage().indexOf( "[1.0-SNAPSHOT]" ) < e.getMessage().indexOf( "[1.0,)" ) );
|
||||
}
|
||||
}
|
||||
|
||||
private Artifact getArtifact( String id, Set artifacts )
|
||||
{
|
||||
for ( Iterator i = artifacts.iterator(); i.hasNext(); )
|
||||
|
|
|
@ -144,6 +144,9 @@ public class VersionRangeTest
|
|||
assertNull( CHECK_VERSION_RECOMMENDATION, range.getRecommendedVersion() );
|
||||
assertFalse( CHECK_SELECTED_VERSION_KNOWN, range.isSelectedVersionKnown( artifact ) );
|
||||
assertNull( CHECK_SELECTED_VERSION, range.getSelectedVersion( artifact ) );
|
||||
|
||||
range = VersionRange.createFromVersionSpec( "[1.0,)" );
|
||||
assertFalse( range.containsVersion( new DefaultArtifactVersion( "1.0-SNAPSHOT" ) ) );
|
||||
}
|
||||
|
||||
public void testInvalidRanges()
|
||||
|
@ -658,4 +661,33 @@ public class VersionRangeTest
|
|||
// expected
|
||||
}
|
||||
}
|
||||
|
||||
public void testContains() throws InvalidVersionSpecificationException
|
||||
{
|
||||
ArtifactVersion actualVersion = new DefaultArtifactVersion( "2.0.5" );
|
||||
assertTrue( enforceVersion( "2.0.5", actualVersion ) );
|
||||
assertTrue( enforceVersion( "2.0.4", actualVersion ) );
|
||||
assertTrue( enforceVersion( "[2.0.5]", actualVersion ) );
|
||||
assertFalse( enforceVersion( "[2.0.6,)", actualVersion ) );
|
||||
assertFalse( enforceVersion( "[2.0.6]", actualVersion ) );
|
||||
assertTrue( enforceVersion( "[2.0,2.1]", actualVersion ) );
|
||||
assertFalse( enforceVersion( "[2.0,2.0.3]", actualVersion ) );
|
||||
assertTrue( enforceVersion( "[2.0,2.0.5]", actualVersion ) );
|
||||
assertFalse( enforceVersion( "[2.0,2.0.5)", actualVersion ) );
|
||||
}
|
||||
|
||||
public boolean enforceVersion( String requiredVersionRange, ArtifactVersion actualVersion )
|
||||
throws InvalidVersionSpecificationException
|
||||
{
|
||||
VersionRange vr = null;
|
||||
|
||||
vr = VersionRange.createFromVersionSpec( requiredVersionRange );
|
||||
|
||||
return vr.containsVersion( actualVersion );
|
||||
}
|
||||
|
||||
public void testOrder0()
|
||||
{
|
||||
// assertTrue( new DefaultArtifactVersion( "1.0-alpha10" ).compareTo( new DefaultArtifactVersion( "1.0-alpha1" ) ) > 0 );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue