From 19d2d9492beea5b2492e44bf9390bbef63e47831 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Mon, 9 Feb 2009 16:44:09 +0000 Subject: [PATCH] [MNG-2720] Clean up the integration test for MNG-2720, so it uses one of the standard IT plugins (*-plugin-dependencies, to be specific). git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@742607 13f79535-47bb-0310-9956-ffa450edef68 --- ...Tmng2720SiblingClasspathArtifactsTest.java | 44 ++++++---- .../{project-hierarchy => }/child1/pom.xml | 0 .../org/apache/maven/debug/mng2720/App.java | 0 .../apache/maven/debug/mng2720/AppTest.java | 0 .../{project-hierarchy => }/child2/pom.xml | 0 .../org/apache/maven/debug/mng2720/App.java | 0 .../apache/maven/debug/mng2720/AppTest.java | 0 .../{project-hierarchy => }/child3/pom.xml | 0 .../org/apache/maven/debug/mng2720/App.java | 0 .../apache/maven/debug/mng2720/AppTest.java | 0 .../test/resources/mng-2720/plugin/pom.xml | 21 ----- .../maven/debug/mng2720/ClasspathMojo.java | 88 ------------------- .../mng-2720/{project-hierarchy => }/pom.xml | 15 ++-- 13 files changed, 38 insertions(+), 130 deletions(-) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child1/pom.xml (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child1/src/main/java/org/apache/maven/debug/mng2720/App.java (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child1/src/test/java/org/apache/maven/debug/mng2720/AppTest.java (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child2/pom.xml (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child2/src/main/java/org/apache/maven/debug/mng2720/App.java (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child2/src/test/java/org/apache/maven/debug/mng2720/AppTest.java (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child3/pom.xml (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child3/src/main/java/org/apache/maven/debug/mng2720/App.java (100%) rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/child3/src/test/java/org/apache/maven/debug/mng2720/AppTest.java (100%) delete mode 100644 its/core-it-suite/src/test/resources/mng-2720/plugin/pom.xml delete mode 100644 its/core-it-suite/src/test/resources/mng-2720/plugin/src/main/java/org/apache/maven/debug/mng2720/ClasspathMojo.java rename its/core-it-suite/src/test/resources/mng-2720/{project-hierarchy => }/pom.xml (63%) diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java index bb39003c61..83c2792d44 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng2720SiblingClasspathArtifactsTest.java @@ -19,15 +19,13 @@ package org.apache.maven.it; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException; -import org.apache.maven.it.AbstractMavenIntegrationTestCase; -import org.apache.maven.it.Verifier; import org.apache.maven.it.util.ResourceExtractor; +import java.io.File; +import java.util.Iterator; +import java.util.List; + /** * This is a test set for MNG-2720. * @@ -54,18 +52,34 @@ public class MavenITmng2720SiblingClasspathArtifactsTest throws Exception { File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-2720" ); - File pluginDir = new File( testDir, "plugin" ); - File projectDir = new File( testDir, "project-hierarchy" ); - // First, install the plugin used for the test. - Verifier verifier = new Verifier( pluginDir.getAbsolutePath() ); - verifier.executeGoal( "install" ); + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + + verifier.executeGoal( "package" ); verifier.verifyErrorFreeLog(); verifier.resetStreams(); - // Now, build the project hierarchy that uses the plugin to verify sibling dependencies. - verifier = new Verifier( projectDir.getAbsolutePath() ); - verifier.executeGoal( "package" ); - verifier.verifyErrorFreeLog(); + List compileClassPath = verifier.loadLines( "child2/target/compile.classpath", "UTF-8" ); + assertTrue( find( "child1-1.jar", compileClassPath ) ); + + compileClassPath = verifier.loadLines( "child3/target/compile.classpath", "UTF-8" ); + assertFalse( find( "child1-1.jar", compileClassPath ) ); + assertTrue( find( "child1-1-tests.jar", compileClassPath ) ); + + } + + private boolean find( String pathSubstr, List classPath ) + { + for ( Iterator it = classPath.iterator(); it.hasNext(); ) + { + String path = (String) it.next(); + + if ( path.indexOf( pathSubstr ) > -1 ) + { + return true; + } + } + + return false; } } diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child1/pom.xml b/its/core-it-suite/src/test/resources/mng-2720/child1/pom.xml similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child1/pom.xml rename to its/core-it-suite/src/test/resources/mng-2720/child1/pom.xml diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child1/src/main/java/org/apache/maven/debug/mng2720/App.java b/its/core-it-suite/src/test/resources/mng-2720/child1/src/main/java/org/apache/maven/debug/mng2720/App.java similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child1/src/main/java/org/apache/maven/debug/mng2720/App.java rename to its/core-it-suite/src/test/resources/mng-2720/child1/src/main/java/org/apache/maven/debug/mng2720/App.java diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child1/src/test/java/org/apache/maven/debug/mng2720/AppTest.java b/its/core-it-suite/src/test/resources/mng-2720/child1/src/test/java/org/apache/maven/debug/mng2720/AppTest.java similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child1/src/test/java/org/apache/maven/debug/mng2720/AppTest.java rename to its/core-it-suite/src/test/resources/mng-2720/child1/src/test/java/org/apache/maven/debug/mng2720/AppTest.java diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child2/pom.xml b/its/core-it-suite/src/test/resources/mng-2720/child2/pom.xml similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child2/pom.xml rename to its/core-it-suite/src/test/resources/mng-2720/child2/pom.xml diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child2/src/main/java/org/apache/maven/debug/mng2720/App.java b/its/core-it-suite/src/test/resources/mng-2720/child2/src/main/java/org/apache/maven/debug/mng2720/App.java similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child2/src/main/java/org/apache/maven/debug/mng2720/App.java rename to its/core-it-suite/src/test/resources/mng-2720/child2/src/main/java/org/apache/maven/debug/mng2720/App.java diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child2/src/test/java/org/apache/maven/debug/mng2720/AppTest.java b/its/core-it-suite/src/test/resources/mng-2720/child2/src/test/java/org/apache/maven/debug/mng2720/AppTest.java similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child2/src/test/java/org/apache/maven/debug/mng2720/AppTest.java rename to its/core-it-suite/src/test/resources/mng-2720/child2/src/test/java/org/apache/maven/debug/mng2720/AppTest.java diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child3/pom.xml b/its/core-it-suite/src/test/resources/mng-2720/child3/pom.xml similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child3/pom.xml rename to its/core-it-suite/src/test/resources/mng-2720/child3/pom.xml diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child3/src/main/java/org/apache/maven/debug/mng2720/App.java b/its/core-it-suite/src/test/resources/mng-2720/child3/src/main/java/org/apache/maven/debug/mng2720/App.java similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child3/src/main/java/org/apache/maven/debug/mng2720/App.java rename to its/core-it-suite/src/test/resources/mng-2720/child3/src/main/java/org/apache/maven/debug/mng2720/App.java diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child3/src/test/java/org/apache/maven/debug/mng2720/AppTest.java b/its/core-it-suite/src/test/resources/mng-2720/child3/src/test/java/org/apache/maven/debug/mng2720/AppTest.java similarity index 100% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/child3/src/test/java/org/apache/maven/debug/mng2720/AppTest.java rename to its/core-it-suite/src/test/resources/mng-2720/child3/src/test/java/org/apache/maven/debug/mng2720/AppTest.java diff --git a/its/core-it-suite/src/test/resources/mng-2720/plugin/pom.xml b/its/core-it-suite/src/test/resources/mng-2720/plugin/pom.xml deleted file mode 100644 index f907098121..0000000000 --- a/its/core-it-suite/src/test/resources/mng-2720/plugin/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - 4.0.0 - org.apache.maven.its.mng2720 - maven-mng2720-plugin - maven-plugin - 1 - - - - org.apache.maven - maven-plugin-api - 2.0.9 - - - org.apache.maven - maven-project - 2.0.9 - - - diff --git a/its/core-it-suite/src/test/resources/mng-2720/plugin/src/main/java/org/apache/maven/debug/mng2720/ClasspathMojo.java b/its/core-it-suite/src/test/resources/mng-2720/plugin/src/main/java/org/apache/maven/debug/mng2720/ClasspathMojo.java deleted file mode 100644 index 5227d45c23..0000000000 --- a/its/core-it-suite/src/test/resources/mng-2720/plugin/src/main/java/org/apache/maven/debug/mng2720/ClasspathMojo.java +++ /dev/null @@ -1,88 +0,0 @@ -package org.apache.maven.debug.mng2720; - -import org.apache.maven.artifact.DependencyResolutionRequiredException; -import org.apache.maven.plugin.Mojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugin.logging.Log; -import org.apache.maven.project.MavenProject; - -import java.util.Iterator; -import java.util.List; - -/** - * @goal test - * @requiresDependencyResolution compile - * @phase package - */ -public class ClasspathMojo - implements Mojo -{ - - /** - * @parameter default-value="${project}" - * @readonly - */ - private MavenProject project; - - /** - * @parameter default-value="${project.compileClasspathElements}" - * @readonly - */ - private List compileClasspathElements; - - private Log log; - - public void execute() throws MojoExecutionException, MojoFailureException - { - if ( "child2".equals( project.getArtifactId() ) ) - { - boolean found = false; - for ( Iterator it = compileClasspathElements.iterator(); it.hasNext(); ) - { - String path = (String) it.next(); - if ( path.indexOf( "child1-1.jar" ) > -1 ) - { - found = true; - break; - } - } - - if ( !found ) - { - throw new MojoExecutionException( "child1-1.jar dependency artifact path not found in compile classpath for project: " + project.getId() ); - } - } - else if ( "child3".equals( project.getArtifactId() ) ) - { - boolean found = false; - for ( Iterator it = compileClasspathElements.iterator(); it.hasNext(); ) - { - String path = (String) it.next(); - if ( path.indexOf( "child1-1-tests.jar" ) > -1 ) - { - found = true; - break; - } - } - - if ( !found ) - { - throw new MojoExecutionException( "child1-1-tests.jar dependency artifact path not found in compile classpath for project: " + project.getId() ); - } - } - - log.info( "Tests succeeded." ); - } - - public Log getLog() - { - return log; - } - - public void setLog( Log log ) - { - this.log = log; - } - -} diff --git a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/pom.xml b/its/core-it-suite/src/test/resources/mng-2720/pom.xml similarity index 63% rename from its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/pom.xml rename to its/core-it-suite/src/test/resources/mng-2720/pom.xml index 8cbbcd39c1..f307081e87 100644 --- a/its/core-it-suite/src/test/resources/mng-2720/project-hierarchy/pom.xml +++ b/its/core-it-suite/src/test/resources/mng-2720/pom.xml @@ -5,7 +5,7 @@ project-hierarchy pom 1 - MNG-2720 Project Hierarchy 1 + MNG-2720 Project Hierarchy child1 @@ -16,16 +16,19 @@ - org.apache.maven.its.mng2720 - maven-mng2720-plugin - 1 + org.apache.maven.its.plugins + maven-it-plugin-dependency-resolution + 2.1-SNAPSHOT - test + compile-classpath package - test + compile + + ${project.build.directory}/compile.classpath +