maven-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject svn commit: r634097 - in /maven/components/branches/maven-2.0.x/maven-artifact/src: main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
Date Thu, 06 Mar 2008 01:02:37 GMT
Author: brianf
Date: Wed Mar  5 17:02:28 2008
New Revision: 634097

URL: http://svn.apache.org/viewvc?rev=634097&view=rev
Log:
MNG-2123: new form of the unit test that expressed the issue seen in the IT

Modified:
    maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
    maven/components/branches/maven-2.0.x/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java

Modified: maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java?rev=634097&r1=634096&r2=634097&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
(original)
+++ maven/components/branches/maven-2.0.x/maven-artifact/src/main/java/org/apache/maven/artifact/resolver/DefaultArtifactCollector.java
Wed Mar  5 17:02:28 2008
@@ -196,10 +196,10 @@
                             //MNG-2123: if the previous node was not a range, then it wouldn't
have any available
                             //versions. We just clobbered the selected version above. (why?
i have no idea.)
                             //So since we are here and this is ranges we must go figure out
the version (for a third time...)
-                            if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange()
!= null)
+                            if ( resetArtifact.getVersion() == null && resetArtifact.getVersionRange()
!= null )
                             {
 
-                                //go find the version. This is a total hack. See previous
comment.
+                                // go find the version. This is a total hack. See previous
comment.
                                 List versions = resetArtifact.getAvailableVersions();
                                 if ( versions == null )
                                 {
@@ -219,8 +219,9 @@
                                                                                remoteRepositories,
e );
                                     }
                                 }
+                                //end hack
                                 resetArtifact.selectVersion( resetArtifact.getVersionRange().matchVersion(
-                                    resetArtifact.getAvailableVersions() ).toString() );
+                                                                                        
                  resetArtifact.getAvailableVersions() ).toString() );
                                 fireEvent( ResolutionListener.SELECT_VERSION_FROM_RANGE,
listeners, resetNodes[j] );
                             }
                         }

Modified: maven/components/branches/maven-2.0.x/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
URL: http://svn.apache.org/viewvc/maven/components/branches/maven-2.0.x/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java?rev=634097&r1=634096&r2=634097&view=diff
==============================================================================
--- maven/components/branches/maven-2.0.x/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
(original)
+++ maven/components/branches/maven-2.0.x/maven-artifact/src/test/java/org/apache/maven/artifact/resolver/DefaultArtifactCollectorTest.java
Wed Mar  5 17:02:28 2008
@@ -368,30 +368,56 @@
     }
     
     public void testInCompatibleRecommendedVersion()
-    throws ArtifactResolutionException, InvalidVersionSpecificationException
-{
-    
-    //this test puts two dependencies on C with 3.2 and [1.0,3.0] as the version.
-    //it puts 2.5 and 3.0 in the pretend repo...we should get back 3.0
-    ArtifactSpec a = createArtifactSpec( "a", "1.0" );
-    ArtifactSpec b = a.addDependency( "b", "1.0" );
-    ArtifactSpec b1 = a.addDependency( "b1", "1.0" );
-    b.addDependency( "c", "3.2" );
-    b1.addDependency( "c", "[1.0,3.0]" );
-  
-    //put it in the repo
-    ArtifactSpec c = createArtifactSpec( "c", "3.0" );
-    source.addArtifact( createArtifactSpec( "c", "2.5" ));
-    source.addArtifact( createArtifactSpec( "c", "3.0" ));
-    source.addArtifact( createArtifactSpec( "c", "3.2" ));
-
-    
-    ArtifactResolutionResult res = collect( a );
-
-    assertEquals( "Check artifact list", createSet( new Object[] { a.artifact, b.artifact,b1.artifact,c.artifact
} ),
-                  res.getArtifacts() );
-    assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion()
);
-}
+        throws ArtifactResolutionException, InvalidVersionSpecificationException
+    {
+
+        // this test puts two dependencies on C with 3.2 and [1.0,3.0] as the version.
+        // it puts 2.5 and 3.0 in the pretend repo...we should get back 3.0
+        ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+        ArtifactSpec b = a.addDependency( "b", "1.0" );
+        ArtifactSpec b1 = a.addDependency( "b1", "1.0" );
+        b.addDependency( "c", "3.2" );
+        b1.addDependency( "c", "[1.0,3.0]" );
+
+        // put it in the repo
+        ArtifactSpec c = createArtifactSpec( "c", "3.0" );
+        source.addArtifact( createArtifactSpec( "c", "2.5" ) );
+        source.addArtifact( createArtifactSpec( "c", "3.0" ) );
+        source.addArtifact( createArtifactSpec( "c", "3.2" ) );
+
+        ArtifactResolutionResult res = collect( a );
+
+        assertEquals( "Check artifact list",
+                      createSet( new Object[] { a.artifact, b.artifact, b1.artifact, c.artifact
} ), res.getArtifacts() );
+        assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion()
);
+    }
+
+    //MNG-2123: this version of the test caused the crash seen in the IT. It was
+    //only happening if the first dependency was not a range but the second one was.
+    public void testInCompatibleRecommendedVersion2()
+        throws ArtifactResolutionException, InvalidVersionSpecificationException
+    {
+
+        // this test puts two dependencies on C with 3.2 and [1.0,3.0] as the version.
+        // it puts 2.5 and 3.0 in the pretend repo...we should get back 3.0
+        ArtifactSpec a = createArtifactSpec( "a", "1.0" );
+        ArtifactSpec b = a.addDependency( "b", "1.0" );
+        ArtifactSpec b1 = a.addDependency( "b1", "1.0" );
+        b1.addDependency( "c", "3.2" );
+        b.addDependency( "c", "[1.0,3.0]" );
+
+        // put it in the repo
+        ArtifactSpec c = createArtifactSpec( "c", "3.0" );
+        source.addArtifact( createArtifactSpec( "c", "2.5" ) );
+        source.addArtifact( createArtifactSpec( "c", "3.0" ) );
+        source.addArtifact( createArtifactSpec( "c", "3.2" ) );
+
+        ArtifactResolutionResult res = collect( a );
+
+        assertEquals( "Check artifact list",
+                      createSet( new Object[] { a.artifact, b.artifact, b1.artifact, c.artifact
} ), res.getArtifacts() );
+        assertEquals( "Check version", "3.0", getArtifact( "c", res.getArtifacts() ).getVersion()
);
+    }
     
     public void testIncompatibleRanges()
         throws ArtifactResolutionException, InvalidVersionSpecificationException



Mime
View raw message