Author: jdcasey Date: Mon Mar 3 11:44:53 2008 New Revision: 633246 URL: http://svn.apache.org/viewvc?rev=633246&view=rev Log: [MNG-3428] Adding an integration test to guard against this happening in future.
Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3428PluginDescriptorArtifactsIncompleteTest.java (with props) maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/pom.xml (with props) maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/readme.txt (with props) maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/MyMojo.java (with props) Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java Modified: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java?rev=633246&r1=633245&r2=633246&view=diff ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java (original) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/IntegrationTestSuite.java Mon Mar 3 11:44:53 2008 @@ -177,6 +177,7 @@ suite.addTestSuite( MavenITmng1493NonStandardModulePomNames.class ); suite.addTestSuite( MavenITmng1491ReactorArtifactIdCollision.class ); suite.addTestSuite( MavenITmng3426PluginsClasspathOverrideTest.class ); + suite.addTestSuite( MavenITmng3428PluginDescriptorArtifactsIncompleteTest.class ); // ---------------------------------------------------------------------------------------------------- // Tests that need to be fixed. Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3428PluginDescriptorArtifactsIncompleteTest.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3428PluginDescriptorArtifactsIncompleteTest.java?rev=633246&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3428PluginDescriptorArtifactsIncompleteTest.java (added) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3428PluginDescriptorArtifactsIncompleteTest.java Mon Mar 3 11:44:53 2008 @@ -0,0 +1,50 @@ +package org.apache.maven.integrationtests; + +import org.apache.maven.it.Verifier; +import org.apache.maven.it.util.ResourceExtractor; + +import java.io.File; + +/** + * Tests that the PluginDescriptor.getArtifacts() call returns all of the dependencies of the plugin, + * not just those that made it past the filter excluding Maven's core artifacts. + */ +public class MavenITmng3428PluginDescriptorArtifactsIncompleteTest + extends AbstractMavenIntegrationTestCase +{ + public void test () + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-3428-pluginDescriptorArtifactsIncomplete" ); + + Verifier verifier = new Verifier( testDir.getAbsolutePath() ); + + // First, build the plugin we'll use to test the PluginDescriptor artifact collection. + verifier.executeGoal( "install" ); + + /* + * This is the simplest way to check a build + * succeeded. It is also the simplest way to create + * an IT test: make the build pass when the test + * should pass, and make the build fail when the + * test should fail. There are other methods + * supported by the verifier. They can be seen here: + * http://maven.apache.org/shared/maven-verifier/apidocs/index.html + */ + verifier.verifyErrorFreeLog(); + + /* + * Reset the streams before executing the verifier + * again. + */ + verifier.resetStreams(); + + // This should only succeed if commons-cli is part of ${plugin.artifacts}. The + // commons-cli library is part of Maven's core classpath, so if this mojo succeeds + // it means the PluginDescriptor.getArtifacts() call returns an unfiltered collection. + verifier.setAutoclean( false ); + verifier.executeGoal( "tests:test-cli-maven-plugin:1:test" ); + verifier.verifyErrorFreeLog(); + verifier.resetStreams(); + } +} Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3428PluginDescriptorArtifactsIncompleteTest.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/java/org/apache/maven/integrationtests/MavenITmng3428PluginDescriptorArtifactsIncompleteTest.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/pom.xml URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/pom.xml?rev=633246&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/pom.xml (added) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/pom.xml Mon Mar 3 11:44:53 2008 @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="UTF-8"?><project> + <modelVersion>4.0.0</modelVersion> + <groupId>tests</groupId> + <artifactId>test-cli-maven-plugin</artifactId> + <packaging>maven-plugin</packaging> + <name>test-cli-maven-plugin Maven Mojo</name> + <version>1</version> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>2.0</version> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-artifact</artifactId> + <version>2.0.8</version> + </dependency> + <dependency> + <groupId>commons-cli</groupId> + <artifactId>commons-cli</artifactId> + <version>1.0</version> + <scope>runtime</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-descriptor</artifactId> + <version>2.0.8</version> + </dependency> + </dependencies> +</project> \ No newline at end of file Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/pom.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/pom.xml ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/readme.txt URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/readme.txt?rev=633246&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/readme.txt (added) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/readme.txt Mon Mar 3 11:44:53 2008 @@ -0,0 +1,8 @@ +This is a plugin that uses the ${plugin.artifacts} expression to extract its own collection of dependency artifacts. It will then cycle through this collection looking for commons-cli, which is also part of Maven's core classpath. If the plugin-artifact collection is unfiltered, this artifact should be present. Otherwise, the plugin will throw a MojoExecutionException when it's run. + +So, this test entails first installing this plugin, then executing it; two executions in total, and it'll look like this: + +mvn install +mvn tests:test-cli-maven-plugin:1:test + +(It should succeed on the first one at all times, and only succeed on the second one if the plugin-artifact collection has NOT had commons-cli filtered out.) \ No newline at end of file Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/readme.txt ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/readme.txt ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision" Added: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/MyMojo.java URL: http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/MyMojo.java?rev=633246&view=auto ============================================================================== --- maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/MyMojo.java (added) +++ maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/MyMojo.java Mon Mar 3 11:44:53 2008 @@ -0,0 +1,66 @@ +package tests; + +/* + * Copyright 2001-2005 The Apache Software Foundation. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +import java.util.Iterator; +import java.util.List; + +/** + * @goal test + * @requiresProject false + */ +public class MyMojo + extends AbstractMojo +{ + + /** + * @parameter default-value="${plugin.artifacts}" + */ + private List pluginArtifacts; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + System.out.println( "\n\n\n\n\n\n\n" ); + + boolean foundCommonsCli = false; + for ( Iterator it = pluginArtifacts.iterator(); it.hasNext(); ) + { + Artifact artifact = (Artifact) it.next(); + + if ( "commons-cli".equals( artifact.getArtifactId() ) ) + { + foundCommonsCli = true; + } + + System.out.println( artifact.getArtifactId() ); + } + + System.out.println( "\n\n\n\n\n\n\n" ); + + if ( !foundCommonsCli ) + { + throw new MojoExecutionException( "Commons-cli dependency not found." ); + } + } + +} Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/MyMojo.java ------------------------------------------------------------------------------ svn:eol-style = native Propchange: maven/core-integration-testing/trunk/core-integration-tests/src/test/resources/mng-3428-pluginDescriptorArtifactsIncomplete/src/main/java/tests/MyMojo.java ------------------------------------------------------------------------------ svn:keywords = "Author Date Id Revision"