maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ken...@apache.org
Subject svn commit: r547874 - in /maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact: resolver/DefaultArtifactCollectorTest.java versioning/VersionRangeTest.java
Date Sat, 16 Jun 2007 07:20:41 GMT
Author: kenney
Date: Sat Jun 16 00:20:35 2007
New Revision: 547874

URL: http://svn.apache.org/viewvc?view=rev&rev=547874
Log:
Added some tests; also add test for MNG-3001 where it's claimed that [1.0,) includes 1.0-SNAPSHOT,
which it doesn't.

Modified:
    maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
    maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java

Modified: maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java?view=diff&rev=547874&r1=547873&r2=547874
==============================================================================
--- maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
(original)
+++ maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
Sat Jun 16 00:20:35 2007
@@ -41,6 +41,7 @@
 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;
 
@@ -665,6 +666,24 @@
 
         ArtifactResolutionResult res = collect( createSet( new Object[]{a.artifact, b.artifact}
) );
         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 )

Modified: maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
URL: http://svn.apache.org/viewvc/maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java?view=diff&rev=547874&r1=547873&r2=547874
==============================================================================
--- maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
(original)
+++ maven/components/trunk/maven-artifact/src/test/java/org/apache/maven/artifact/versioning/VersionRangeTest.java
Sat Jun 16 00:20:35 2007
@@ -144,6 +144,9 @@
         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()
@@ -657,5 +660,34 @@
         {
             // 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 );
     }
 }



Mime
View raw message