You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wayang.apache.org by cd...@apache.org on 2021/02/09 12:27:16 UTC

[incubator-wayang] 01/03: - Make the test work on systems with non-US locale

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

cdutz pushed a commit to branch feature/asf-onboarding
in repository https://gitbox.apache.org/repos/asf/incubator-wayang.git

commit 334b9effc18b2cfe1731ecca11ea18099a555b3e
Author: Christofer Dutz <ch...@c-ware.de>
AuthorDate: Tue Feb 9 13:24:49 2021 +0100

    - Make the test work on systems with non-US locale
---
 .../java/operators/JavaTextFileSinkTest.java       | 23 ++++++++++++++++++++++
 1 file changed, 23 insertions(+)

diff --git a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java
index 9248bcf..502d9ef 100644
--- a/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java
+++ b/wayang-platforms/wayang-java/src/test/java/org/apache/wayang/java/operators/JavaTextFileSinkTest.java
@@ -18,7 +18,9 @@
 
 package org.apache.wayang.java.operators;
 
+import org.junit.After;
 import org.junit.Assert;
+import org.junit.Before;
 import org.junit.Test;
 import org.apache.wayang.core.api.Configuration;
 import org.apache.wayang.core.api.Job;
@@ -37,8 +39,11 @@ import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.file.Files;
 import java.nio.file.Paths;
+import java.text.DecimalFormatSymbols;
+import java.text.NumberFormat;
 import java.util.Arrays;
 import java.util.List;
+import java.util.Locale;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -50,6 +55,24 @@ import static org.mockito.Mockito.when;
  */
 public class JavaTextFileSinkTest extends JavaExecutionOperatorTestBase {
 
+    private Locale defaultLocale;
+
+    /**
+     * In locales, where the decimal separator is not "." this rest would fail.
+     * Therefore we ensure it's run in a pre-defined locale and we make sure it's
+     * reset after the test.
+     */
+    @Before
+    public void setupTest() {
+        defaultLocale = Locale.getDefault();
+        Locale.setDefault(Locale.US);
+    }
+
+    @After
+    public void teardownTest() {
+        Locale.setDefault(defaultLocale);
+    }
+
     @Test
     public void testWritingLocalFile() throws IOException, URISyntaxException {
         Configuration configuration = new Configuration();