diff --git a/its/.gitignore b/its/.gitignore index 93298bd530..aa2d9663cf 100644 --- a/its/.gitignore +++ b/its/.gitignore @@ -8,3 +8,5 @@ bin *.iml *.iws .DS_Store +.idea + 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 26f9f2abc3..22012da0b0 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 @@ -106,6 +106,7 @@ public class IntegrationTestSuite // ------------------------------------------------------------------------------------------------------------- // suite.addTestSuite( MavenIT0108SnapshotUpdateTest.class ); -- MNG-3137 + suite.addTestSuite( MavenITmng5208EventSpyParallelTest.class ); suite.addTestSuite( MavenITmng5387ArtifactReplacementPlugin.class ); suite.addTestSuite( MavenITmng5382Jsr330Plugin.class ); suite.addTestSuite( MavenITmng5338FileOptionToDirectory.class ); diff --git a/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5208EventSpyParallelTest.java b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5208EventSpyParallelTest.java new file mode 100644 index 0000000000..9e2467697f --- /dev/null +++ b/its/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5208EventSpyParallelTest.java @@ -0,0 +1,59 @@ +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.List; +import org.apache.maven.it.util.ResourceExtractor; + +public class MavenITmng5208EventSpyParallelTest + extends AbstractMavenIntegrationTestCase +{ + + public MavenITmng5208EventSpyParallelTest() + { + super( "[3.0.5,)" ); + } + + /** + * Verify spy signals correct module for failure + */ + public void testCorrectModuleFails() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5208" ); + + Verifier spy = newVerifier( testDir.getAbsolutePath() + "/spy"); + spy.executeGoal( "install" ); + + Verifier verifier = newVerifier( testDir.getAbsolutePath() + "/project" ); + verifier.setForkJvm( true ); + verifier.setAutoclean( false ); + verifier.deleteDirectory( "target" ); + verifier.setSystemProperty( "maven.ext.class.path", "../spy/target/event-spy-0.0.1-SNAPSHOT.jar" ); + verifier.getCliOptions().add( "-X" ); + verifier.getCliOptions().add( "-T 2" ); + verifier.addCliOption( "-fn" ); + verifier.executeGoal( "compile" ); + verifier.verifyTextInLog( "ProjectFailed/org.apache.maven.its.mng5208:sub-2" ); + verifier.resetStreams(); + } + +} diff --git a/its/core-it-suite/src/test/resources/mng-5208/project/pom.xml b/its/core-it-suite/src/test/resources/mng-5208/project/pom.xml new file mode 100644 index 0000000000..e276556183 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5208/project/pom.xml @@ -0,0 +1,61 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5208 + root + 0.1 + pom + + + sub-1 + sub-2 + + + + + + org.apache.maven.its.plugins + maven-it-plugin-expression + 2.1-SNAPSHOT + + target/project.properties + + project/executionRoot + project/parent/executionRoot + project/parent/parent/executionRoot + + + + + test + validate + + eval + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-5208/project/sub-1/pom.xml b/its/core-it-suite/src/test/resources/mng-5208/project/sub-1/pom.xml new file mode 100644 index 0000000000..d035e3ba98 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5208/project/sub-1/pom.xml @@ -0,0 +1,30 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5208 + sub-1 + 0.1 + jar + + diff --git a/its/core-it-suite/src/test/resources/mng-5208/project/sub-2/pom.xml b/its/core-it-suite/src/test/resources/mng-5208/project/sub-2/pom.xml new file mode 100644 index 0000000000..a8d72b67ab --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5208/project/sub-2/pom.xml @@ -0,0 +1,30 @@ + + + + + + 4.0.0 + + org.apache.maven.its.mng5208 + sub-2 + 0.1 + jar + + diff --git a/its/core-it-suite/src/test/resources/mng-5208/project/sub-2/src/main/java/Bad.java b/its/core-it-suite/src/test/resources/mng-5208/project/sub-2/src/main/java/Bad.java new file mode 100644 index 0000000000..2fcac7092a --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5208/project/sub-2/src/main/java/Bad.java @@ -0,0 +1 @@ +This is not a java file diff --git a/its/core-it-suite/src/test/resources/mng-5208/spy/pom.xml b/its/core-it-suite/src/test/resources/mng-5208/spy/pom.xml new file mode 100644 index 0000000000..522e1cdb6e --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5208/spy/pom.xml @@ -0,0 +1,53 @@ + + + 4.0.0 + org.apache.maven.core.its.mng5208 + event-spy + 0.0.1-SNAPSHOT + + UTF-8 + + + + org.apache.maven + maven-core + 3.0.3 + + + org.codehaus.plexus + plexus-component-annotations + 1.5.5 + + + junit + junit + + + + + + + + org.codehaus.plexus + plexus-component-metadata + 1.5.5 + + + process-classes + + generate-metadata + + + + process-test-classes + + generate-test-metadata + + + + + + + + diff --git a/its/core-it-suite/src/test/resources/mng-5208/spy/src/main/java/EventLoggerSpy.java b/its/core-it-suite/src/test/resources/mng-5208/spy/src/main/java/EventLoggerSpy.java new file mode 100644 index 0000000000..c8fc349368 --- /dev/null +++ b/its/core-it-suite/src/test/resources/mng-5208/spy/src/main/java/EventLoggerSpy.java @@ -0,0 +1,24 @@ + +import org.apache.maven.eventspy.AbstractEventSpy; +import org.apache.maven.eventspy.EventSpy; +import org.apache.maven.execution.ExecutionEvent; +import org.codehaus.plexus.component.annotations.Component; + +@Component( role=EventSpy.class ) +public class EventLoggerSpy extends AbstractEventSpy { + + + @Override + public void init(Context context) throws Exception { + } + + @Override + public void onEvent(Object event) throws Exception { + if (event instanceof ExecutionEvent) { + + ExecutionEvent executionEvent = (ExecutionEvent) event; + System.out.println( "executionEvent:" + executionEvent.getType() + "/" + executionEvent.getProject().getId()); + } + } +} +