From 6d7456ec3130ecfa4d563a09c3353aab025523d8 Mon Sep 17 00:00:00 2001 From: Virtually Nick Date: Mon, 26 Oct 2020 11:09:49 -0400 Subject: [PATCH] GUACAMOLE-760: Add JUnit tests for TimeZone getAvailableIDs. --- .../TimeZoneGuacamolePropertyTest.java | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/guacamole-ext/src/test/java/org/apache/guacamole/properties/TimeZoneGuacamolePropertyTest.java b/guacamole-ext/src/test/java/org/apache/guacamole/properties/TimeZoneGuacamolePropertyTest.java index 48535a10c..4c4ced17f 100644 --- a/guacamole-ext/src/test/java/org/apache/guacamole/properties/TimeZoneGuacamolePropertyTest.java +++ b/guacamole-ext/src/test/java/org/apache/guacamole/properties/TimeZoneGuacamolePropertyTest.java @@ -21,6 +21,7 @@ package org.apache.guacamole.properties; import java.util.Arrays; import java.util.List; +import java.util.TimeZone; import org.apache.guacamole.GuacamoleException; import static org.junit.Assert.*; import org.junit.Test; @@ -103,6 +104,12 @@ public class TimeZoneGuacamolePropertyTest { "GMT+10:65" ); + /** + * The list of all available timezones that are known to the TimeZone class. + */ + private static final List TZ_AVAIL_IDS = + Arrays.asList(TimeZone.getAvailableIDs()); + /** * An example TimeZoneGuacamoleProperty for testing how various possible * TimeZone values will be parsed. @@ -217,6 +224,23 @@ public class TimeZoneGuacamolePropertyTest { }); } + /** + * Tests the list of available identifiers provided by the TimeZone class + * to make sure that all identifiers provided pass through successfully and + * do not yield unexpected results. + * + * @throws GuacamoleException + * If the test fails unexpectedly because the timezone is not recognized + * and is converted to GMT. + */ + public void availTzCheck() throws GuacamoleException { + for (String tzStr : TZ_AVAIL_IDS) { + String tzId = WHERE_IN_WORLD.parseValue(tzStr).getID(); + assertNotNull(tzId); + assertTrue(tzId.equals(tzStr)); + } + } + /** * Tests parse of null input values to make sure the resuling parsed value * is also null.