You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2022/07/25 13:21:12 UTC

[maven-integration-testing] branch master updated: [MNG-7474] SessionScoped beans should be singletons for a given session (#177)

This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-integration-testing.git


The following commit(s) were added to refs/heads/master by this push:
     new eff36ca9f [MNG-7474] SessionScoped beans should be singletons for a given session (#177)
eff36ca9f is described below

commit eff36ca9fed296136629c9d633dde08a18cc0458
Author: Guillaume Nodet <gn...@apache.org>
AuthorDate: Mon Jul 25 15:21:08 2022 +0200

    [MNG-7474] SessionScoped beans should be singletons for a given session (#177)
    
    * [MNG-7474] SessionScoped beans should be singletons for a given session
    * Upgrade Maven Resources Plugin to 3.2.0 in MNG-6720/MNG7335 to avoid
      ConcurrentModificationException
    * Clean up IT a bit
    
    This closes #177
---
 .../maven/it/MavenITmng7474SessionScopeTest.java   | 49 ++++++++++++++++++
 .../src/test/resources/mng-6720-fail-fast/pom.xml  | 12 +++++
 .../mng-7335-missing-jar-in-parallel-build/pom.xml | 12 +++++
 .../mng-7474-session-scope/plugin/pom.xml          | 58 ++++++++++++++++++++++
 .../apache/maven/its/mng7474/TestComponent.java    | 39 +++++++++++++++
 .../org/apache/maven/its/mng7474/TestMojo.java     | 44 ++++++++++++++++
 .../test/resources/mng-7474-session-scope/pom.xml  | 16 ++++++
 .../mng-7474-session-scope/project-a/pom.xml       | 34 +++++++++++++
 .../mng-7474-session-scope/project-b/pom.xml       | 34 +++++++++++++
 9 files changed, 298 insertions(+)

diff --git a/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7474SessionScopeTest.java b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7474SessionScopeTest.java
new file mode 100644
index 000000000..018681261
--- /dev/null
+++ b/core-it-suite/src/test/java/org/apache/maven/it/MavenITmng7474SessionScopeTest.java
@@ -0,0 +1,49 @@
+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;
+
+/**
+ * This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-7474">MNG-7474</a>:
+ * check that Session scope beans are actually singletons for the session.
+ */
+public class MavenITmng7474SessionScopeTest
+        extends AbstractMavenIntegrationTestCase
+{
+    public MavenITmng7474SessionScopeTest()
+    {
+        super( "[3.9.0,)" );
+    }
+
+    public void testSessionScope()
+            throws Exception
+    {
+        File testDir = ResourceExtractor.simpleExtractResources( getClass(), "/mng-7474-session-scope" );
+
+        Verifier verifier = newVerifier( testDir.getAbsolutePath() );
+        verifier.executeGoal( "validate" );
+        verifier.verifyErrorFreeLog();
+        verifier.resetStreams();
+    }
+
+}
diff --git a/core-it-suite/src/test/resources/mng-6720-fail-fast/pom.xml b/core-it-suite/src/test/resources/mng-6720-fail-fast/pom.xml
index 939fd5f71..5337dc45c 100644
--- a/core-it-suite/src/test/resources/mng-6720-fail-fast/pom.xml
+++ b/core-it-suite/src/test/resources/mng-6720-fail-fast/pom.xml
@@ -34,4 +34,16 @@ under the License.
     <module>module-2</module>
     <module>module-3</module>
   </modules>
+
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>3.2.0</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
 </project>
diff --git a/core-it-suite/src/test/resources/mng-7335-missing-jar-in-parallel-build/pom.xml b/core-it-suite/src/test/resources/mng-7335-missing-jar-in-parallel-build/pom.xml
index 3ce7b206a..3ff0e85e8 100644
--- a/core-it-suite/src/test/resources/mng-7335-missing-jar-in-parallel-build/pom.xml
+++ b/core-it-suite/src/test/resources/mng-7335-missing-jar-in-parallel-build/pom.xml
@@ -57,6 +57,18 @@
     </modules>
     <packaging>pom</packaging>
 
+  <build>
+    <pluginManagement>
+      <plugins>
+        <plugin>
+          <groupId>org.apache.maven.plugins</groupId>
+          <artifactId>maven-resources-plugin</artifactId>
+          <version>3.2.0</version>
+        </plugin>
+      </plugins>
+    </pluginManagement>
+  </build>
+
     <dependencies>
         <dependency>
             <groupId>commons-lang</groupId>
diff --git a/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/pom.xml b/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/pom.xml
new file mode 100644
index 000000000..a51b8951b
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/pom.xml
@@ -0,0 +1,58 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.maven.its.mng7474</groupId>
+        <artifactId>parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>plugin</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>maven-plugin</packaging>
+
+    <properties>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+        <maven-version>3.1.1</maven-version>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>javax.inject</groupId>
+            <artifactId>javax.inject</artifactId>
+            <version>1</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.plugin-tools</groupId>
+            <artifactId>maven-plugin-annotations</artifactId>
+            <version>3.3</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven</groupId>
+            <artifactId>maven-plugin-api</artifactId>
+            <version>${maven-version}</version>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.eclipse.sisu</groupId>
+                <artifactId>sisu-maven-plugin</artifactId>
+                <version>0.3.5</version>
+                <executions>
+                    <execution>
+                        <id>generate-index</id>
+                        <goals>
+                            <goal>main-index</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/src/main/java/org/apache/maven/its/mng7474/TestComponent.java b/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/src/main/java/org/apache/maven/its/mng7474/TestComponent.java
new file mode 100644
index 000000000..7bc17dd91
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/src/main/java/org/apache/maven/its/mng7474/TestComponent.java
@@ -0,0 +1,39 @@
+package org.apache.maven.its.mng7474;
+
+/*
+ * 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.enterprise.context.SessionScoped;
+import javax.inject.Named;
+
+import java.util.List;
+import java.util.concurrent.CopyOnWriteArrayList;
+
+@SessionScoped
+@Named
+public class TestComponent
+{
+
+    public static List<TestComponent> allInstances = new CopyOnWriteArrayList<>();
+
+    public TestComponent()
+    {
+        allInstances.add( this );
+    }
+}
diff --git a/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/src/main/java/org/apache/maven/its/mng7474/TestMojo.java b/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/src/main/java/org/apache/maven/its/mng7474/TestMojo.java
new file mode 100644
index 000000000..3d90092f6
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7474-session-scope/plugin/src/main/java/org/apache/maven/its/mng7474/TestMojo.java
@@ -0,0 +1,44 @@
+package org.apache.maven.its.mng7474;
+
+/*
+ * 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.plugins.annotations.Component;
+import org.apache.maven.plugins.annotations.Mojo;
+
+@Mojo( name = "test" )
+public class TestMojo
+        extends AbstractMojo
+{
+
+    @Component
+    TestComponent component;
+
+    @Override
+    public void execute() throws MojoExecutionException, MojoFailureException
+    {
+        if ( TestComponent.allInstances.size() > 1 )
+        {
+            throw new IllegalStateException();
+        }
+    }
+}
\ No newline at end of file
diff --git a/core-it-suite/src/test/resources/mng-7474-session-scope/pom.xml b/core-it-suite/src/test/resources/mng-7474-session-scope/pom.xml
new file mode 100644
index 000000000..6f8add86e
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7474-session-scope/pom.xml
@@ -0,0 +1,16 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.its.mng7474</groupId>
+    <artifactId>parent</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>pom</packaging>
+
+    <modules>
+        <module>plugin</module>
+        <module>project-a</module>
+        <module>project-b</module>
+    </modules>
+
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7474-session-scope/project-a/pom.xml b/core-it-suite/src/test/resources/mng-7474-session-scope/project-a/pom.xml
new file mode 100644
index 000000000..e9494f041
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7474-session-scope/project-a/pom.xml
@@ -0,0 +1,34 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.maven.its.mng7474</groupId>
+        <artifactId>parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>project-a</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.its.mng7474</groupId>
+                <artifactId>plugin</artifactId>
+                <version>1.0-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <id>test</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>
diff --git a/core-it-suite/src/test/resources/mng-7474-session-scope/project-b/pom.xml b/core-it-suite/src/test/resources/mng-7474-session-scope/project-b/pom.xml
new file mode 100644
index 000000000..28fd8b0e3
--- /dev/null
+++ b/core-it-suite/src/test/resources/mng-7474-session-scope/project-b/pom.xml
@@ -0,0 +1,34 @@
+<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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <parent>
+        <groupId>org.apache.maven.its.mng7474</groupId>
+        <artifactId>parent</artifactId>
+        <version>1.0-SNAPSHOT</version>
+    </parent>
+
+    <artifactId>project-b</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <packaging>jar</packaging>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.its.mng7474</groupId>
+                <artifactId>plugin</artifactId>
+                <version>1.0-SNAPSHOT</version>
+                <executions>
+                    <execution>
+                        <id>test</id>
+                        <phase>validate</phase>
+                        <goals>
+                            <goal>test</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+
+</project>