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 2014/10/16 18:26:52 UTC
git commit: [SUREFIRE-963] Unable to set empty environment variables
Repository: maven-surefire
Updated Branches:
refs/heads/master 4df651657 -> 3fd14a9bf
[SUREFIRE-963] Unable to set empty environment variables
Fix SUREFIRE-963
Unit test about env variable values completed with the use case of an
env varaible not defined
Apply the maven code style to the previous modifications
Project: http://git-wip-us.apache.org/repos/asf/maven-surefire/repo
Commit: http://git-wip-us.apache.org/repos/asf/maven-surefire/commit/3fd14a9b
Tree: http://git-wip-us.apache.org/repos/asf/maven-surefire/tree/3fd14a9b
Diff: http://git-wip-us.apache.org/repos/asf/maven-surefire/diff/3fd14a9b
Branch: refs/heads/master
Commit: 3fd14a9bf2cb5be28f7b8b0d51f89620f958908f
Parents: 4df6516
Author: cdeneux <ch...@gmail.com>
Authored: Wed Oct 8 14:13:27 2014 +0200
Committer: tibordigana <ti...@lycos.com>
Committed: Thu Oct 16 17:48:06 2014 +0200
----------------------------------------------------------------------
.../booterclient/ForkConfiguration.java | 2 +-
.../maven/surefire/EnvironmentVariablesIT.java | 47 ++++++++++++++++++++
.../jiras/Surefire763EnvironmentForkModeIT.java | 45 -------------------
.../resources/environment-variables/pom.xml | 2 +
.../src/test/java/environment/BasicTest.java | 5 +++
5 files changed, 55 insertions(+), 46 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3fd14a9b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
----------------------------------------------------------------------
diff --git a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
index ca9bff1..d468c37 100644
--- a/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
+++ b/maven-surefire-common/src/main/java/org/apache/maven/plugin/surefire/booterclient/ForkConfiguration.java
@@ -161,7 +161,7 @@ public class ForkConfiguration
{
String value = environmentVariables.get( key );
- cli.addEnvironment( key, value );
+ cli.addEnvironment( key, value == null ? "" : value );
}
}
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3fd14a9b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/EnvironmentVariablesIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/EnvironmentVariablesIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/EnvironmentVariablesIT.java
new file mode 100644
index 0000000..a8a346b
--- /dev/null
+++ b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/EnvironmentVariablesIT.java
@@ -0,0 +1,47 @@
+package org.apache.maven.surefire;
+
+/*
+ * 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;
+
+/**
+ * SUREFIRE-763 Asserts that environment variables are correctly populated using "useSystemClassLoader=false"
+ * SUREFIRE-963 Asserts that empty environment variables are read as "".
+ *
+ * @author Kristian Rosenvold
+ * @author Christophe Deneux
+ */
+public class EnvironmentVariablesIT
+ extends SurefireJUnit4IntegrationTestCase
+{
+ @Test
+ public void testWhenUseSystemClassLoader()
+ {
+ unpack( "/environment-variables" ).addGoal( "-DuseSystemClassLoader=true" ).executeTest();
+ }
+
+ @Test
+ public void testWhenDontUseSystemClassLoader()
+ {
+ unpack( "/environment-variables" ).addGoal( "-DuseSystemClassLoader=false" ).executeTest();
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3fd14a9b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire763EnvironmentForkModeIT.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire763EnvironmentForkModeIT.java b/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire763EnvironmentForkModeIT.java
deleted file mode 100644
index 37a569c..0000000
--- a/surefire-integration-tests/src/test/java/org/apache/maven/surefire/its/jiras/Surefire763EnvironmentForkModeIT.java
+++ /dev/null
@@ -1,45 +0,0 @@
-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;
-
-/**
- * SUREFIRE-674 Asserts that the build fails when tests have errors
- *
- * @author Kristian Rosenvold
- */
-public class Surefire763EnvironmentForkModeIT
- extends SurefireJUnit4IntegrationTestCase
-{
- @Test
- public void testWhenUseSystemClassLoader()
- {
- unpack( "/environment-variables" ).addGoal( "-DuseSystemClassLoader=true" ).executeTest();
- }
-
- @Test
- public void testWhenDontUseSystemClassLoader()
- {
- unpack( "/environment-variables" ).addGoal( "-DuseSystemClassLoader=false" ).executeTest();
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3fd14a9b/surefire-integration-tests/src/test/resources/environment-variables/pom.xml
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/environment-variables/pom.xml b/surefire-integration-tests/src/test/resources/environment-variables/pom.xml
index 57c05c3..c18b3b9 100644
--- a/surefire-integration-tests/src/test/resources/environment-variables/pom.xml
+++ b/surefire-integration-tests/src/test/resources/environment-variables/pom.xml
@@ -51,6 +51,8 @@
<useSystemClassLoader>${useSystemClassLoader}</useSystemClassLoader>
<environmentVariables>
<DUMMY_ENV_VAR>foo</DUMMY_ENV_VAR>
+ <EMPTY_VAR></EMPTY_VAR>
+ <UNSET_VAR />
</environmentVariables>
</configuration>
</plugin>
http://git-wip-us.apache.org/repos/asf/maven-surefire/blob/3fd14a9b/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java
----------------------------------------------------------------------
diff --git a/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java b/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java
index 82d5449..e1a0f79 100644
--- a/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java
+++ b/surefire-integration-tests/src/test/resources/environment-variables/src/test/java/environment/BasicTest.java
@@ -19,11 +19,13 @@ package environment;
* under the License.
*/
+import org.hamcrest.core.IsNull;
import org.junit.Assert;
import org.junit.Test;
import static org.hamcrest.core.Is.is;
import static org.hamcrest.core.IsNull.notNullValue;
+import static org.hamcrest.core.IsNull.nullValue;
public class BasicTest
@@ -35,6 +37,9 @@ public class BasicTest
{
Assert.assertThat( System.getenv( "PATH" ), notNullValue() );
Assert.assertThat( System.getenv( "DUMMY_ENV_VAR" ), is( "foo" ) );
+ Assert.assertThat( System.getenv( "EMPTY_VAR" ), is( "" ) );
+ Assert.assertThat( System.getenv( "UNSET_VAR" ), is( "" ) );
+ Assert.assertThat( System.getenv( "UNDEFINED_VAR" ), nullValue() );
}