You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rm...@apache.org on 2021/03/07 16:10:47 UTC

[maven-surefire] branch SUREFIRE-1892 created (now e3a1a7b)

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

rmannibucau pushed a change to branch SUREFIRE-1892
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git.


      at e3a1a7b  [SUREFIRE-1892] ensure systemPropertyVariables values are stringified

This branch includes the following new commits:

     new e3a1a7b  [SUREFIRE-1892] ensure systemPropertyVariables values are stringified

The 1 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.



[maven-surefire] 01/01: [SUREFIRE-1892] ensure systemPropertyVariables values are stringified

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

rmannibucau pushed a commit to branch SUREFIRE-1892
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git

commit e3a1a7bb642c1e69b6bd34c2a95820221da368c8
Author: Romain Manni-Bucau <rm...@gmail.com>
AuthorDate: Sun Mar 7 17:10:33 2021 +0100

    [SUREFIRE-1892] ensure systemPropertyVariables values are stringified
---
 .../maven/plugin/surefire/AbstractSurefireMojo.java       | 15 +++++++++++++--
 .../maven/plugin/surefire/AbstractSurefireMojoTest.java   | 10 ++++++++++
 2 files changed, 23 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 4d1af3d..ec6ff73 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
@@ -3623,9 +3623,20 @@ public abstract class AbstractSurefireMojo
     }
 
     @SuppressWarnings( "UnusedDeclaration" )
-    public void setSystemPropertyVariables( Map<String, String> systemPropertyVariables )
+    public void setSystemPropertyVariables( Map<String, ?> systemPropertyVariables )
     {
-        this.systemPropertyVariables = systemPropertyVariables;
+        if (systemPropertyVariables != null)
+        {
+            this.systemPropertyVariables = new HashMap<>();
+            for ( final Map.Entry<String, ?> entry : systemPropertyVariables.entrySet() )
+            {
+                this.systemPropertyVariables.put( entry.getKey(), String.valueOf( entry.getValue() ) );
+            }
+        }
+        else
+        {
+            this.systemPropertyVariables = null;
+        }
     }
 
     /**
diff --git a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
index 53e7fba..12a7b1b 100644
--- a/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
+++ b/maven-surefire-common/src/test/java/org/apache/maven/plugin/surefire/AbstractSurefireMojoTest.java
@@ -94,6 +94,7 @@ import static java.util.Collections.emptyMap;
 import static java.util.Collections.emptySet;
 import static java.util.Collections.singleton;
 import static java.util.Collections.singletonList;
+import static java.util.Collections.singletonMap;
 import static org.apache.maven.artifact.versioning.VersionRange.createFromVersion;
 import static org.apache.maven.artifact.versioning.VersionRange.createFromVersionSpec;
 import static org.apache.maven.surefire.shared.lang3.JavaVersion.JAVA_9;
@@ -102,6 +103,7 @@ import static org.apache.maven.surefire.shared.lang3.SystemUtils.IS_OS_WINDOWS;
 import static org.codehaus.plexus.languages.java.jpms.ModuleNameSource.MODULEDESCRIPTOR;
 import static org.fest.assertions.Assertions.assertThat;
 import static org.fest.assertions.MapAssert.entry;
+import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.fail;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.anyString;
@@ -1999,6 +2001,14 @@ public class AbstractSurefireMojoTest
         mojo.verifyParameters();
     }
 
+    @Test
+    public void shouldSupportBooleanSystemPropertiesValue()
+    {
+        AbstractSurefireMojo mojo = new Mojo();
+        mojo.setSystemPropertyVariables(singletonMap("offline", true));
+        assertEquals(singletonMap("offline", "true"), mojo.getSystemPropertyVariables());
+    }
+
     private void setProjectDepedenciesToMojo( Artifact... deps )
     {
         for ( Artifact dep : deps )