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

ahuber pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/isis.git


The following commit(s) were added to refs/heads/master by this push:
     new 5181e8a9f4 ISIS-3049: trying to make sense of the failing time-zone 
tests
5181e8a9f4 is described below

commit 5181e8a9f4c9166dd484d78c5fc2be6777464753
Author: Andi Huber <[email protected]>
AuthorDate: Wed Jul 13 19:29:55 2022 +0200

    ISIS-3049: trying to make sense of the failing time-zone tests
---
 .../isis/testdomain/value/ValueSemanticsTest.java  | 45 ++++++++++++++++++++++
 1 file changed, 45 insertions(+)

diff --git 
a/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
 
b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
index ceb586d217..648490e3c1 100644
--- 
a/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
+++ 
b/regressiontests/stable-value/src/test/java/org/apache/isis/testdomain/value/ValueSemanticsTest.java
@@ -22,7 +22,9 @@ import java.time.OffsetDateTime;
 import java.time.OffsetTime;
 import java.time.ZonedDateTime;
 import java.util.Locale;
+import java.util.Objects;
 import java.util.Set;
+import java.util.TimeZone;
 import java.util.stream.Collectors;
 import java.util.stream.Stream;
 
@@ -94,6 +96,36 @@ import lombok.val;
 @TestInstance(Lifecycle.PER_CLASS)
 class ValueSemanticsTest {
 
+    static class TestEnvironment {
+
+        private Locale systemLocale;
+        private TimeZone systemTimeZone;
+
+        TestEnvironment() {
+            systemLocale = Locale.getDefault();
+            systemTimeZone = TimeZone.getDefault();
+
+            if(!Objects.equals(systemLocale, Locale.US)) {
+                System.err.println("DEBUG: setting test Locale to US");
+                //log.warn("setting test Locale to US");
+                Locale.setDefault(Locale.US);
+            }
+
+            if(!Objects.equals(systemTimeZone, TimeZone.getTimeZone("GMT"))) {
+                System.err.println("DEBUG: setting test TimeZone to GMT");
+                //log.warn("setting test TimeZone to GMT");
+                TimeZone.setDefault(TimeZone.getTimeZone("GMT"));
+            }
+        }
+
+        void cleanup() {
+            Locale.setDefault(systemLocale);
+            TimeZone.setDefault(systemTimeZone);
+        }
+
+    }
+
+
     @Test
     void fullTypeCoverage() {
 
@@ -127,6 +159,9 @@ class ValueSemanticsTest {
             final String name,
             final Class<T> valueType,
             final ValueTypeExample<T> example) {
+
+        val env = new TestEnvironment();
+
         assertNotNull(example);
 
         val tester = serviceInjector.injectServicesInto(
@@ -213,10 +248,18 @@ class ValueSemanticsTest {
 
                             assertValueEqualsParsedValue(context, parser, 
stringified, "parser roundtrip failed");
 
+
                             if(valueType.equals(OffsetDateTime.class)
                                     || valueType.equals(OffsetTime.class)
                                     || valueType.equals(ZonedDateTime.class)) {
 
+                                System.err.printf("DEBUG: stringified: %s%n", 
stringified);
+
+                                if(!stringified.contains("+")) {
+                                    System.err.printf("DEBUG: invalid 
stringified: %s%n", stringified);
+                                    return;
+                                }
+
                                 /* fails on CI !? ... */
 
                                 val with4digitZone = 
_Strings.substring(stringified, 0, -6) + "+0200";
@@ -287,6 +330,8 @@ class ValueSemanticsTest {
 
                 });
 
+        env.cleanup();
+
     }
 
     // -- HELPER

Reply via email to