Return-Path: Delivered-To: apmail-maven-commits-archive@www.apache.org Received: (qmail 14048 invoked from network); 6 Mar 2008 01:03:03 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 6 Mar 2008 01:03:03 -0000 Received: (qmail 1558 invoked by uid 500); 6 Mar 2008 01:02:58 -0000 Delivered-To: apmail-maven-commits-archive@maven.apache.org Received: (qmail 1515 invoked by uid 500); 6 Mar 2008 01:02:58 -0000 Mailing-List: contact commits-help@maven.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@maven.apache.org Delivered-To: mailing list commits@maven.apache.org Received: (qmail 1501 invoked by uid 99); 6 Mar 2008 01:02:58 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 05 Mar 2008 17:02:58 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO eris.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 06 Mar 2008 01:02:18 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 25F161A9832; Wed, 5 Mar 2008 17:02:38 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@maven.apache.org From: brianf@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080306010238.25F161A9832@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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