diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java index 95568cf490..5ce0e454c5 100644 --- a/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/IntegrationTestSuite.java @@ -92,6 +92,7 @@ public class IntegrationTestSuite // 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 ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java new file mode 100644 index 0000000000..34c918ca71 --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng4091BadPluginDescriptorTest.java @@ -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 ); + } +} + diff --git a/its/core-it-suite/src/test/resources/bootstrap/pom.xml b/its/core-it-suite/src/test/resources/bootstrap/pom.xml index cfab3cb276..499d2cac84 100644 --- a/its/core-it-suite/src/test/resources/bootstrap/pom.xml +++ b/its/core-it-suite/src/test/resources/bootstrap/pom.xml @@ -109,6 +109,12 @@ under the License. ${itPluginVersion} runtime + + org.apache.maven.its.plugins + maven-it-plugin-invalid-descriptor + ${itPluginVersion} + runtime + org.apache.maven.its.plugins maven-it-plugin-log-file diff --git a/its/core-it-suite/src/test/resources/mng-4091/pom.xml b/its/core-it-suite/src/test/resources/mng-4091/pom.xml new file mode 100644 index 0000000000..727e886748 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-4091/pom.xml @@ -0,0 +1,50 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng4091 + plugin-descriptor-test + 1 + pom + + MNG-4091 - Profile activation warning test + + + + + org.apache.maven.its.plugins + maven-it-plugin-invalid-descriptor + 2.1-SNAPSHOT + + + test + validate + + test + + + + + + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml new file mode 100644 index 0000000000..6b990b8114 --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/pom.xml @@ -0,0 +1,60 @@ + + + + + + 4.0.0 + + + maven-it-plugins + org.apache.maven.its.plugins + 2.1-SNAPSHOT + + + maven-it-plugin-invalid-descriptor + maven-plugin + + Maven Integration Test Plugin :: Invalid Descriptor + + + + org.apache.maven + maven-plugin-api + 2.0 + + + junit + junit + 3.8.1 + test + + + + + + + src/main/resources + + true + + + + + diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java new file mode 100644 index 0000000000..82e88ffda1 --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/java/org/apache/maven/plugin/coreit/CoreItMojo.java @@ -0,0 +1,39 @@ +package org.apache.maven.plugin.coreit; + +/* + * 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 org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; + +/** + * @goal test + * + * @phase process-sources + */ +public class CoreItMojo + extends AbstractMojo +{ + public void execute() + throws MojoExecutionException + { + throw new MojoExecutionException( "Should not be run" ); + } + +} diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml new file mode 100644 index 0000000000..666ab3dc56 --- /dev/null +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-invalid-descriptor/src/main/resources/META-INF/maven/plugin.xml @@ -0,0 +1,36 @@ + + + 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. + org.apache.maven.its.plugins + maven-it-plugin-invalid-descriptor + 2.0-SNAPSHOT + itinvalid-descriptor + false + true + + + test + + false + true + false + false + false + true + process-sources + org.apache.maven.plugin.coreit.CoreItMojo + java + per-lookup + once-per-session + + + + + + org.apache.maven + maven-plugin-api + jar + 2.0 + + + diff --git a/its/core-it-support/core-it-plugins/pom.xml b/its/core-it-support/core-it-plugins/pom.xml index 31cd1fbec3..a32548666f 100644 --- a/its/core-it-support/core-it-plugins/pom.xml +++ b/its/core-it-support/core-it-plugins/pom.xml @@ -42,6 +42,7 @@ under the License. maven-it-plugin-expression maven-it-plugin-error maven-it-plugin-fork + maven-it-plugin-invalid-descriptor maven-it-plugin-log-file maven-it-plugin-no-project maven-it-plugin-packaging @@ -92,4 +93,4 @@ under the License. - \ No newline at end of file +