You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sis.apache.org by de...@apache.org on 2021/03/25 09:59:14 UTC

[sis] branch geoapi-4.0 updated: Fix a test which was timezone-dependent.

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

desruisseaux pushed a commit to branch geoapi-4.0
in repository https://gitbox.apache.org/repos/asf/sis.git


The following commit(s) were added to refs/heads/geoapi-4.0 by this push:
     new 80f193c  Fix a test which was timezone-dependent.
80f193c is described below

commit 80f193c163e8748d76079421949beb162d6415d1
Author: Martin Desruisseaux <ma...@geomatys.com>
AuthorDate: Thu Mar 25 10:58:50 2021 +0100

    Fix a test which was timezone-dependent.
---
 .../src/test/java/org/apache/sis/measure/RangeTest.java       | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java b/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
index d0732e3..25a7547 100644
--- a/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
+++ b/core/sis-utility/src/test/java/org/apache/sis/measure/RangeTest.java
@@ -331,9 +331,14 @@ public final strictfp class RangeTest extends TestCase {
     public void testFormatInstantTo() {
         final Range<Instant> range = new Range<>(Instant.class,
                 Instant.parse("2019-12-23T06:00:00Z"), true,
-                Instant.parse("2020-05-31T18:00:00Z"), true);
-
-        assertEquals("[23/12/2019 07:00 … 31/05/2020 20:00]", String.format(Locale.FRANCE, "%s", range));
+                Instant.parse("2020-05-14T18:00:00Z"), true);
+        /*
+         * The result depends on time zone and we have no API for forcing the time zone to some specific
+         * value in a call to 'Range.formatTo(Formatter, …)`. So we verify only the year and the month.
+         */
+        final String result = String.format(Locale.CANADA, "%s", range);
+        assertTrue(result, result.startsWith("[2019-12-"));
+        assertTrue(result, result.contains(" … 2020-05-"));
     }
 
     /**