From 8937fd353d5bd2fe630fca9d4397ee708da24794 Mon Sep 17 00:00:00 2001 From: John Dennis Casey Date: Mon, 10 Apr 2006 19:32:35 +0000 Subject: [PATCH] Merging 393029 from branch, to fix the case where -DperformRelease=true injects additional plugins into the test POMs. git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@393031 13f79535-47bb-0310-9956-ffa450edef68 --- .../t02/ProjectInheritanceTest.java | 56 ++++++++++++++++++- 1 file changed, 53 insertions(+), 3 deletions(-) diff --git a/maven-project/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java b/maven-project/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java index aa1dcf0ec4..f7a61839d0 100644 --- a/maven-project/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java +++ b/maven-project/src/test/java/org/apache/maven/project/inheritance/t02/ProjectInheritanceTest.java @@ -17,7 +17,11 @@ package org.apache.maven.project.inheritance.t02; */ import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.Iterator; import java.util.List; +import java.util.Map; import org.apache.maven.model.Build; import org.apache.maven.model.MailingList; @@ -58,6 +62,9 @@ public class ProjectInheritanceTest throws Exception { File localRepo = getLocalRepositoryPath(); + + System.out.println( "Local repository is at: " + localRepo.getAbsolutePath() ); + File pom0 = new File( localRepo, "p0/pom.xml" ); File pom1 = new File( pom0.getParentFile(), "p1/pom.xml" ); File pom2 = new File( pom1.getParentFile(), "p2/pom.xml" ); @@ -110,10 +117,53 @@ public class ProjectInheritanceTest Build build = project4.getBuild(); List plugins = build.getPlugins(); - assertEquals( 1, plugins.size() ); + Map validPluginCounts = new HashMap(); - Plugin plugin = (Plugin) plugins.get( 0 ); - List executions = plugin.getExecutions(); + String testPluginArtifactId = "maven-compiler-plugin"; + + // this is the plugin we're looking for. + validPluginCounts.put( testPluginArtifactId, Integer.valueOf( 0 ) ); + + // these are injected if -DperformRelease=true + validPluginCounts.put( "maven-deploy-plugin", Integer.valueOf( 0 ) ); + validPluginCounts.put( "maven-javadoc-plugin", Integer.valueOf( 0 ) ); + validPluginCounts.put( "maven-source-plugin", Integer.valueOf( 0 ) ); + + Plugin testPlugin = null; + + for ( Iterator it = plugins.iterator(); it.hasNext(); ) + { + Plugin plugin = (Plugin) it.next(); + + String pluginArtifactId = plugin.getArtifactId(); + + if ( !validPluginCounts.containsKey( pluginArtifactId ) ) + { + fail( "Illegal plugin found: " + pluginArtifactId ); + } + else + { + if ( pluginArtifactId.equals( testPluginArtifactId ) ) + { + testPlugin = plugin; + } + + Integer count = (Integer) validPluginCounts.get( pluginArtifactId ); + + if ( count.intValue() > 0 ) + { + fail( "Multiple copies of plugin: " + pluginArtifactId + " found in POM." ); + } + else + { + count = Integer.valueOf( count.intValue() + 1 ); + + validPluginCounts.put( pluginArtifactId, count ); + } + } + } + + List executions = testPlugin.getExecutions(); assertEquals( 1, executions.size() ); }