You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@seatunnel.apache.org by ki...@apache.org on 2022/04/07 06:02:00 UTC

[incubator-seatunnel] branch dev updated: [Bug] [UT] CompleteTest#testVariables failed due to system property not set (#1668)

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

kirs pushed a commit to branch dev
in repository https://gitbox.apache.org/repos/asf/incubator-seatunnel.git


The following commit(s) were added to refs/heads/dev by this push:
     new 1b0da1c7 [Bug] [UT] CompleteTest#testVariables failed due to system property not set (#1668)
1b0da1c7 is described below

commit 1b0da1c7d5c50e7b8c000e0aef26024a6a7db4a2
Author: Wenjun Ruan <we...@apache.org>
AuthorDate: Thu Apr 7 14:01:55 2022 +0800

    [Bug] [UT] CompleteTest#testVariables failed due to system property not set (#1668)
---
 .github/PULL_REQUEST_TEMPLATE.md                           |  2 +-
 .../java/org/apache/seatunnel/config/CompleteTest.java     | 14 +++++++++-----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md
index 5a718844..52a63326 100644
--- a/.github/PULL_REQUEST_TEMPLATE.md
+++ b/.github/PULL_REQUEST_TEMPLATE.md
@@ -23,6 +23,6 @@ Feel free to ping committers for the review!
 ## Check list
 
 * [ ] Code changed are covered with tests, or it does not need tests for reason:
-* [ ] If any new Jar binary package adding in you PR, please add License Notice according
+* [ ] If any new Jar binary package adding in your PR, please add License Notice according
   [New License Guide](https://github.com/apache/incubator-seatunnel/blob/dev/docs/en/development/new-license.md)
 * [ ] If necessary, please update the documentation to describe the new feature. https://github.com/apache/incubator-seatunnel/tree/dev/docs
diff --git a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java
index 88b26b9b..0528aa3c 100644
--- a/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java
+++ b/seatunnel-config/seatunnel-config-shade/src/test/java/org/apache/seatunnel/config/CompleteTest.java
@@ -26,18 +26,22 @@ import org.apache.seatunnel.shade.com.typesafe.config.ConfigResolveOptions;
 import org.junit.Assert;
 import org.junit.Test;
 
+import java.util.HashMap;
+import java.util.Map;
+
 public class CompleteTest {
 
     @Test
     public void testVariables() {
-
-        System.setProperty("dt", "20190318");
-        System.setProperty("city2", "shanghai");
+        // We use a map to mock the system property, since the system property will be only loaded once
+        // after the test is run. see Issue #1670
+        Map<String, String> systemProperties = new HashMap<>();
+        systemProperties.put("dt", "20190318");
+        systemProperties.put("city2", "shanghai");
 
         Config config = ConfigFactory
             .parseFile(FileUtils.getFileFromResources("seatunnel/variables.conf"))
-            .resolveWith(ConfigFactory.systemProperties(), ConfigResolveOptions.defaults().setAllowUnresolved(true));
-
+            .resolveWith(ConfigFactory.parseMap(systemProperties), ConfigResolveOptions.defaults().setAllowUnresolved(true));
         String sql1 = config.getConfigList("transform").get(1).getString("sql");
         String sql2 = config.getConfigList("transform").get(2).getString("sql");