Author: brett
Date: Tue Mar 17 02:28:08 2009
New Revision: 755085
URL: http://svn.apache.org/viewvc?rev=755085&view=rev
Log:
[MNG-4091] add test for bad plugin descriptor handling
Added:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java
(with props)
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4091/
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4091/pom.xml
(with props)
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/
(props changed)
- copied from r753077,
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-touch/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml
(with props)
Modified:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
Modified:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java?rev=755085&r1=755084&r2=755085&view=diff
==============================================================================
---
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
(original)
+++
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java
Tue Mar 17 02:28:08 2009
@@ -92,6 +92,7 @@
// suite.addTestSuite( MavenIT0109ReleaseUpdateTest.class );
// suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); --
MNG-3137
+ suite.addTestSuite( MavenITmng4091BadPluginDescriptorTest.class );
suite.addTestSuite( MavenITmng4087PercentEncodedFileUrlTest.class );
suite.addTestSuite( MavenITmng4086ExplicitPluginMetaversionTest.class
);
suite.addTestSuite( MavenITmng4072InactiveProfileReposTest.class );
Added:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java?rev=755085&view=auto
==============================================================================
---
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java
(added)
+++
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java
Tue Mar 17 02:28:08 2009
@@ -0,0 +1,82 @@
+package org.apache.maven.it;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you 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 java.io.File;
+import java.util.Iterator;
+import java.util.List;
+
+import org.apache.maven.it.util.ResourceExtractor;
+
+/**
+ * MNG-4091 - Bad plugin descriptor error handling
+ */
+public class MavenITmng4091BadPluginDescriptorTest
+ extends AbstractMavenIntegrationTestCase
+{
+
+ public MavenITmng4091BadPluginDescriptorTest()
+ {
+ super( "[2.1.0,)" ); // only test in 2.1.0+
+ }
+
+ public void testitMNG4091()
+ throws Exception
+ {
+ File testDir = ResourceExtractor.simpleExtractResources( getClass(),
"/mng-4091" );
+
+ Verifier verifier = new Verifier( testDir.getAbsolutePath() );
+ verifier.setAutoclean( false );
+
+ try
+ {
+ verifier.executeGoal( "validate" );
+
+ fail( "should throw an error during execution." );
+ }
+ catch ( VerificationException e )
+ {
+ // expected...it'd be nice if we could get the specifics of the
exception right here...
+ }
+ finally
+ {
+ verifier.resetStreams();
+ }
+
+
+ List logFile = verifier.loadFile( verifier.getBasedir(),
verifier.getLogFileName(), false );
+
+ String msg = "Plugin's descriptor contains the wrong version:
2.0-SNAPSHOT";
+
+ boolean foundMessage = false;
+ for ( Iterator it = logFile.iterator(); it.hasNext(); )
+ {
+ String line = (String) it.next();
+ if ( line.indexOf( msg ) > -1 )
+ {
+ foundMessage = true;
+ break;
+ }
+ }
+
+ assertTrue( "User-friendly message was not found in output.",
foundMessage );
+ }
+}
+
Propchange:
maven/core-integration-testing/trunk/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml?rev=755085&r1=755084&r2=755085&view=diff
==============================================================================
---
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml
(original)
+++
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/bootstrap/pom.xml
Tue Mar 17 02:28:08 2009
@@ -111,6 +111,12 @@
</dependency>
<dependency>
<groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-invalid-descriptor</artifactId>
+ <version>${itPluginVersion}</version>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.maven.its.plugins</groupId>
<artifactId>maven-it-plugin-log-file</artifactId>
<version>${itPluginVersion}</version>
<scope>runtime</scope>
Added:
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4091/pom.xml
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4091/pom.xml?rev=755085&view=auto
==============================================================================
---
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4091/pom.xml
(added)
+++
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4091/pom.xml
Tue Mar 17 02:28:08 2009
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements. See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership. The ASF licenses this file
+to you 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.
+-->
+
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.its.mng4091</groupId>
+ <artifactId>plugin-descriptor-test</artifactId>
+ <version>1</version>
+ <packaging>pom</packaging>
+
+ <name>MNG-4091 - Profile activation warning test</name>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-invalid-descriptor</artifactId>
+ <version>2.1-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <id>test</id>
+ <phase>validate</phase>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange:
maven/core-integration-testing/trunk/core-it-suite/src/test/resources/mng-4091/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Mar 17 02:28:08 2009
@@ -0,0 +1,7 @@
+target
+*.iml
+.classpath
+.project
+.settings
+target-eclipse
+bin
Propchange:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/
------------------------------------------------------------------------------
svn:mergeinfo =
Modified:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml?rev=755085&r1=753077&r2=755085&view=diff
==============================================================================
---
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml
(original)
+++
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml
Tue Mar 17 02:28:08 2009
@@ -28,11 +28,10 @@
<version>2.1-SNAPSHOT</version>
</parent>
- <artifactId>maven-it-plugin-touch</artifactId>
+ <artifactId>maven-it-plugin-invalid-descriptor</artifactId>
<packaging>maven-plugin</packaging>
- <name>Maven Integration Test Plugin :: Touch</name>
- <inceptionYear>2001</inceptionYear>
+ <name>Maven Integration Test Plugin :: Invalid Descriptor</name>
<dependencies>
<dependency>
@@ -41,19 +40,21 @@
<version>2.0</version>
</dependency>
<dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-project</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-artifact</artifactId>
- <version>2.0</version>
- </dependency>
- <dependency>
- <groupId>org.apache.maven</groupId>
- <artifactId>maven-archiver</artifactId>
- <version>2.0</version>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ <scope>test</scope>
</dependency>
</dependencies>
+
+ <build>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <!-- forces overwrite of generated one -->
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ </build>
</project>
+
Modified:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java?rev=755085&r1=753077&r2=755085&view=diff
==============================================================================
---
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
(original)
+++
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java
Tue Mar 17 02:28:08 2009
@@ -19,138 +19,21 @@
* 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.project.MavenProject;
-
-import java.io.File;
-import java.io.FileWriter;
-import java.io.IOException;
-import java.util.Map;
/**
- * @goal touch
+ * @goal test
*
* @phase process-sources
- *
- * @description Goal which cleans the build
*/
public class CoreItMojo
extends AbstractMojo
{
- /**
- * @parameter expression="${project}"
- */
- private MavenProject project;
-
- /**
- * @parameter expression="${project.build.directory}"
- * @required
- */
- private String outputDirectory;
-
- /** Test setting of plugin-artifacts on the PluginDescriptor instance.
- * @parameter expression="${plugin.artifactMap}"
- * @required
- */
- private Map pluginArtifacts;
-
- /**
- * @parameter expression="target/test-basedir-alignment"
- */
- private File basedirAlignmentDirectory;
-
- /**
- * @parameter alias="pluginFile"
- */
- private String pluginItem = "foo";
-
- /**
- * @parameter
- */
- private String goalItem = "bar";
-
- /**
- * @parameter expression="${artifactToFile}"
- */
- private String artifactToFile;
-
- /**
- * @parameter expression="${fail}"
- */
- private boolean fail = false;
-
public void execute()
throws MojoExecutionException
{
- if ( fail )
- {
- throw new MojoExecutionException( "Failing per \'fail\' parameter
(specified in pom or system properties)" );
- }
-
- touch( new File( outputDirectory ), "touch.txt" );
-
- // This parameter should be aligned to the basedir as the parameter
type is specified
- // as java.io.File
-
- if ( !basedirAlignmentDirectory.isAbsolute() )
- {
- throw new MojoExecutionException( "basedirAlignmentDirectory not
aligned" );
- }
-
- touch( basedirAlignmentDirectory, "touch.txt" );
-
- File outDir = new File( outputDirectory );
-
- // Test parameter setting
- if ( pluginItem != null )
- {
- touch( outDir, pluginItem );
- }
-
- if ( goalItem != null )
- {
- touch( outDir, goalItem );
- }
-
- if ( artifactToFile != null )
- {
- Artifact artifact = (Artifact) pluginArtifacts.get( artifactToFile
);
-
- File artifactFile = artifact.getFile();
-
- String filename = artifactFile.getAbsolutePath().replace('/',
'_').replace(':', '_') + ".txt";
-
- touch( outDir, filename );
- }
-
- project.getBuild().setFinalName( "coreitified" );
+ throw new MojoExecutionException( "Should not be run" );
}
- private void touch( File dir, String file )
- throws MojoExecutionException
- {
- try
- {
- if ( !dir.exists() )
- {
- dir.mkdirs();
- }
-
- File touch = new File( dir, file );
-
- getLog().info( "Touching file: " + touch.getAbsolutePath() );
-
- FileWriter w = new FileWriter( touch );
-
- w.write( file );
-
- w.close();
- }
- catch ( IOException e )
- {
- throw new MojoExecutionException( "Error touching file", e );
- }
- }
}
Added:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml?rev=755085&view=auto
==============================================================================
---
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml
(added)
+++
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml
Tue Mar 17 02:28:08 2009
@@ -0,0 +1,36 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<plugin>
+ <description>Maven is a software project management and comprehension tool.
Based on the concept of a project object model (POM), Maven can manage a
project's build, reporting and documentation from a central piece of
information.</description>
+ <groupId>org.apache.maven.its.plugins</groupId>
+ <artifactId>maven-it-plugin-invalid-descriptor</artifactId>
+ <version>2.0-SNAPSHOT</version>
+ <goalPrefix>itinvalid-descriptor</goalPrefix>
+ <isolatedRealm>false</isolatedRealm>
+ <inheritedByDefault>true</inheritedByDefault>
+ <mojos>
+ <mojo>
+ <goal>test</goal>
+ <description></description>
+ <requiresDirectInvocation>false</requiresDirectInvocation>
+ <requiresProject>true</requiresProject>
+ <requiresReports>false</requiresReports>
+ <aggregator>false</aggregator>
+ <requiresOnline>false</requiresOnline>
+ <inheritedByDefault>true</inheritedByDefault>
+ <phase>process-sources</phase>
+
<implementation>org.apache.maven.plugin.coreit.CoreItMojo</implementation>
+ <language>java</language>
+ <instantiationStrategy>per-lookup</instantiationStrategy>
+ <executionStrategy>once-per-session</executionStrategy>
+ <parameters/>
+ </mojo>
+ </mojos>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.maven</groupId>
+ <artifactId>maven-plugin-api</artifactId>
+ <type>jar</type>
+ <version>2.0</version>
+ </dependency>
+ </dependencies>
+</plugin>
Propchange:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml
------------------------------------------------------------------------------
svn:eol-style = native
Modified:
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
URL:
http://svn.apache.org/viewvc/maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml?rev=755085&r1=755084&r2=755085&view=diff
==============================================================================
---
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
(original)
+++
maven/core-integration-testing/trunk/core-it-support/core-it-plugins/pom.xml
Tue Mar 17 02:28:08 2009
@@ -42,6 +42,7 @@
<module>maven-it-plugin-expression</module>
<module>maven-it-plugin-error</module>
<module>maven-it-plugin-fork</module>
+ <module>maven-it-plugin-invalid-descriptor</module>
<module>maven-it-plugin-log-file</module>
<module>maven-it-plugin-no-project</module>
<module>maven-it-plugin-packaging</module>
@@ -92,4 +93,4 @@
</plugins>
</pluginManagement>
</build>
-</project>
\ No newline at end of file
+</project>