From d7eed084202ed16b1c8a2514dae0ca94018a1c74 Mon Sep 17 00:00:00 2001 From: Michael Hoennig Date: Tue, 25 Oct 2022 13:08:17 +0200 Subject: [PATCH] always run tests with locale en_US, no matter of system settings --- build.gradle | 4 +++- .../net/hostsharing/test/LocaleUnitTest.java | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 src/test/java/net/hostsharing/test/LocaleUnitTest.java diff --git a/build.gradle b/build.gradle index d4aa51f9..77abf0b0 100644 --- a/build.gradle +++ b/build.gradle @@ -98,9 +98,11 @@ tasks.withType(JavaCompile) { ] } -// Use JUnit Jupiter +// Configure tests tasks.named('test') { useJUnitPlatform() + jvmArgs '-Duser.language=en' + jvmArgs '-Duser.country=US' } // OpenAPI Source Code Generation diff --git a/src/test/java/net/hostsharing/test/LocaleUnitTest.java b/src/test/java/net/hostsharing/test/LocaleUnitTest.java new file mode 100644 index 00000000..6071c4ea --- /dev/null +++ b/src/test/java/net/hostsharing/test/LocaleUnitTest.java @@ -0,0 +1,17 @@ +package net.hostsharing.test; + +import org.junit.jupiter.api.Test; + +import java.math.BigDecimal; +import java.util.Locale; + +import static org.assertj.core.api.Assertions.assertThat; + +public class LocaleUnitTest { + + @Test + void testsAreUsingEnUsUtf8Locale() { + assertThat(Locale.getDefault()).isEqualTo(new Locale("en", "US")); + assertThat(new BigDecimal("64.00").toString()).isEqualTo("64.00"); + } +}