MNG-5640: Enhance IT coverage Changes: - test case for build failure due to UT failure - test case for build failure due to missing dep - test case for build error (mojo throwing MojoExecutionEx) - test case for build error (mojo throwing RuntimeEx) - checking all participant method invocations, not only afterSessionEnd
Signed-off-by: Jason van Zyl <ja...@tesla.io> Project: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/repo Commit: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/commit/33a43e61 Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/33a43e61 Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/33a43e61 Branch: refs/heads/master Commit: 33a43e61bcbc5e0d96d6e82ecfd1ce946bd8e400 Parents: 3483c6e Author: Tamas Cservenak <ta...@cservenak.net> Authored: Tue Jun 3 10:16:29 2014 +0200 Committer: Jason van Zyl <ja...@tesla.io> Committed: Tue Jun 10 07:21:25 2014 -0400 ---------------------------------------------------------------------- ...5640LifecycleParticipantAfterSessionEnd.java | 149 ++++++++++++++++++- .../badplugin/pom.xml | 72 +++++++++ .../BadMojo.java | 38 +++++ .../BadMojoRt.java | 38 +++++ .../basic/pom.xml | 48 ------ .../apache/maven/its/mng5640/FailingTest.java | 18 --- .../builderror-rt/pom.xml | 63 ++++++++ .../builderror/pom.xml | 63 ++++++++ .../buildfailure-depmissing/pom.xml | 54 +++++++ .../apache/maven/its/mng5640/FailingTest.java | 18 +++ .../buildfailure/pom.xml | 48 ++++++ .../apache/maven/its/mng5640/FailingTest.java | 18 +++ .../LifecycleParticipantImpl.java | 21 ++- 13 files changed, 574 insertions(+), 74 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5640LifecycleParticipantAfterSessionEnd.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5640LifecycleParticipantAfterSessionEnd.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5640LifecycleParticipantAfterSessionEnd.java index d0151cd..fdbd2a7 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5640LifecycleParticipantAfterSessionEnd.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5640LifecycleParticipantAfterSessionEnd.java @@ -35,13 +35,16 @@ public class MavenITmng5640LifecycleParticipantAfterSessionEnd super( "[3.2.2,)" ); } - public void test() + /** + * IT executing a Maven build that has UT failure. Asserts that afterSessionEnd is still executed. + */ + public void testBuildFailure() throws Exception { File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" ); File extensionDir = new File( testDir, "extension" ); - File projectDir = new File( testDir, "basic" ); + File projectDir = new File( testDir, "buildfailure" ); Verifier verifier; @@ -53,14 +56,148 @@ public class MavenITmng5640LifecycleParticipantAfterSessionEnd // build the test project verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); - try { - verifier.executeGoal("package"); - } catch (VerificationException e) { + try + { + verifier.executeGoal( "package" ); + fail( "The build should fail" ); + } + catch (VerificationException e) + { // expected, as the build will fail due to always failing UT } verifier.resetStreams(); verifier.verifyTextInLog("testApp(org.apache.maven.its.mng5640.FailingTest)"); + verifier.assertFilePresent( "target/afterProjectsRead.txt" ); + // See http://jira.codehaus.org/browse/MNG-5641 + // verifier.assertFilePresent( "target/afterSessionStart.txt" ); + verifier.assertFilePresent( "target/afterSessionEnd.txt" ); + } + + /** + * IT executing a Maven build that has missing dependency. Asserts that afterSessionEnd is still executed. + */ + public void testBuildFailureMissingDependency() + throws Exception + { + File testDir = + ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" ); + File extensionDir = new File( testDir, "extension" ); + File projectDir = new File( testDir, "buildfailure-depmissing" ); + + Verifier verifier; + + // install the test plugin + verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + try + { + verifier.executeGoal( "package" ); + fail( "The build should fail" ); + } + catch (VerificationException e) + { + // expected, as the build will fail due to always failing UT + } + verifier.resetStreams(); + + verifier.assertFilePresent( "target/afterProjectsRead.txt" ); + // See http://jira.codehaus.org/browse/MNG-5641 + // verifier.assertFilePresent( "target/afterSessionStart.txt" ); + verifier.assertFilePresent( "target/afterSessionEnd.txt" ); + } + + /** + * IT executing a Maven build that has failing Maven plugin. Asserts that afterSessionEnd is still executed. + */ + public void testBuildError() + throws Exception + { + File testDir = + ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" ); + File extensionDir = new File( testDir, "extension" ); + File pluginDir = new File( testDir, "badplugin" ); + File projectDir = new File( testDir, "builderror" ); + + Verifier verifier; + + // install the test plugin + verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // install the bad plugin + verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + try + { + verifier.executeGoal( "package" ); + fail( "The build should fail" ); + } + catch ( VerificationException e ) + { + // expected, as the build will fail due to always failing UT + } + verifier.resetStreams(); + + verifier.assertFilePresent( "target/afterProjectsRead.txt" ); + // See http://jira.codehaus.org/browse/MNG-5641 + // verifier.assertFilePresent( "target/afterSessionStart.txt" ); verifier.assertFilePresent( "target/afterSessionEnd.txt" ); } -} + + /** + * IT executing a Maven build that has failing Maven plugin throwing RuntimeException. Asserts that afterSessionEnd is still executed. + */ + public void testBuildErrorRt() + throws Exception + { + File testDir = + ResourceExtractor.simpleExtractResources( getClass(), "/mng-5640-lifecycleParticipant-afterSession" ); + File extensionDir = new File( testDir, "extension" ); + File pluginDir = new File( testDir, "badplugin" ); + File projectDir = new File( testDir, "builderror-rt" ); + + Verifier verifier; + + // install the test plugin + verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // install the bad plugin + verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + try + { + verifier.executeGoal( "package" ); + fail( "The build should fail" ); + } + catch ( VerificationException e ) + { + // expected, as the build will fail due to always failing UT + } + verifier.resetStreams(); + + verifier.assertFilePresent( "target/afterProjectsRead.txt" ); + // See http://jira.codehaus.org/browse/MNG-5641 + // verifier.assertFilePresent( "target/afterSessionStart.txt" ); + verifier.assertFilePresent( "target/afterSessionEnd.txt" ); + }} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/pom.xml b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/pom.xml new file mode 100644 index 0000000..7bcbb90 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/pom.xml @@ -0,0 +1,72 @@ +<?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.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-badplugin</artifactId> + <version>0.1</version> + <packaging>maven-plugin</packaging> + + <properties> + <maven-version>3.2.1</maven-version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-plugin-api</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.maven.plugin-tools</groupId> + <artifactId>maven-plugin-annotations</artifactId> + <version>3.3</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.3</version> + <executions> + <execution> + <goals> + <goal>descriptor</goal> + </goals> + </execution> + </executions> + <configuration> + <!-- + Works around bug in maven-plugin packaging lifecycle: http://jira.codehaus.org/browse/MNG-5346 + --> + <skipErrorNoDescriptorsFound>true</skipErrorNoDescriptorsFound> + </configuration> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojo.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojo.java b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojo.java new file mode 100644 index 0000000..721f86a --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojo.java @@ -0,0 +1,38 @@ +package org.apache.maven.its.mng5640.lifecycleParticipantAfterSession; + +/* + * 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; +import org.apache.maven.plugins.annotations.Mojo; + +/** + * A bad mojo that fails execution by throwing a MojoExecutionException. + */ +@Mojo( name = "bad" ) +public class BadMojo + extends AbstractMojo +{ + @Override + public void execute() throws MojoExecutionException + { + throw new MojoExecutionException("Am being bad!"); + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojoRt.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojoRt.java b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojoRt.java new file mode 100644 index 0000000..257a3dd --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/badplugin/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/BadMojoRt.java @@ -0,0 +1,38 @@ +package org.apache.maven.its.mng5640.lifecycleParticipantAfterSession; + +/* + * 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; +import org.apache.maven.plugins.annotations.Mojo; + +/** + * A bad mojo that fails execution by throwing a runtime exception. + */ +@Mojo( name = "badrt" ) +public class BadMojoRt + extends AbstractMojo +{ + @Override + public void execute() + { + throw new RuntimeException("Am being bad!"); + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/pom.xml b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/pom.xml deleted file mode 100644 index fea98e0..0000000 --- a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ -<?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.mng5640.lifecycleParticipantAfterSession</groupId> - <artifactId>mng-5640-lifecycleParticipant-afterSession-basic</artifactId> - <version>0.1</version> - - <dependencies> - <dependency> - <groupId>junit</groupId> - <artifactId>junit</artifactId> - <version>3.8.1</version> - <scope>test</scope> - </dependency> - </dependencies> - - <build> - <extensions> - <extension> - <groupId>org.apache.maven.its.mng5640.lifecycleParticipantAfterSession</groupId> - <artifactId>mng-5640-lifecycleParticipant-afterSession-extension</artifactId> - <version>0.1</version> - </extension> - </extensions> - </build> -</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/src/test/java/org/apache/maven/its/mng5640/FailingTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/src/test/java/org/apache/maven/its/mng5640/FailingTest.java b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/src/test/java/org/apache/maven/its/mng5640/FailingTest.java deleted file mode 100644 index 3f2dd98..0000000 --- a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/basic/src/test/java/org/apache/maven/its/mng5640/FailingTest.java +++ /dev/null @@ -1,18 +0,0 @@ -package org.apache.maven.its.mng5640; - -import junit.framework.TestCase; - -/** - * Always failing UT. - */ -public class FailingTest - extends TestCase -{ - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( false ); - } -} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror-rt/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror-rt/pom.xml b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror-rt/pom.xml new file mode 100644 index 0000000..e4448b5 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror-rt/pom.xml @@ -0,0 +1,63 @@ +<?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.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-buildError-rt</artifactId> + <version>0.1</version> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <extensions> + <extension> + <groupId>org.apache.maven.its.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-extension</artifactId> + <version>0.1</version> + </extension> + </extensions> + <plugins> + <plugin> + <groupId>org.apache.maven.its.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-badplugin</artifactId> + <version>0.1</version> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>badrt</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror/pom.xml b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror/pom.xml new file mode 100644 index 0000000..458672b --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/builderror/pom.xml @@ -0,0 +1,63 @@ +<?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.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-buildError</artifactId> + <version>0.1</version> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <extensions> + <extension> + <groupId>org.apache.maven.its.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-extension</artifactId> + <version>0.1</version> + </extension> + </extensions> + <plugins> + <plugin> + <groupId>org.apache.maven.its.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-badplugin</artifactId> + <version>0.1</version> + <executions> + <execution> + <phase>compile</phase> + <goals> + <goal>bad</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/pom.xml b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/pom.xml new file mode 100644 index 0000000..725b317 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/pom.xml @@ -0,0 +1,54 @@ +<?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.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-buildFailure</artifactId> + <version>0.1</version> + + <dependencies> + <dependency> + <groupId>org.cstamas.missing</groupId> + <artifactId>missing-dependency</artifactId> + <version>1.0</version> + <scope>compile</scope> + </dependency> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <extensions> + <extension> + <groupId>org.apache.maven.its.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-extension</artifactId> + <version>0.1</version> + </extension> + </extensions> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/src/test/java/org/apache/maven/its/mng5640/FailingTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/src/test/java/org/apache/maven/its/mng5640/FailingTest.java b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/src/test/java/org/apache/maven/its/mng5640/FailingTest.java new file mode 100644 index 0000000..3f2dd98 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure-depmissing/src/test/java/org/apache/maven/its/mng5640/FailingTest.java @@ -0,0 +1,18 @@ +package org.apache.maven.its.mng5640; + +import junit.framework.TestCase; + +/** + * Always failing UT. + */ +public class FailingTest + extends TestCase +{ + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( false ); + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/pom.xml b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/pom.xml new file mode 100644 index 0000000..121b920 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/pom.xml @@ -0,0 +1,48 @@ +<?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.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-buildFailure</artifactId> + <version>0.1</version> + + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> + + <build> + <extensions> + <extension> + <groupId>org.apache.maven.its.mng5640.lifecycleParticipantAfterSession</groupId> + <artifactId>mng-5640-lifecycleParticipant-afterSession-extension</artifactId> + <version>0.1</version> + </extension> + </extensions> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/src/test/java/org/apache/maven/its/mng5640/FailingTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/src/test/java/org/apache/maven/its/mng5640/FailingTest.java b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/src/test/java/org/apache/maven/its/mng5640/FailingTest.java new file mode 100644 index 0000000..3f2dd98 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/buildfailure/src/test/java/org/apache/maven/its/mng5640/FailingTest.java @@ -0,0 +1,18 @@ +package org.apache.maven.its.mng5640; + +import junit.framework.TestCase; + +/** + * Always failing UT. + */ +public class FailingTest + extends TestCase +{ + /** + * Rigourous Test :-) + */ + public void testApp() + { + assertTrue( false ); + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/33a43e61/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/extension/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/LifecycleParticipantImpl.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/extension/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/LifecycleParticipantImpl.java b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/extension/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/LifecycleParticipantImpl.java index 1dabb2e..017226a 100644 --- a/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/extension/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/LifecycleParticipantImpl.java +++ b/core-it-suite/src/test/resources/mng-5640-lifecycleParticipant-afterSession/extension/src/main/java/org/apache/maven/its/mng5640/lifecycleParticipantAfterSession/LifecycleParticipantImpl.java @@ -46,14 +46,31 @@ public class LifecycleParticipantImpl } @Override + public void afterProjectsRead( MavenSession session ) + { + dropMarker( session, "afterProjectsRead.txt" ); + } + + @Override + public void afterSessionStart( MavenSession session ) + { + dropMarker( session, "afterSessionStart.txt" ); + } + + @Override public void afterSessionEnd( MavenSession session ) { + dropMarker( session, "afterSessionEnd.txt" ); + } + + private void dropMarker( MavenSession session, String markerName ) + { MavenProject project = session.getProjects().get( 0 ); File target = new File( project.getBuild().getDirectory() ); - File marker = new File( target, "afterSessionEnd.txt" ); + File marker = new File( target, markerName ); - if ( !target.exists() && !target.getParentFile().mkdirs() ) + if ( !target.exists() && !target.mkdirs() ) { log.error( "Could not create directory " + target ); }