You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2022/01/23 21:51:24 UTC

[maven-surefire] branch release/2.22.3 updated (81a2023 -> c709bf9)

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

tibordigana pushed a change to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


 discard 81a2023  enabled and fixed tests in surefire-junit-platform
 discard 0f295d8  setupJunitLogger() should be called AFTER startCapture()
 discard 2ff0016  [jenkinsci] windows-he
 discard 2bbb86c  [jenkinsci] Maven 3.2.x and 3.6.x; JDK 7,8,11
 discard d33ae9e  [SUREFIRE-1851] Prevent NPE in SmartStackTraceParser
 discard 62557e4  [SUREFIRE-1842] - NPE at end of successful test run
 discard b6678e1  [SUREFIRE-1825] Unable to zip the Cucumber TXT report file on Linux and MacOS
 discard d0fa1ec  [SUREFIRE-1659] Log4j logger in TestExecutionListener corrupts Surefire's STDOUT
 discard 54a0582  update ASF CI url
 discard 9ca0cc5  [SUREFIRE-1843] - Trademarks / privacy policy footer displays broken
 discard d4d2413  [SUREFIRE-1924] Upgrade plexus-java to Version 1.0.7
 discard 43e5767  [SUREFIRE-1967] Fix parallel test ordering to prevent high resource consumption
 discard 4e30da4  [SUREFIRE-1890] Support TestNG 7.4.0
     new 89ae7ef  [SUREFIRE-1890] Support TestNG 7.4.0
     new 48d8e9c  [SUREFIRE-1967] Fix parallel test ordering to prevent high resource consumption
     new 40d4e7a  [SUREFIRE-1924] Upgrade plexus-java to Version 1.0.7
     new d34ebcd  [SUREFIRE-1843] - Trademarks / privacy policy footer displays broken
     new 159aacc  update ASF CI url
     new 1897798  [SUREFIRE-1659] Log4j logger in TestExecutionListener corrupts Surefire's STDOUT
     new 28da522  [SUREFIRE-1825] Unable to zip the Cucumber TXT report file on Linux and MacOS
     new 547cec7  [SUREFIRE-1842] - NPE at end of successful test run
     new ea671d2  [SUREFIRE-1851] Prevent NPE in SmartStackTraceParser
     new be44680  [jenkinsci] Maven 3.2.x and 3.6.x; JDK 7,8,11
     new 6e39e09  [jenkinsci] windows-he
     new 985649a  setupJunitLogger() should be called AFTER startCapture()
     new c709bf9  enabled and fixed tests in surefire-junit-platform

This update added new revisions after undoing existing revisions.
That is to say, some revisions that were in the old version of the
branch are not in the new version.  This situation occurs
when a user --force pushes a change and generates a repository
containing something like this:

 * -- * -- B -- O -- O -- O   (81a2023)
            \
             N -- N -- N   refs/heads/release/2.22.3 (c709bf9)

You should already have received notification emails for all of the O
revisions, and so the following emails describe only the N revisions
from the common base, B.

Any revisions marked "omit" are not gone; other references still
refer to them.  Any revisions marked "discard" are gone forever.

The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java   | 3 +++
 1 file changed, 3 insertions(+)

[maven-surefire] 03/13: [SUREFIRE-1924] Upgrade plexus-java to Version 1.0.7

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 40d4e7a53653f7a802704f76db0df5b9d2a53398
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Fri Dec 31 20:25:01 2021 +0100

    [SUREFIRE-1924] Upgrade plexus-java to Version 1.0.7
    
    (cherry picked from commit 773451c6874b02e26854a8763e0889e2126d4f95)
---
 maven-surefire-common/pom.xml                                    | 4 ++++
 .../maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java | 2 +-
 pom.xml                                                          | 9 +++++++--
 3 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/maven-surefire-common/pom.xml b/maven-surefire-common/pom.xml
index 409e28f..98ee90b 100644
--- a/maven-surefire-common/pom.xml
+++ b/maven-surefire-common/pom.xml
@@ -108,6 +108,10 @@
       <artifactId>plexus-java</artifactId>
     </dependency>
     <dependency>
+      <groupId>org.ow2.asm</groupId>
+      <artifactId>asm</artifactId>
+    </dependency>
+    <dependency>
       <groupId>org.mockito</groupId>
       <artifactId>mockito-core</artifactId>
       <scope>test</scope>
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
index 96a2a5c..731ef46 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoJava7PlusTest.java
@@ -35,7 +35,7 @@ import org.apache.maven.surefire.util.DefaultScanResult;
 import org.codehaus.plexus.languages.java.jpms.LocationManager;
 import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest;
 import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult;
-import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult.ModuleNameSource;
+import org.codehaus.plexus.languages.java.jpms.ModuleNameSource;
 import org.codehaus.plexus.logging.Logger;
 import org.junit.BeforeClass;
 import org.junit.Test;
diff --git a/pom.xml b/pom.xml
index 8da630b..aa4a1ad 100644
--- a/pom.xml
+++ b/pom.xml
@@ -256,7 +256,12 @@
       <dependency>
         <groupId>org.codehaus.plexus</groupId>
         <artifactId>plexus-java</artifactId>
-        <version>0.9.10</version>
+        <version>1.0.7</version>
+      </dependency>
+      <dependency>
+        <groupId>org.ow2.asm</groupId>
+        <artifactId>asm</artifactId>
+        <version>9.2</version>
       </dependency>
       <dependency>
         <groupId>org.mockito</groupId>
@@ -635,7 +640,7 @@
           <plugins>
             <!-- Moving to a profile, since these dependencies won't exist the first
                  time a new snapshot version is built. This prevents the first
-                 snapshot build from proceeding beyond the build for the top-level 
+                 snapshot build from proceeding beyond the build for the top-level
                  Surefire parent POM.
             -->
             <plugin>

[maven-surefire] 05/13: update ASF CI url

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 159aacc12e4a74179825309ec7c8233cd183c6ca
Author: tibordigana <ti...@gmail.com>
AuthorDate: Mon Nov 15 21:26:52 2021 +0100

    update ASF CI url
    
    (cherry picked from commit 3b77fd35f2322460a0099208d0c6fbff000cbd9f)
---
 pom.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/pom.xml b/pom.xml
index aa4a1ad..c00ce26 100644
--- a/pom.xml
+++ b/pom.xml
@@ -74,7 +74,7 @@
   </issueManagement>
   <ciManagement>
     <system>Jenkins</system>
-    <url>https://builds.apache.org/job/maven-box/job/maven-surefire</url>
+    <url>https://ci-maven.apache.org/job/Maven/job/maven-box/job/maven-surefire/</url>
   </ciManagement>
   <distributionManagement>
     <site>

[maven-surefire] 10/13: [jenkinsci] Maven 3.2.x and 3.6.x; JDK 7,8,11

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit be4468077355ef4bbe7b8810c28f66d9d2097ee5
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Sun Jan 23 07:06:27 2022 +0100

    [jenkinsci] Maven 3.2.x and 3.6.x; JDK 7,8,11
---
 Jenkinsfile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 9de3f2f..1013636 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -31,8 +31,8 @@ properties(
 )
 
 final def oses = ['linux':'ubuntu && !H24', 'windows':'Windows']
-final def mavens = env.BRANCH_NAME == 'master' ? ['3.2.x', '3.3.x', '3.5.x'] : ['3.5.x']
-final def jdks = [7, 8, 9, 10, 11]
+final def mavens = env.BRANCH_NAME == 'master' ? ['3.2.x', '3.6.x'] : ['3.6.x']
+final def jdks = [7, 8, 11]
 
 final def options = ['-e', '-V', '-B', '-nsu', '-P', 'run-its']
 final def goals = ['clean', 'install', 'jacoco:report']

[maven-surefire] 09/13: [SUREFIRE-1851] Prevent NPE in SmartStackTraceParser

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit ea671d2846b1421b9e96aa9f993c8dfb17eec651
Author: Adam Jones <jo...@rocketmail.com>
AuthorDate: Mon Oct 5 02:32:14 2020 +0200

    [SUREFIRE-1851] Prevent NPE in SmartStackTraceParser
    
    (cherry picked from commit 08163fa6d0d161070a6add1c05a1058781160415)
---
 .../surefire/report/SmartStackTraceParser.java     |  6 ++-
 .../apache/maven/surefire/report/ATestClass.java   |  5 +++
 .../surefire/report/SmartStackTraceParserTest.java | 15 ++++++++
 .../{ATestClass.java => SomeMockedException.java}  | 43 ++++++++++------------
 4 files changed, 45 insertions(+), 24 deletions(-)

diff --git a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
index 7c68f95..cccb939 100644
--- a/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
+++ b/surefire-providers/common-java5/src/main/java/org/apache/maven/surefire/report/SmartStackTraceParser.java
@@ -196,11 +196,15 @@ public class SmartStackTraceParser
 
     private boolean rootIsInclass()
     {
-        return stackTrace.length > 0 && stackTrace[0].getClassName().equals( testClassName );
+        return stackTrace != null && stackTrace.length > 0 && stackTrace[0].getClassName().equals( testClassName );
     }
 
     static List<StackTraceElement> focusOnClass( StackTraceElement[] stackTrace, Class clazz )
     {
+        if ( stackTrace == null )
+        {
+            return Collections.emptyList();
+        }
         List<StackTraceElement> result = new ArrayList<StackTraceElement>();
         for ( StackTraceElement element : stackTrace )
         {
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/ATestClass.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/ATestClass.java
index baff162..d75e741 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/ATestClass.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/ATestClass.java
@@ -60,4 +60,9 @@ public class ATestClass
         throw new RuntimeException( "This message will be truncated, somewhere over the rainbow. "
                                         + "Gangnam style, Gangnam style, Gangnam style, , Gangnam style, Gangnam style" );
     }
+
+    public void aMockedException()
+    {
+        throw new SomeMockedException();
+    }
 }
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
index e600718..a598f5b 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SmartStackTraceParserTest.java
@@ -303,6 +303,21 @@ public class SmartStackTraceParserTest
         }
     }
 
+    public void testNullStackTrace()
+    {
+        try
+        {
+            new ATestClass().aMockedException();
+        }
+        catch ( Exception e )
+        {
+            SmartStackTraceParser smartStackTraceParser =
+                    new SmartStackTraceParser( ATestClass.class.getName(), e, null );
+            String res = smartStackTraceParser.getString();
+            assertEquals( "ATestClass » SomeMocked", res );
+        }
+    }
+
     public ExecutionException getSingleNested()
     {
         FutureTask<Object> futureTask = new FutureTask<Object>( new RunnableTestClass2() );
diff --git a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/ATestClass.java b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SomeMockedException.java
similarity index 54%
copy from surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/ATestClass.java
copy to surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SomeMockedException.java
index baff162..5852db2 100644
--- a/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/ATestClass.java
+++ b/surefire-providers/common-java5/src/test/java/org/apache/maven/surefire/report/SomeMockedException.java
@@ -19,45 +19,42 @@ package org.apache.maven.surefire.report;
  * under the License.
  */
 
-import java.io.File;
-
-@SuppressWarnings( "UnusedDeclaration" )
-public class ATestClass
+/**
+ * @author Adam Jones
+ */
+public class SomeMockedException extends RuntimeException
 {
-
-    public void failInAssert()
-    {
-        throw new AssertionError( "X is not Z" );
-    }
-
-    public void nestedFailInAssert()
+    public SomeMockedException()
     {
-        failInAssert();
     }
 
-    public void npe()
+    @Override
+    public String getMessage()
     {
-        throw new NullPointerException( "It was null" );
+        return null;
     }
 
-    public void nestedNpe()
+    @Override
+    public String getLocalizedMessage()
     {
-        npe();
+        return null;
     }
 
-    public void npeOutsideTest()
+    @Override
+    public Throwable getCause()
     {
-        File file = new File( (String) null );
+        return null;
     }
 
-    public void nestedNpeOutsideTest()
+    @Override
+    public String toString()
     {
-        npeOutsideTest();
+        return null;
     }
 
-    public void aLongTestErrorMessage()
+    @Override
+    public StackTraceElement[] getStackTrace()
     {
-        throw new RuntimeException( "This message will be truncated, somewhere over the rainbow. "
-                                        + "Gangnam style, Gangnam style, Gangnam style, , Gangnam style, Gangnam style" );
+        return null;
     }
 }

[maven-surefire] 13/13: enabled and fixed tests in surefire-junit-platform

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit c709bf952ce8d51c60f1f3d580b10ef1f4e15027
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Sun Jan 23 20:57:40 2022 +0100

    enabled and fixed tests in surefire-junit-platform
---
 surefire-providers/surefire-junit-platform/pom.xml |  4 ++
 .../surefire/junitplatform/JUnit47SuiteTest.java   | 44 ++++++++++++++++++++++
 .../junitplatform/RunListenerAdapterTest.java      |  5 ++-
 .../junitplatform/TestMethodFilterTest.java        |  5 ++-
 4 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/surefire-providers/surefire-junit-platform/pom.xml b/surefire-providers/surefire-junit-platform/pom.xml
index b50dc6d..da34605 100644
--- a/surefire-providers/surefire-junit-platform/pom.xml
+++ b/surefire-providers/surefire-junit-platform/pom.xml
@@ -138,6 +138,10 @@
                 <artifactId>maven-surefire-plugin</artifactId>
                 <configuration>
                     <jvm>${java.home}/bin/java</jvm>
+                    <redirectTestOutputToFile>true</redirectTestOutputToFile>
+                    <includes>
+                        <include>**/JUnit47SuiteTest.java</include>
+                    </includes>
                 </configuration>
             </plugin>
             <plugin>
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnit47SuiteTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnit47SuiteTest.java
new file mode 100644
index 0000000..6e56760
--- /dev/null
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/JUnit47SuiteTest.java
@@ -0,0 +1,44 @@
+package org.apache.maven.surefire.junitplatform;
+
+/*
+ * 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 junit.framework.JUnit4TestAdapter;
+import junit.framework.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+import org.junit.runners.Suite.SuiteClasses;
+
+/**
+ *
+ */
+@SuiteClasses( {
+        JUnitPlatformProviderTest.class,
+        RunListenerAdapterTest.class,
+        TestMethodFilterTest.class,
+        TestPlanScannerFilterTest.class
+} )
+@RunWith( Suite.class )
+public class JUnit47SuiteTest
+{
+    public static Test suite()
+    {
+        return new JUnit4TestAdapter( JUnit47SuiteTest.class );
+    }
+}
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
index a6cbddd..a0ba6b7 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/RunListenerAdapterTest.java
@@ -46,9 +46,11 @@ import org.apache.maven.surefire.report.SimpleReportEntry;
 import org.junit.Before;
 import org.junit.Test;
 import org.junit.jupiter.api.DisplayName;
+import org.junit.jupiter.engine.config.DefaultJupiterConfiguration;
 import org.junit.jupiter.engine.config.JupiterConfiguration;
 import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
 import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
+import org.junit.platform.engine.ConfigurationParameters;
 import org.junit.platform.engine.TestDescriptor;
 import org.junit.platform.engine.TestDescriptor.Type;
 import org.junit.platform.engine.TestExecutionResult;
@@ -69,7 +71,8 @@ import org.mockito.InOrder;
  */
 public class RunListenerAdapterTest
 {
-    private static final JupiterConfiguration JUPITER_CONFIGURATION = mock(JupiterConfiguration.class);
+    private static final JupiterConfiguration JUPITER_CONFIGURATION =
+            new DefaultJupiterConfiguration( mock( ConfigurationParameters.class ) );
 
     private RunListener listener;
 
diff --git a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
index 3633faa..b5cb528 100644
--- a/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
+++ b/surefire-providers/surefire-junit-platform/src/test/java/org/apache/maven/surefire/junitplatform/TestMethodFilterTest.java
@@ -29,9 +29,11 @@ import java.lang.reflect.Method;
 
 import org.apache.maven.surefire.testset.TestListResolver;
 import org.junit.Test;
+import org.junit.jupiter.engine.config.DefaultJupiterConfiguration;
 import org.junit.jupiter.engine.config.JupiterConfiguration;
 import org.junit.jupiter.engine.descriptor.ClassTestDescriptor;
 import org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor;
+import org.junit.platform.engine.ConfigurationParameters;
 import org.junit.platform.engine.FilterResult;
 import org.junit.platform.engine.UniqueId;
 
@@ -42,7 +44,8 @@ import org.junit.platform.engine.UniqueId;
  */
 public class TestMethodFilterTest
 {
-    private static final JupiterConfiguration JUPITER_CONFIGURATION = mock(JupiterConfiguration.class);
+    private static final JupiterConfiguration JUPITER_CONFIGURATION =
+            new DefaultJupiterConfiguration( mock( ConfigurationParameters.class ) );
 
     private final TestListResolver resolver = mock( TestListResolver.class );
 

[maven-surefire] 07/13: [SUREFIRE-1825] Unable to zip the Cucumber TXT report file on Linux and MacOS

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 28da522a400cf5b04f2ae2f2f31a3ed69b0127ac
Author: tibordigana <ti...@apache.org>
AuthorDate: Sat Jul 18 22:26:55 2020 +0200

    [SUREFIRE-1825] Unable to zip the Cucumber TXT report file on Linux and MacOS
    
    (cherry picked from commit 53ea3ea7c320c62c9068c1d226a8f1233e99e7e0)
---
 .../org/apache/maven/plugin/surefire/report/FileReporterUtils.java  | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
index fd33d8e..ea5c6c6 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/report/FileReporterUtils.java
@@ -47,6 +47,10 @@ public final class FileReporterUtils
 
     private static String getOSSpecificIllegalChars()
     {
-        return IS_OS_WINDOWS ? "\\/:*?\"<>|\0" : "/\0";
+        // forbidden and quoted characters
+        // https://docs.microsoft.com/en-us/windows/win32/fileio/naming-a-file
+        // https://cygwin.com/cygwin-ug-net/using-specialnames.html
+        // https://www.cyberciti.biz/faq/linuxunix-rules-for-naming-file-and-directory-names/
+        return IS_OS_WINDOWS ? "[],\\/:*?\"<>|\0" : "()&\\/:*?\"<>|\0";
     }
 }

[maven-surefire] 11/13: [jenkinsci] windows-he

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 6e39e09c4a2fe29d01ae98ba92bc524e2f1e6a57
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Sun Jan 23 07:22:44 2022 +0100

    [jenkinsci] windows-he
---
 Jenkinsfile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index 1013636..6eabce6 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -30,7 +30,7 @@ properties(
     ]
 )
 
-final def oses = ['linux':'ubuntu && !H24', 'windows':'Windows']
+final def oses = ['linux':'ubuntu', 'windows':'windows-he']
 final def mavens = env.BRANCH_NAME == 'master' ? ['3.2.x', '3.6.x'] : ['3.6.x']
 final def jdks = [7, 8, 11]
 

[maven-surefire] 02/13: [SUREFIRE-1967] Fix parallel test ordering to prevent high resource consumption

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 48d8e9c31aea865d00642c39c114ad9bbbe0606c
Author: Piotr Findeisen <pi...@gmail.com>
AuthorDate: Mon Jan 10 11:03:00 2022 +0100

    [SUREFIRE-1967] Fix parallel test ordering to prevent high resource consumption
    
    Before the change, TestNG run from Surefire can execute `@BeforeClass`
    on many different test classes/instances, without invoking `@AfterClass`
    yet, leading to high resource utilization. This is not observed when
    tests are invoked via a suite file. This is because `XmlClass.m_index`
    field is used by TestNG to order test execution and this field used not
    to be set by Surefire. This commit lets Surefire initialize `XmlClass`
    object in a similar manner to how TestNG suite file XML parser does.
    
    (cherry picked from commit 909637cb5d79171e12690ad0f1b99a3bd2184e23)
---
 .../maven/surefire/util/ReflectionUtils.java       | 12 ++++
 .../maven/surefire/util/ReflectionUtilsTest.java   | 29 ++++++++
 .../surefire/its/fixture/HelperAssertions.java     |  7 ++
 ...ire1967CheckTestNgMethodParallelOrderingIT.java | 83 ++++++++++++++++++++++
 .../pom.xml                                        | 60 ++++++++++++++++
 .../test/java/testng/parallelOrdering/Base.java    | 58 +++++++++++++++
 .../java/testng/parallelOrdering/TestClass1.java   |  3 +
 .../java/testng/parallelOrdering/TestClass2.java   |  3 +
 .../java/testng/parallelOrdering/TestClass3.java   |  3 +
 .../java/testng/parallelOrdering/TestClass4.java   |  3 +
 .../maven/surefire/testng/TestNGExecutor.java      | 42 ++++++++++-
 11 files changed, 302 insertions(+), 1 deletion(-)

diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
index 49f8f09..38c89ce 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/util/ReflectionUtils.java
@@ -88,6 +88,18 @@ public final class ReflectionUtils
         }
     }
 
+    public static <T> Constructor<T> tryGetConstructor( Class<T> clazz, Class<?>... arguments )
+    {
+        try
+        {
+            return clazz.getConstructor( arguments );
+        }
+        catch ( NoSuchMethodException e )
+        {
+            return null;
+        }
+    }
+
     public static Object newInstance( Constructor constructor, Object... params )
     {
         try
diff --git a/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java b/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java
index 5440d6e..09beff5 100644
--- a/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java
+++ b/surefire-api/src/test/java/org/apache/maven/surefire/util/ReflectionUtilsTest.java
@@ -21,6 +21,8 @@ package org.apache.maven.surefire.util;
 
 import org.junit.Test;
 
+import java.lang.reflect.Constructor;
+
 import static org.fest.assertions.Assertions.assertThat;
 
 /**
@@ -31,6 +33,23 @@ import static org.fest.assertions.Assertions.assertThat;
  */
 public class ReflectionUtilsTest
 {
+    @Test
+    public void shouldGetConstructor() throws Exception
+    {
+        Constructor<ClassWithParameterizedConstructor> constructor =
+                ReflectionUtils.tryGetConstructor( ClassWithParameterizedConstructor.class, int.class );
+        assertThat( constructor ).isNotNull();
+        // Verify the Constructor returned really is for the class it should be
+        assertThat( constructor.newInstance( 10 ) ).isInstanceOf( ClassWithParameterizedConstructor.class );
+    }
+
+    @Test
+    public void shouldNotGetNonExistingConstructor()
+    {
+        assertThat( ReflectionUtils.tryGetConstructor( ClassWithParameterizedConstructor.class, String.class ) )
+                .isNull();
+    }
+
     @Test(expected = RuntimeException.class)
     public void shouldNotInvokeStaticMethod()
     {
@@ -113,4 +132,14 @@ public class ReflectionUtilsTest
             return 1L;
         }
     }
+
+    // The constructor has to be public for ReflectionUtils.tryGetConstructor to find it. Currently, the checkstyle
+    // rules require that class be public too, and a public class must be documented, hence minimalist javadoc.
+    /** */
+    public static class ClassWithParameterizedConstructor
+    {
+        public ClassWithParameterizedConstructor( int param )
+        {
+        }
+    }
 }
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
index 5bea87e..641ac41 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/fixture/HelperAssertions.java
@@ -28,6 +28,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Locale;
 
+import static java.lang.Double.parseDouble;
 import static junit.framework.Assert.assertEquals;
 import static junit.framework.Assert.assertTrue;
 import static org.apache.commons.io.Charsets.UTF_8;
@@ -51,6 +52,12 @@ public class HelperAssertions
         assertTestSuiteResults( total, errors, failures, skipped, flakes, suite );
     }
 
+    public static void assumeJavaMaxVersion( double expectedMaxVersion )
+    {
+        String thisVersion = System.getProperty( "java.specification.version" );
+        assumeTrue( "java.specification.version: " + thisVersion, parseDouble( thisVersion ) <= expectedMaxVersion );
+    }
+
     public static void assertTestSuiteResults( int total, File testDir )
     {
         IntegrationTestSuiteResults suite = parseTestResults( testDir );
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java
new file mode 100644
index 0000000..5f0ed9d
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/jiras/Surefire1967CheckTestNgMethodParallelOrderingIT.java
@@ -0,0 +1,83 @@
+package org.apache.maven.surefire.its.jiras;
+
+/*
+ * 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.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Test;
+
+import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaMaxVersion;
+
+/**
+ * Test TestNG setup and teardown ordering with parallelism
+ *
+ * @author findepi
+ */
+public class Surefire1967CheckTestNgMethodParallelOrderingIT
+    extends SurefireJUnit4IntegrationTestCase
+{
+    @Test
+    public void testNgParallelOrdering()
+    {
+        unpack( "surefire-1967-testng-method-parallel-ordering" )
+                .sysProp( "testNgVersion", "7.3.0" )
+                .executeTest()
+                .verifyErrorFree( 12 );
+    }
+
+    // Since the test ordering guarantees currently depend on reflection, it's useful to test with
+    // some older version too.
+    @Test
+    public void testNgParallelOrderingWithVersion6()
+    {
+        unpack( "surefire-1967-testng-method-parallel-ordering" )
+                .sysProp( "testNgVersion", "6.10" )
+                .executeTest()
+                .verifyErrorFree( 12 );
+    }
+
+    // TestNG 6.2.1 is the newest version that doesn't have XmlClass.setIndex method yet.
+    // Note that the problem of wrong setup methods ordering (SUREFIRE-1967) was not observed on that version.
+    // This is likely because SUREFIRE-1967 is related to a change in TestNG 6.3, where preserve-order became true by
+    // default (https://github.com/cbeust/testng/commit/8849b3406ef2184ceb6002768a2d087d7a8de8d5).
+    @Test
+    public void testNgParallelOrderingWithEarlyVersion6()
+    {
+        unpack( "surefire-1967-testng-method-parallel-ordering" )
+                .sysProp( "testNgVersion", "6.2.1" )
+                .executeTest()
+                .verifyErrorFree( 12 );
+    }
+
+    // TestNG 5.13+ already has XmlClass.m_index field, but doesn't have XmlClass.setIndex method.
+    // Note that the problem of wrong setup methods ordering (SUREFIRE-1967) was not observed on that version.
+    // This is likely because SUREFIRE-1967 is related to a change in TestNG 6.3, where preserve-order became true by
+    // default (https://github.com/cbeust/testng/commit/8849b3406ef2184ceb6002768a2d087d7a8de8d5).
+    @Test
+    public void testNgParallelOrderingWithVersion5()
+    {
+        // TestNG 5.13 does not work with Java 17
+        assumeJavaMaxVersion( 16 );
+
+        unpack( "surefire-1967-testng-method-parallel-ordering" )
+                .sysProp( "testNgVersion", "5.13" )
+                .executeTest()
+                .verifyErrorFree( 12 );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/pom.xml b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/pom.xml
new file mode 100644
index 0000000..f71d97c
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/pom.xml
@@ -0,0 +1,60 @@
+<?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/xsd/maven-4.0.0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.surefire</groupId>
+    <artifactId>it-parent</artifactId>
+    <version>1.0</version>
+    <relativePath>../pom.xml</relativePath>
+  </parent>
+
+  <groupId>org.apache.maven.plugins.surefire</groupId>
+  <artifactId>surefire-1967-testng-method-parallel-ordering</artifactId>
+  <version>1.0-SNAPSHOT</version>
+  <name>TestNG parallel ordering</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.testng</groupId>
+      <artifactId>testng</artifactId>
+      <version>${testNgVersion}</version>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <version>${surefire.version}</version>
+        <configuration>
+          <threadCount>2</threadCount>
+          <parallel>methods</parallel>
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/Base.java b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/Base.java
new file mode 100644
index 0000000..ab37f14
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/Base.java
@@ -0,0 +1,58 @@
+package testng.parallelOrdering;
+
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
+
+import java.util.concurrent.ThreadLocalRandom;
+import java.util.concurrent.atomic.AtomicInteger;
+
+public abstract class Base
+{
+    private static final AtomicInteger resources = new AtomicInteger();
+
+    // This simulates resource allocation
+    @BeforeClass
+    public void setupAllocateResources()
+    {
+        int concurrentResources = resources.incrementAndGet();
+        if (concurrentResources > 2) {
+            throw new IllegalStateException("Tests execute in two threads, so there should be at most 2 resources allocated, got: " + concurrentResources);
+        }
+    }
+
+    // This simulates freeing resources
+    @AfterClass(alwaysRun = true)
+    public void tearDownReleaseResources()
+    {
+        resources.decrementAndGet();
+    }
+
+    @Test
+    public void test1()
+            throws Exception
+    {
+        sleepShortly();
+    }
+
+    @Test
+    public void test2()
+            throws Exception
+    {
+        sleepShortly();
+    }
+
+    @Test
+    public void test3()
+            throws Exception
+    {
+        sleepShortly();
+    }
+
+    // Sleep random time to let tests interleave. Keep sleep short not to extend tests duration too much.
+    private void sleepShortly()
+            throws InterruptedException
+    {
+        Thread.sleep(ThreadLocalRandom.current().nextInt(3));
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass1.java b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass1.java
new file mode 100644
index 0000000..34c524c
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass1.java
@@ -0,0 +1,3 @@
+package testng.parallelOrdering;
+
+public class TestClass1 extends Base {}
diff --git a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass2.java b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass2.java
new file mode 100644
index 0000000..8b11761
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass2.java
@@ -0,0 +1,3 @@
+package testng.parallelOrdering;
+
+public class TestClass2 extends Base {}
diff --git a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass3.java b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass3.java
new file mode 100644
index 0000000..b5ea787
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass3.java
@@ -0,0 +1,3 @@
+package testng.parallelOrdering;
+
+public class TestClass3 extends Base {}
diff --git a/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass4.java b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass4.java
new file mode 100644
index 0000000..51b9fc5
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1967-testng-method-parallel-ordering/src/test/java/testng/parallelOrdering/TestClass4.java
@@ -0,0 +1,3 @@
+package testng.parallelOrdering;
+
+public class TestClass4 extends Base {}
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
index 0b52c4d..bae5f8b 100644
--- a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/TestNGExecutor.java
@@ -50,6 +50,10 @@ import java.util.concurrent.atomic.AtomicInteger;
 import static org.apache.maven.surefire.cli.CommandLineOption.LOGGING_LEVEL_DEBUG;
 import static org.apache.maven.surefire.cli.CommandLineOption.SHOW_ERRORS;
 import static org.apache.maven.surefire.util.ReflectionUtils.instantiate;
+import static org.apache.maven.surefire.util.ReflectionUtils.invokeSetter;
+import static org.apache.maven.surefire.util.ReflectionUtils.newInstance;
+import static org.apache.maven.surefire.util.ReflectionUtils.tryGetConstructor;
+import static org.apache.maven.surefire.util.ReflectionUtils.tryGetMethod;
 import static org.apache.maven.surefire.util.ReflectionUtils.tryLoadClass;
 import static org.apache.maven.surefire.util.internal.ConcurrencyUtils.countDownToZero;
 
@@ -70,6 +74,17 @@ final class TestNGExecutor
     private static final boolean HAS_TEST_ANNOTATION_ON_CLASSPATH =
             tryLoadClass( TestNGExecutor.class.getClassLoader(), "org.testng.annotations.Test" ) != null;
 
+    // Using reflection because XmlClass.setIndex is available since TestNG 6.3
+    // XmlClass.m_index field is available since TestNG 5.13, but prior to 6.3 required invoking constructor
+    // and constructor XmlClass constructor signatures evolved over time.
+    private static final Method XML_CLASS_SET_INDEX = tryGetMethod( XmlClass.class, "setIndex", int.class );
+
+    // For TestNG versions [5.13, 6.3) where XmlClass.setIndex is not available, invoke XmlClass(String, boolean, int)
+    // constructor. Note that XmlClass(String, boolean, int) was replaced with XmlClass(String, int) when
+    // XmlClass.setIndex already existed.
+    private static final Constructor<XmlClass> XML_CLASS_CONSTRUCTOR_WITH_INDEX =
+            tryGetConstructor( XmlClass.class, String.class, boolean.class, int.class );
+
     private TestNGExecutor()
     {
         throw new IllegalStateException( "not instantiable constructor" );
@@ -125,7 +140,7 @@ final class TestNGExecutor
                 suiteAndNamedTests.testNameToTest.put( metadata.testName, xmlTest );
             }
 
-            xmlTest.getXmlClasses().add( new XmlClass( testClass.getName() ) );
+            xmlTest.getXmlClasses().add( newXmlClassInstance( testClass.getName(), xmlTest.getXmlClasses().size() ) );
         }
 
         testng.setXmlSuites( xmlSuites );
@@ -135,6 +150,31 @@ final class TestNGExecutor
         testng.run();
     }
 
+    private static XmlClass newXmlClassInstance( String testClassName, int index )
+    {
+        // In case of parallel test execution with parallel="methods", TestNG orders test execution
+        // by XmlClass.m_index field. When unset (equal for all XmlClass instances), TestNG can
+        // invoke `@BeforeClass` setup methods on many instances, without invoking `@AfterClass`
+        // tearDown methods, thus leading to high resource consumptions when test instances
+        // allocate resources.
+        // With index set, order of setup, test and tearDown methods is reasonable, with approximately
+        // #thread-count many test classes being initialized at given point in time.
+        // Note: XmlClass.m_index field is set automatically by TestNG when it reads a suite file.
+
+        if ( XML_CLASS_SET_INDEX != null )
+        {
+            XmlClass xmlClass = new XmlClass( testClassName );
+            invokeSetter( xmlClass, XML_CLASS_SET_INDEX, index );
+            return xmlClass;
+        }
+        if ( XML_CLASS_CONSTRUCTOR_WITH_INDEX != null )
+        {
+            boolean loadClass = true; // this is the default
+            return (XmlClass) newInstance( XML_CLASS_CONSTRUCTOR_WITH_INDEX, testClassName, loadClass, index );
+        }
+        return new XmlClass( testClassName );
+    }
+
     private static boolean isCliDebugOrShowErrors( List<CommandLineOption> mainCliOptions )
     {
         return mainCliOptions.contains( LOGGING_LEVEL_DEBUG ) || mainCliOptions.contains( SHOW_ERRORS );

[maven-surefire] 06/13: [SUREFIRE-1659] Log4j logger in TestExecutionListener corrupts Surefire's STDOUT

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 189779833ef6ea56225481af14f7eed680015c38
Author: Xavier Dury <ka...@hotmail.com>
AuthorDate: Fri Mar 26 15:43:56 2021 +0100

    [SUREFIRE-1659] Log4j logger in TestExecutionListener corrupts
    Surefire's STDOUT
    
    (cherry picked from commit 0ec1283c1652408cae53650eebdd0c33f876a807)
---
 .../its/JUnitPlatformStreamCorruptionIT.java       | 30 ++++++++
 .../surefire-1659-stream-corruption/pom.xml        | 88 ++++++++++++++++++++++
 .../com/example/demo/JUnitPlatformSampleTest.java  | 17 +++++
 .../src/test/resources/jul-to-slf4j.properties     |  1 +
 .../src/test/resources/junit-platform.properties   |  1 +
 .../src/test/resources/log4j2.xml                  | 13 ++++
 .../src/test/resources/logback-test.xml            | 11 +++
 .../junitplatform/JUnitPlatformProvider.java       |  3 +-
 .../maven/surefire/junitplatform/LazyLauncher.java | 70 +++++++++++++++++
 9 files changed, 232 insertions(+), 2 deletions(-)

diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformStreamCorruptionIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformStreamCorruptionIT.java
index 00a556c..b4b08bd 100644
--- a/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformStreamCorruptionIT.java
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/JUnitPlatformStreamCorruptionIT.java
@@ -53,4 +53,34 @@ public class JUnitPlatformStreamCorruptionIT
         assertThat( lines )
                 .isEmpty();
     }
+
+    @Test
+    public void warningIsNotEmittedWithJulToSlf4j() throws VerificationException
+    {
+        OutputValidator validator = unpack( "/surefire-1659-stream-corruption" )
+                .activateProfile( "junit-platform-with-jul-to-slf4j" )
+                .executeTest()
+                .verifyErrorFree( 1 );
+
+        List<String> lines = validator.loadLogLines(
+                startsWith( "[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM" ) );
+
+        assertThat( lines )
+                .isEmpty();
+    }
+
+    @Test
+    public void warningIsNotEmittedWithJulToLog4j() throws VerificationException
+    {
+        OutputValidator validator = unpack( "/surefire-1659-stream-corruption" )
+                .activateProfile( "junit-platform-with-jul-to-log4j" )
+                .executeTest()
+                .verifyErrorFree( 1 );
+
+        List<String> lines = validator.loadLogLines(
+                startsWith( "[WARNING] Corrupted STDOUT by directly writing to native stream in forked JVM" ) );
+
+        assertThat( lines )
+                .isEmpty();
+    }
 }
diff --git a/surefire-its/src/test/resources/surefire-1659-stream-corruption/pom.xml b/surefire-its/src/test/resources/surefire-1659-stream-corruption/pom.xml
new file mode 100644
index 0000000..1184931
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1659-stream-corruption/pom.xml
@@ -0,0 +1,88 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.plugins.surefire</groupId>
+    <artifactId>junit-platform-1.0.0</artifactId>
+    <version>1.0</version>
+    <name>[SUREFIRE-1659] Log4j logger in TestExecutionListener corrupts Surefire's STDOUT.</name>
+
+    <properties>
+        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+        <maven.compiler.source>${java.specification.version}</maven.compiler.source>
+        <maven.compiler.target>${java.specification.version}</maven.compiler.target>
+    </properties>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.junit.jupiter</groupId>
+            <artifactId>junit-jupiter-engine</artifactId>
+            <version>5.7.1</version>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>junit-platform-with-jul-to-slf4j</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <version>${surefire.version}</version>
+                        <configuration>
+                            <systemPropertyVariables>
+                                <java.util.logging.config.file>${project.basedir}/src/test/resources/jul-to-slf4j.properties</java.util.logging.config.file>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+            <dependencies>
+                <dependency>
+                    <groupId>org.slf4j</groupId>
+                    <artifactId>jul-to-slf4j</artifactId>
+                    <version>1.7.25</version>
+                    <scope>test</scope>
+                </dependency>
+                <dependency>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-classic</artifactId>
+                    <version>1.2.3</version>
+                    <scope>test</scope>
+                </dependency>
+            </dependencies>
+        </profile>
+        <profile>
+            <id>junit-platform-with-jul-to-log4j</id>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-surefire-plugin</artifactId>
+                        <version>${surefire.version}</version>
+                        <configuration>
+                            <systemPropertyVariables>
+                                <java.util.logging.manager>org.apache.logging.log4j.jul.LogManager</java.util.logging.manager>
+                            </systemPropertyVariables>
+                        </configuration>
+                    </plugin>
+                </plugins>
+            </build>
+            <dependencies>
+                <dependency>
+                    <groupId>org.apache.logging.log4j</groupId>
+                    <artifactId>log4j-core</artifactId>
+                    <version>2.13.1</version>
+                </dependency>
+                <dependency>
+                    <groupId>org.apache.logging.log4j</groupId>
+                    <artifactId>log4j-jul</artifactId>
+                    <version>2.13.1</version>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
+</project>
diff --git a/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/java/com/example/demo/JUnitPlatformSampleTest.java b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/java/com/example/demo/JUnitPlatformSampleTest.java
new file mode 100644
index 0000000..f0359bb
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/java/com/example/demo/JUnitPlatformSampleTest.java
@@ -0,0 +1,17 @@
+package com.example.demo;
+
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
+
+import java.util.logging.Logger;
+
+public class JUnitPlatformSampleTest
+{
+
+    @Test
+    public void sampleTest()
+    {
+        Logger.getLogger( getClass().getName() ).info( "running test" );
+        Assertions.assertTrue( true );
+    }
+}
diff --git a/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/jul-to-slf4j.properties b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/jul-to-slf4j.properties
new file mode 100644
index 0000000..637a886
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/jul-to-slf4j.properties
@@ -0,0 +1 @@
+handlers = org.slf4j.bridge.SLF4JBridgeHandler
diff --git a/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/junit-platform.properties b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/junit-platform.properties
new file mode 100644
index 0000000..648ee97
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/junit-platform.properties
@@ -0,0 +1 @@
+# This file is needed in order for JUnit to log something early on org.junit.platform.launcher.core.LauncherConfigurationParameters
diff --git a/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/log4j2.xml b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/log4j2.xml
new file mode 100644
index 0000000..a5185ce
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/log4j2.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Configuration status="INFO">
+    <Appenders>
+        <Console name="console" target="SYSTEM_OUT">
+            <PatternLayout pattern="[%-5level] %d{yyyy-MM-dd HH:mm:ss.SSS} [%t] %c{1} - %msg%n"/>
+        </Console>
+    </Appenders>
+    <Loggers>
+        <Root level="info" additivity="false">
+            <AppenderRef ref="console"/>
+        </Root>
+    </Loggers>
+</Configuration>
diff --git a/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/logback-test.xml b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/logback-test.xml
new file mode 100644
index 0000000..35d1b19
--- /dev/null
+++ b/surefire-its/src/test/resources/surefire-1659-stream-corruption/src/test/resources/logback-test.xml
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<configuration>
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <encoder>
+            <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
+        </encoder>
+    </appender>
+    <root level="INFO">
+        <appender-ref ref="STDOUT"/>
+    </root>
+</configuration>
diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
index fef72e6..10a5dfe 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
@@ -61,7 +61,6 @@ import org.junit.platform.launcher.Launcher;
 import org.junit.platform.launcher.LauncherDiscoveryRequest;
 import org.junit.platform.launcher.TagFilter;
 import org.junit.platform.launcher.core.LauncherDiscoveryRequestBuilder;
-import org.junit.platform.launcher.core.LauncherFactory;
 
 /**
  * JUnit 5 Platform Provider.
@@ -83,7 +82,7 @@ public class JUnitPlatformProvider
 
     public JUnitPlatformProvider( ProviderParameters parameters )
     {
-        this( parameters, LauncherFactory.create() );
+        this( parameters, new LazyLauncher() );
     }
 
     JUnitPlatformProvider( ProviderParameters parameters, Launcher launcher )
diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
new file mode 100644
index 0000000..c057c32
--- /dev/null
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/LazyLauncher.java
@@ -0,0 +1,70 @@
+package org.apache.maven.surefire.junitplatform;
+
+/*
+ * 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.junit.platform.launcher.Launcher;
+import org.junit.platform.launcher.LauncherDiscoveryRequest;
+import org.junit.platform.launcher.TestExecutionListener;
+import org.junit.platform.launcher.TestPlan;
+import org.junit.platform.launcher.core.LauncherFactory;
+
+/**
+ * Launcher proxy which delays the most possible the initialization of the real JUnit
+ * Launcher in order to avoid stream/stdout corruption due to early logging.
+ */
+class LazyLauncher implements Launcher
+{
+
+    private Launcher launcher;
+
+    @Override
+    public void registerTestExecutionListeners( TestExecutionListener... testExecutionListeners )
+    {
+        launcher().registerTestExecutionListeners( testExecutionListeners );
+    }
+
+    @Override
+    public TestPlan discover( LauncherDiscoveryRequest launcherDiscoveryRequest )
+    {
+        return launcher().discover( launcherDiscoveryRequest );
+    }
+
+    @Override
+    public void execute( LauncherDiscoveryRequest launcherDiscoveryRequest,
+                         TestExecutionListener... testExecutionListeners )
+    {
+        launcher().execute( launcherDiscoveryRequest, testExecutionListeners );
+    }
+
+    @Override
+    public void execute( TestPlan testPlan, TestExecutionListener... testExecutionListeners )
+    {
+        launcher().execute( testPlan, testExecutionListeners );
+    }
+
+    private Launcher launcher()
+    {
+        if ( launcher == null )
+        {
+            launcher = LauncherFactory.create();
+        }
+        return launcher;
+    }
+}

[maven-surefire] 04/13: [SUREFIRE-1843] - Trademarks / privacy policy footer displays broken

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit d34ebcdcde66c42a212e73b0682ef46623d48226
Author: Michael Boyles <mi...@hotmail.co.uk>
AuthorDate: Wed Sep 23 00:17:58 2020 +0100

    [SUREFIRE-1843] - Trademarks / privacy policy footer displays broken
    
    (cherry picked from commit 51e04414c3e66835b470c4566b78272b4d5a0c74)
---
 src/site/site.xml | 7 +------
 1 file changed, 1 insertion(+), 6 deletions(-)

diff --git a/src/site/site.xml b/src/site/site.xml
index 447f71b..11d869a 100644
--- a/src/site/site.xml
+++ b/src/site/site.xml
@@ -64,12 +64,7 @@
     
     <footer>
 		<![CDATA[
-		<div class="row pull-left">
-		  <p>Apache ${project.name}, ${project.name}, Apache, the Apache feather logo, and the Apache ${project.name} project logos are trademarks of The Apache Software Foundation.</p>
-		</div>
-		<div class="row pull-left">
-		  <a href="${project.url}privacy-policy.html">Privacy Policy</a>
-        </div>
+		  <p>Apache ${project.name}, ${project.name}, Apache, the Apache feather logo, and the Apache ${project.name} project logos are trademarks of The Apache Software Foundation. <a href="${project.url}privacy-policy.html">Privacy Policy</a></p>
         ]]>
     </footer>
   </body>

[maven-surefire] 01/13: [SUREFIRE-1890] Support TestNG 7.4.0

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 89ae7ef78a0ec9c15a299d3b4c4f9aaf8eeb1a58
Author: Joe Barnett <jb...@tribedynamics.com>
AuthorDate: Mon Mar 1 09:39:12 2021 -0800

    [SUREFIRE-1890] Support TestNG 7.4.0
    
    Use reflection to configure parallel arguments,
    as the setParallel(String) method has been removed
    and the enum equivalent doesn't exist in older
    TestNG versions.  Add an integration test that
    runs a simple do-nothing test with TestNG 7.4.0
    and parallel setting of `methods`.
    
    (cherry picked from commit ce59346769bffc5d9c049d4727de1bb59f0fd5ca)
---
 .../plugin/surefire/AbstractSurefireMojo.java      |  9 ++-
 .../surefire/its/CheckTestNg740ParallelIT.java     | 40 ++++++++++++
 .../src/test/resources/testng-740-parallel/pom.xml | 74 ++++++++++++++++++++++
 .../test/java/testng740/TestNG740ParallelTest.java | 35 ++++++++++
 .../testng/conf/TestNG740Configurator.java         | 69 ++++++++++++++++++++
 5 files changed, 225 insertions(+), 2 deletions(-)

diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
index 9c08399..2e916d8 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/AbstractSurefireMojo.java
@@ -567,7 +567,7 @@ public abstract class AbstractSurefireMojo
     /**
      * (TestNG provider) When you use the parameter {@code parallel}, TestNG will try to run all your test methods
      * in separate threads, except for methods that depend on each other, which will be run in the same thread in order
-     * to respect their order of execution.
+     * to respect their order of execution.  Supports two values: {@code classes} or {@code methods}.
      * <br>
      * (JUnit 4.7 provider) Supports values {@code classes}, {@code methods}, {@code both} to run
      * in separate threads been controlled by {@code threadCount}.
@@ -1346,11 +1346,16 @@ public abstract class AbstractSurefireMojo
                 }
                 return "org.apache.maven.surefire.testng.conf.TestNG5143Configurator";
             }
-            range = VersionRange.createFromVersionSpec( "[6.0,)" );
+            range = VersionRange.createFromVersionSpec( "[6.0,7.4.0)" );
             if ( range.containsVersion( version ) )
             {
                 return "org.apache.maven.surefire.testng.conf.TestNG60Configurator";
             }
+            range = VersionRange.createFromVersionSpec( "[7.4.0,)" );
+            if ( range.containsVersion( version ) )
+            {
+                return "org.apache.maven.surefire.testng.conf.TestNG740Configurator";
+            }
 
             throw new MojoExecutionException( "Unknown TestNG version " + version );
         }
diff --git a/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java
new file mode 100644
index 0000000..ac85d62
--- /dev/null
+++ b/surefire-its/src/test/java/org/apache/maven/surefire/its/CheckTestNg740ParallelIT.java
@@ -0,0 +1,40 @@
+package org.apache.maven.surefire.its;
+
+/*
+ * 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.surefire.its.fixture.SurefireJUnit4IntegrationTestCase;
+import org.junit.Test;
+
+import static org.apache.maven.surefire.its.fixture.HelperAssertions.assumeJavaVersion;
+
+/**
+ */
+public class CheckTestNg740ParallelIT
+    extends SurefireJUnit4IntegrationTestCase
+{
+    @Test
+    public void withTestNG740AndParallelSet()
+    {
+        assumeJavaVersion( 1.8 );
+        unpack( "testng-740-parallel" )
+            .executeTest()
+            .assertTestSuiteResults( 2, 0, 0, 0 );
+    }
+}
diff --git a/surefire-its/src/test/resources/testng-740-parallel/pom.xml b/surefire-its/src/test/resources/testng-740-parallel/pom.xml
new file mode 100644
index 0000000..fa02e67
--- /dev/null
+++ b/surefire-its/src/test/resources/testng-740-parallel/pom.xml
@@ -0,0 +1,74 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.apache.maven.plugins.surefire</groupId>
+    <artifactId>testng-740-parallel</artifactId>
+    <version>1.0-SNAPSHOT</version>
+    <name>TestNG 7.4.0 parallel test</name>
+
+    <properties>
+        <surefire.testng.verbose>0</surefire.testng.verbose>
+        <argLine/>
+        <jacoco.agent/>
+        <maven.compiler.source>1.7</maven.compiler.source>
+        <maven.compiler.target>1.7</maven.compiler.target>
+    </properties>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-surefire-plugin</artifactId>
+                <version>${surefire.version}</version>
+                <configuration>
+                    <argLine>${argLine} ${jacoco.agent}</argLine>
+                    <parallel>methods</parallel>
+                    <threadCount>10</threadCount>
+                    <properties>
+                        <property>
+                            <name>surefire.testng.verbose</name>
+                            <value>${surefire.testng.verbose}</value>
+                        </property>
+                    </properties>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    <dependencies>
+        <dependency>
+            <groupId>org.testng</groupId>
+            <artifactId>testng</artifactId>
+            <version>7.4.0</version>
+            <exclusions>
+                <exclusion>
+                    <!-- NOTE: Deliberaty excluding junit to enforce TestNG only tests, cf. SUREFIRE-642 -->
+                    <groupId>junit</groupId>
+                    <artifactId>junit</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+</project>
diff --git a/surefire-its/src/test/resources/testng-740-parallel/src/test/java/testng740/TestNG740ParallelTest.java b/surefire-its/src/test/resources/testng-740-parallel/src/test/java/testng740/TestNG740ParallelTest.java
new file mode 100644
index 0000000..855b92f
--- /dev/null
+++ b/surefire-its/src/test/resources/testng-740-parallel/src/test/java/testng740/TestNG740ParallelTest.java
@@ -0,0 +1,35 @@
+package testng.simple;
+
+/*
+ * 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.testng.annotations.Test;
+
+
+public class TestNG740ParallelTest {
+    @Test
+    public void testOne() {
+
+    }
+
+    @Test
+    public void testTwo() {
+
+    }
+}
diff --git a/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java
new file mode 100644
index 0000000..b2b7aa7
--- /dev/null
+++ b/surefire-providers/surefire-testng/src/main/java/org/apache/maven/surefire/testng/conf/TestNG740Configurator.java
@@ -0,0 +1,69 @@
+package org.apache.maven.surefire.testng.conf;
+
+/*
+ * 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.surefire.testset.TestSetFailedException;
+import org.apache.maven.surefire.util.ReflectionUtils;
+import org.testng.xml.XmlSuite;
+
+import java.util.Map;
+
+import static java.lang.Integer.parseInt;
+import static org.apache.maven.surefire.booter.ProviderParameterNames.PARALLEL_PROP;
+import static org.apache.maven.surefire.booter.ProviderParameterNames.THREADCOUNT_PROP;
+
+/**
+ * TestNG 7.4.0 configurator. Changed setParallel type to enum value.
+ * Uses reflection since ParallelMode enum doesn't exist in supported
+ * TestNG 5.x versions.
+ *
+ * @since 2.22.3
+ */
+public class TestNG740Configurator extends TestNG60Configurator
+{
+    @Override
+    public void configure( XmlSuite suite, Map<String, String> options )
+        throws TestSetFailedException
+    {
+        String threadCountAsString = options.get( THREADCOUNT_PROP );
+        int threadCount = threadCountAsString == null ? 1 : parseInt( threadCountAsString );
+        suite.setThreadCount( threadCount );
+
+        String parallel = options.get( PARALLEL_PROP );
+        if ( parallel != null )
+        {
+            if ( !"methods".equalsIgnoreCase( parallel ) && !"classes".equalsIgnoreCase( parallel ) )
+            {
+                throw new TestSetFailedException( "Unsupported TestNG parallel setting: "
+                    + parallel + " ( only METHODS or CLASSES supported )" );
+            }
+            Class enumClass = ReflectionUtils.tryLoadClass( XmlSuite.class.getClassLoader(),
+                "org.testng.xml.XmlSuite$ParallelMode" );
+            Object parallelEnum = Enum.valueOf( enumClass, parallel.toUpperCase() );
+            ReflectionUtils.invokeSetter( suite, "setParallel", enumClass, parallelEnum );
+        }
+
+        String dataProviderThreadCount = options.get( "dataproviderthreadcount" );
+        if ( dataProviderThreadCount != null )
+        {
+            suite.setDataProviderThreadCount( Integer.parseInt( dataProviderThreadCount ) );
+        }
+    }
+}

[maven-surefire] 08/13: [SUREFIRE-1842] - NPE at end of successful test run

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 547cec7490535ff10880746a6894896b4d90b313
Author: tibordigana <ti...@apache.org>
AuthorDate: Wed Sep 23 03:38:43 2020 +0200

    [SUREFIRE-1842] - NPE at end of successful test run
    
    (cherry picked from commit aef6573be8a31f8235786517405b49a6c1ef89c5)
---
 .../java/org/apache/maven/surefire/booter/BaseProviderFactory.java     | 3 +--
 .../test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java | 3 +++
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
index 2b329ee..4df2c28 100644
--- a/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
+++ b/surefire-api/src/main/java/org/apache/maven/surefire/booter/BaseProviderFactory.java
@@ -111,8 +111,7 @@ public class BaseProviderFactory
     @Override
     public RunOrderCalculator getRunOrderCalculator()
     {
-        return directoryScannerParameters == null
-                ? null : new DefaultRunOrderCalculator( runOrderParameters, getThreadCount() );
+        return new DefaultRunOrderCalculator( runOrderParameters, getThreadCount() );
     }
 
     @Override
diff --git a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java
index bf6cafc..a970c6b 100644
--- a/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java
+++ b/surefire-providers/surefire-junit4/src/test/java/org/apache/maven/surefire/junit4/JUnit4ProviderTest.java
@@ -21,9 +21,11 @@ package org.apache.maven.surefire.junit4;
 
 import junit.framework.TestCase;
 import org.apache.maven.surefire.booter.BaseProviderFactory;
+import org.apache.maven.surefire.testset.RunOrderParameters;
 import org.apache.maven.surefire.testset.TestRequest;
 import org.junit.runner.Description;
 
+import java.io.File;
 import java.util.HashMap;
 
 import static java.util.Arrays.asList;
@@ -48,6 +50,7 @@ public class JUnit4ProviderTest
         providerParameters.setProviderProperties( new HashMap<String, String>() );
         providerParameters.setClassLoaders( getClass().getClassLoader() );
         providerParameters.setTestRequest( new TestRequest( null, null, null ) );
+        providerParameters.setRunOrderParameters( new RunOrderParameters( "hourly", new File( "" ) ) );
         return new JUnit4Provider( providerParameters );
     }
 

[maven-surefire] 12/13: setupJunitLogger() should be called AFTER startCapture()

Posted by ti...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

tibordigana pushed a commit to branch release/2.22.3
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit 985649aa40cd757385bf45007a3d2134025fb4e8
Author: Tibor Digaňa <ti...@apache.org>
AuthorDate: Sun Jan 23 20:33:58 2022 +0100

    setupJunitLogger() should be called AFTER startCapture()
---
 .../maven/surefire/junitplatform/JUnitPlatformProvider.java   | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
index 10a5dfe..63d65c1 100644
--- a/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
+++ b/surefire-providers/surefire-junit-platform/src/main/java/org/apache/maven/surefire/junitplatform/JUnitPlatformProvider.java
@@ -91,7 +91,6 @@ public class JUnitPlatformProvider
         this.launcher = launcher;
         filters = newFilters();
         configurationParameters = newConfigurationParameters();
-        Logger.getLogger( "org.junit" ).setLevel( WARNING );
     }
 
     @Override
@@ -110,6 +109,7 @@ public class JUnitPlatformProvider
         {
             RunListener runListener = reporterFactory.createReporter();
             startCapture( ( ConsoleOutputReceiver ) runListener );
+            setupJunitLogger();
             if ( forkTestSet instanceof TestsToRun )
             {
                 invokeAllTests( (TestsToRun) forkTestSet, runListener );
@@ -135,6 +135,15 @@ public class JUnitPlatformProvider
         return runResult;
     }
 
+    private static void setupJunitLogger()
+    {
+        Logger logger = Logger.getLogger( "org.junit" );
+        if ( logger.getLevel() == null )
+        {
+            logger.setLevel( WARNING );
+        }
+    }
+
     private TestsToRun scanClasspath()
     {
         TestPlanScannerFilter filter = new TestPlanScannerFilter( launcher, filters );