From f6bc314e2eefd82954743afb875ac07f1b7d756a Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Sun, 28 Mar 2010 19:50:16 +0000 Subject: [PATCH] [MNG-4005] Throw Validation Error if pom contains a dependency with two different versions o Relaxed to warning for now to ease migration git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@928486 13f79535-47bb-0310-9956-ffa450edef68 --- ...MavenITmng4005UniqueDependencyKeyTest.java | 32 ++++++++++--------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4005UniqueDependencyKeyTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4005UniqueDependencyKeyTest.java index a7641bdb78..667c69718d 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4005UniqueDependencyKeyTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4005UniqueDependencyKeyTest.java @@ -23,8 +23,7 @@ import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; import java.io.File; -import java.util.ArrayList; -import java.util.Collections; +import java.util.Iterator; import java.util.List; /** @@ -38,7 +37,7 @@ public class MavenITmng4005UniqueDependencyKeyTest public MavenITmng4005UniqueDependencyKeyTest() { - super( "[3.0-alpha-3,)" ); + super( "[3.0-alpha-8,)" ); } /** @@ -85,20 +84,23 @@ public class MavenITmng4005UniqueDependencyKeyTest Verifier verifier = new Verifier( testDir.getAbsolutePath() ); verifier.setAutoclean( false ); verifier.deleteDirectory( "target" ); - try + verifier.executeGoal( "validate" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + + List lines = verifier.loadLines( verifier.getLogFileName(), "UTF-8" ); + boolean foundWarning = false; + for ( Iterator it = lines.iterator(); it.hasNext(); ) { - verifier.executeGoal( "validate" ); - verifier.verifyErrorFreeLog(); - fail( "Duplicate dependency did not cause validation error" ); - } - catch ( VerificationException e ) - { - // expected - } - finally - { - verifier.resetStreams(); + String line = (String) it.next(); + + if ( line.startsWith( "[WARNING]" ) && line.indexOf( "must be unique: junit:junit:jar" ) > 0 ) + { + foundWarning = true; + } } + + assertTrue( "Duplicate dependency warning wasn't generated.", foundWarning ); } }