Repository: maven-integration-testing Updated Branches: refs/heads/master 3d11f6c31 -> 9c8391aba
MNG-5695 more custom guice scope tests Signed-off-by: Igor Fedorenko <ifedore...@apache.org> 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/9c8391ab Tree: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/tree/9c8391ab Diff: http://git-wip-us.apache.org/repos/asf/maven-integration-testing/diff/9c8391ab Branch: refs/heads/master Commit: 9c8391aba16defe41811f5090809ec03f64918cc Parents: 3d11f6c Author: Igor Fedorenko <ifedore...@apache.org> Authored: Fri Sep 26 19:12:02 2014 -0400 Committer: Igor Fedorenko <ifedore...@apache.org> Committed: Fri Sep 26 22:19:16 2014 -0400 ---------------------------------------------------------------------- .../MavenITmng5530MojoExecutionScopeTest.java | 33 ++++- .../it/MavenITmng5578SessionScopeTest.java | 135 +++++++++++++++++++ .../extension-plugin/pom.xml | 89 ++++++++++++ .../plugin/TestSessionScopeMojo.java | 52 +++++++ .../extension-project/pom.xml | 50 +++++++ .../extension/pom.xml | 69 ++++++++++ .../TestClassRealmManagerDelegate.java | 37 +++++ .../TestMojoExecutionScopedComponent.java | 44 ++++++ .../mng-5578-session-scope/basic/pom.xml | 51 +++++++ .../extension-plugin/pom.xml | 89 ++++++++++++ .../plugin/TestSessionScopeMojo.java | 44 ++++++ .../extension-project/pom.xml | 50 +++++++ .../mng-5578-session-scope/extension/pom.xml | 69 ++++++++++ .../extension/TestSessionScopedComponent.java | 47 +++++++ .../mng-5578-session-scope/plugin/pom.xml | 82 +++++++++++ .../sessionscope/TestSessionScopeMojo.java | 43 ++++++ .../TestSessionScopedComponent.java | 45 +++++++ 17 files changed, 1028 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java index 0ab02e3..b779b68 100644 --- a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5530MojoExecutionScopeTest.java @@ -74,7 +74,7 @@ public class MavenITmng5530MojoExecutionScopeTest // build the test project verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); - verifier.getCliOptions().add("--builder multithreaded -T 1"); + verifier.getCliOptions().add( "--builder multithreaded -T 1" ); verifier.executeGoal( "package" ); verifier.resetStreams(); verifier.verifyErrorFreeLog(); @@ -84,4 +84,35 @@ public class MavenITmng5530MojoExecutionScopeTest verifier.assertFilePresent( "target/execution-before.txt" ); } + public void testExtension() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5530-mojo-execution-scope" ); + File extensionDir = new File( testDir, "extension" ); + File pluginDir = new File( testDir, "extension-plugin" ); + File projectDir = new File( testDir, "extension-project" ); + + Verifier verifier; + + // install the test extension + verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // install the test plugin + verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + verifier.addCliOption( "-Dmaven.ext.class.path=" + new File( extensionDir, "target/classes" ).getAbsolutePath() ); + verifier.setForkJvm( true ); // verifier does not support custom realms in embedded mode + verifier.executeGoal( "package" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + } + } http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5578SessionScopeTest.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5578SessionScopeTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5578SessionScopeTest.java new file mode 100644 index 0000000..5061590 --- /dev/null +++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng5578SessionScopeTest.java @@ -0,0 +1,135 @@ +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 org.apache.maven.it.util.ResourceExtractor; + +public class MavenITmng5578SessionScopeTest + extends AbstractMavenIntegrationTestCase +{ + public MavenITmng5578SessionScopeTest() + { + super( "[3.2.4,)" ); + } + + public void testBasic() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" ); + File pluginDir = new File( testDir, "plugin" ); + File projectDir = new File( testDir, "basic" ); + + Verifier verifier; + + // install the test plugin + verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + verifier.addCliOption( "-Dit-build-extensions=false" ); + verifier.executeGoal( "package" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + } + + public void testBasic_multithreaded() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" ); + File pluginDir = new File( testDir, "plugin" ); + File projectDir = new File( testDir, "basic" ); + + Verifier verifier; + + // install the test plugin + verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + verifier.addCliOption( "-Dit-build-extensions=false" ); + verifier.addCliOption( "--builder multithreaded -T 1" ); + verifier.executeGoal( "package" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + } + + public void testBasic_buildExtension() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" ); + File pluginDir = new File( testDir, "plugin" ); + File projectDir = new File( testDir, "basic" ); + + Verifier verifier; + + // install the test plugin + verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + verifier.addCliOption( "-Dit-build-extensions=true" ); + verifier.executeGoal( "package" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + } + + public void testExtension() + throws Exception + { + File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-5578-session-scope" ); + File extensionDir = new File( testDir, "extension" ); + File pluginDir = new File( testDir, "extension-plugin" ); + File projectDir = new File( testDir, "extension-project" ); + + Verifier verifier; + + // install the test extension + verifier = newVerifier( extensionDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // install the test plugin + verifier = newVerifier( pluginDir.getAbsolutePath(), "remote" ); + verifier.executeGoal( "install" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + // build the test project + verifier = newVerifier( projectDir.getAbsolutePath(), "remote" ); + verifier.addCliOption( "-Dmaven.ext.class.path=" + new File( extensionDir, "target/classes" ).getAbsolutePath() ); + verifier.setForkJvm( true ); // verifier does not support custom realms in embedded mode + verifier.executeGoal( "package" ); + verifier.resetStreams(); + verifier.verifyErrorFreeLog(); + + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/pom.xml b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/pom.xml new file mode 100644 index 0000000..62d160d --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/pom.xml @@ -0,0 +1,89 @@ +<?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>mng-5530-mojo-execution-scope</groupId> + <artifactId>mng-5530-mojo-execution-scope-extension-plugin</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</groupId> + <artifactId>maven-model</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>mng-5530-mojo-execution-scope</groupId> + <artifactId>mng-5530-mojo-execution-scope-extension</artifactId> + <version>0.1</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>sisu-maven-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <goals> + <goal>main-index</goal> + <goal>test-index</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java new file mode 100644 index 0000000..c44599b --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java @@ -0,0 +1,52 @@ +package org.apache.maven.its.mng5530.sessionscope.plugin; + +/* + * 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.its.mng5530.mojoexecutionscope.extension.TestMojoExecutionScopedComponent; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; + +/** + * @goal test-session-scope + */ +public class TestSessionScopeMojo + extends AbstractMojo +{ + /** @component */ + private TestMojoExecutionScopedComponent component; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( component.session == null ) + { + throw new NullPointerException(); + } + if ( component.project == null ) + { + throw new NullPointerException(); + } + if ( component.execution == null ) + { + throw new NullPointerException(); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-project/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-project/pom.xml b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-project/pom.xml new file mode 100644 index 0000000..fd6b136 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension-project/pom.xml @@ -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>mng-5530-mojo-execution-scope</groupId> + <artifactId>mng-5530-mojo-execution-scope-extension-project</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <build> + <plugins> + <plugin> + <groupId>mng-5530-mojo-execution-scope</groupId> + <artifactId>mng-5530-mojo-execution-scope-extension-plugin</artifactId> + <version>0.1</version> + <executions> + <execution> + <id>test-session-scope</id> + <goals> + <goal>test-session-scope</goal> + </goals> + <phase>process-resources</phase> + </execution> + </executions> + </plugin> + </plugins> + + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/pom.xml b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/pom.xml new file mode 100644 index 0000000..d537012 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/pom.xml @@ -0,0 +1,69 @@ +<?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>mng-5530-mojo-execution-scope</groupId> + <artifactId>mng-5530-mojo-execution-scope-extension</artifactId> + <version>0.1</version> + + <properties> + <maven-version>3.2.1</maven-version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>sisu-maven-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <goals> + <goal>main-index</goal> + <goal>test-index</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestClassRealmManagerDelegate.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestClassRealmManagerDelegate.java b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestClassRealmManagerDelegate.java new file mode 100644 index 0000000..979e6b6 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestClassRealmManagerDelegate.java @@ -0,0 +1,37 @@ +package org.apache.maven.its.mng5530.mojoexecutionscope.extension; + +/* + * 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 javax.inject.Named; + +import org.apache.maven.classrealm.ClassRealmManagerDelegate; +import org.apache.maven.classrealm.ClassRealmRequest; +import org.apache.maven.classrealm.ClassRealmRequest.RealmType; +import org.codehaus.plexus.classworlds.realm.ClassRealm; + +@Named +public class TestClassRealmManagerDelegate + implements ClassRealmManagerDelegate +{ + + public void setupRealm( ClassRealm classRealm, ClassRealmRequest request ) + { + if ( request.getType() == RealmType.Plugin ) + { + request.getForeignImports().put( getClass().getPackage().getName() + ".*", getClass().getClassLoader() ); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestMojoExecutionScopedComponent.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestMojoExecutionScopedComponent.java b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestMojoExecutionScopedComponent.java new file mode 100644 index 0000000..b2c6b56 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5530-mojo-execution-scope/extension/src/main/java/org/apache/maven/its/mng5530/mojoexecutionscope/extension/TestMojoExecutionScopedComponent.java @@ -0,0 +1,44 @@ +package org.apache.maven.its.mng5530.mojoexecutionscope.extension; + +/* + * 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 javax.inject.Inject; +import javax.inject.Named; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.execution.scope.MojoExecutionScoped; +import org.apache.maven.plugin.MojoExecution; +import org.apache.maven.project.MavenProject; + +@Named +@MojoExecutionScoped +public class TestMojoExecutionScopedComponent +{ + public final MavenSession session; + + public final MavenProject project; + + public final MojoExecution execution; + + @Inject + public TestMojoExecutionScopedComponent( MavenSession session, MavenProject project, MojoExecution execution ) + { + this.session = session; + this.project = project; + this.execution = execution; + } + +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/basic/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/basic/pom.xml b/core-it-suite/src/test/resources/mng-5578-session-scope/basic/pom.xml new file mode 100644 index 0000000..ac719e0 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/basic/pom.xml @@ -0,0 +1,51 @@ +<?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>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-basic</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <build> + <plugins> + <plugin> + <groupId>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-plugin</artifactId> + <version>0.1</version> + <extensions>${it-build-extensions}</extensions> + <executions> + <execution> + <id>test-session-scope</id> + <goals> + <goal>test-session-scope</goal> + </goals> + <phase>process-resources</phase> + </execution> + </executions> + </plugin> + </plugins> + + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/pom.xml b/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/pom.xml new file mode 100644 index 0000000..b1f7b95 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/pom.xml @@ -0,0 +1,89 @@ +<?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>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-extension-plugin</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</groupId> + <artifactId>maven-model</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + + <dependency> + <groupId>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-extension</artifactId> + <version>0.1</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>sisu-maven-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <goals> + <goal>main-index</goal> + <goal>test-index</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java b/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java new file mode 100644 index 0000000..3686a97 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/extension-plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/plugin/TestSessionScopeMojo.java @@ -0,0 +1,44 @@ +package org.apache.maven.its.mng5530.sessionscope.plugin; + +/* + * 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.plugin.MojoFailureException; +import org.apache.maven.project.MavenProject; + +/** + * @goal test-session-scope + */ +public class TestSessionScopeMojo + extends AbstractMojo +{ + /** @parameter expression="${project}" */ + private MavenProject project; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( project.getContextValue( "TestSessionScopedComponent" ) == null ) + { + throw new NullPointerException(); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/extension-project/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/extension-project/pom.xml b/core-it-suite/src/test/resources/mng-5578-session-scope/extension-project/pom.xml new file mode 100644 index 0000000..709a37e --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/extension-project/pom.xml @@ -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>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-extension-project</artifactId> + <version>0.0.1-SNAPSHOT</version> + <packaging>jar</packaging> + + <build> + <plugins> + <plugin> + <groupId>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-extension-plugin</artifactId> + <version>0.1</version> + <executions> + <execution> + <id>test-session-scope</id> + <goals> + <goal>test-session-scope</goal> + </goals> + <phase>process-resources</phase> + </execution> + </executions> + </plugin> + </plugins> + + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/extension/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/extension/pom.xml b/core-it-suite/src/test/resources/mng-5578-session-scope/extension/pom.xml new file mode 100644 index 0000000..88ccf8c --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/extension/pom.xml @@ -0,0 +1,69 @@ +<?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>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-extension</artifactId> + <version>0.1</version> + + <properties> + <maven-version>3.2.1</maven-version> + </properties> + + <dependencies> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>sisu-maven-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <goals> + <goal>main-index</goal> + <goal>test-index</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/extension/src/main/java/org/apache/maven/its/mng5578/sessionscope/extension/TestSessionScopedComponent.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/extension/src/main/java/org/apache/maven/its/mng5578/sessionscope/extension/TestSessionScopedComponent.java b/core-it-suite/src/test/resources/mng-5578-session-scope/extension/src/main/java/org/apache/maven/its/mng5578/sessionscope/extension/TestSessionScopedComponent.java new file mode 100644 index 0000000..b32ea2b --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/extension/src/main/java/org/apache/maven/its/mng5578/sessionscope/extension/TestSessionScopedComponent.java @@ -0,0 +1,47 @@ +package org.apache.maven.its.mng5578.sessionscope.extension; + +/* + * 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 javax.inject.Inject; +import javax.inject.Named; + +import org.apache.maven.AbstractMavenLifecycleParticipant; +import org.apache.maven.MavenExecutionException; +import org.apache.maven.SessionScoped; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; + +@Named +@SessionScoped +public class TestSessionScopedComponent + extends AbstractMavenLifecycleParticipant +{ + @Inject + public TestSessionScopedComponent( MavenSession session ) + { + System.out.println(); + } + + @Override + public void afterProjectsRead( MavenSession session ) + throws MavenExecutionException + { + for ( MavenProject project : session.getAllProjects() ) + { + project.setContextValue( "TestSessionScopedComponent", "FTW" ); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/pom.xml ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/pom.xml b/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/pom.xml new file mode 100644 index 0000000..1ffb17d --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/pom.xml @@ -0,0 +1,82 @@ +<?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>mng-5578-session-scope</groupId> + <artifactId>mng-5578-session-scope-plugin</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</groupId> + <artifactId>maven-model</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + <dependency> + <groupId>org.apache.maven</groupId> + <artifactId>maven-core</artifactId> + <version>${maven-version}</version> + <scope>provided</scope> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <version>2.0.2</version> + <configuration> + <source>1.5</source> + <target>1.5</target> + </configuration> + </plugin> + <plugin> + <groupId>org.sonatype.plugins</groupId> + <artifactId>sisu-maven-plugin</artifactId> + <version>1.1</version> + <executions> + <execution> + <goals> + <goal>main-index</goal> + <goal>test-index</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> +</project> http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopeMojo.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopeMojo.java b/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopeMojo.java new file mode 100644 index 0000000..df1d8bc --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopeMojo.java @@ -0,0 +1,43 @@ +package org.apache.maven.its.mng5530.sessionscope; + +/* + * 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.plugin.MojoFailureException; + +/** + * @goal test-session-scope + */ +public class TestSessionScopeMojo + extends AbstractMojo +{ + /** @component */ + private TestSessionScopedComponent sessionScopedComponent; + + public void execute() + throws MojoExecutionException, MojoFailureException + { + if ( sessionScopedComponent.getSession() == null ) + { + throw new NullPointerException(); + } + } +} http://git-wip-us.apache.org/repos/asf/maven-integration-testing/blob/9c8391ab/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopedComponent.java ---------------------------------------------------------------------- diff --git a/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopedComponent.java b/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopedComponent.java new file mode 100644 index 0000000..4c15fa7 --- /dev/null +++ b/core-it-suite/src/test/resources/mng-5578-session-scope/plugin/src/main/java/org/apache/maven/its/mng5530/sessionscope/TestSessionScopedComponent.java @@ -0,0 +1,45 @@ +package org.apache.maven.its.mng5530.sessionscope; + +/* + * 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 javax.inject.Inject; +import javax.inject.Named; + +import org.apache.maven.SessionScoped; +import org.apache.maven.execution.MavenSession; + +@Named +@SessionScoped +public class TestSessionScopedComponent +{ + private MavenSession session; + + @Inject + public TestSessionScopedComponent( MavenSession session ) + { + this.session = session; + } + + public MavenSession getSession() + { + return session; + } + +}