test/java/util/PluggableLocale/TimeZoneNameProviderTest.java

Print this page

        

*** 38,47 **** --- 38,48 ---- } TimeZoneNameProviderTest() { test1(); test2(); + test3(); aliasTest(); } void test1() { Locale[] available = Locale.getAvailableLocales();
*** 90,99 **** --- 91,101 ---- } final String pattern = "z"; final Locale OSAKA = new Locale("ja", "JP", "osaka"); final Locale KYOTO = new Locale("ja", "JP", "kyoto"); + final Locale GENERIC = new Locale("ja", "JP", "generic"); final String[] TIMEZONES = { "GMT", "America/Los_Angeles", "SystemV/PST8", "SystemV/PST8PDT", "PST8PDT", };
*** 155,164 **** --- 157,189 ---- Locale.setDefault(defaultLocale); TimeZone.setDefault(reservedTimeZone); } } + void test3() { + final String[] TZNAMES = { + LATIME, PST, PST8PDT, US_PACIFIC, + TOKYOTIME, JST, JAPAN, + }; + for (String tzname : TZNAMES) { + TimeZone tz = TimeZone.getTimeZone(tzname); + for (int style : new int[] { TimeZone.LONG, TimeZone.SHORT }) { + String osakaStd = tz.getDisplayName(false, style, OSAKA); + if (osakaStd != null) { + // No API for getting generic time zone names + String generic = TimeZoneNameUtility.retrieveGenericDisplayName(tzname, + style, GENERIC); + String expected = "Generic " + osakaStd; + if (!expected.equals(generic)) { + throw new RuntimeException("Wrong generic name: got=\"" + generic + + "\", expected=\"" + expected + "\""); + } + } + } + } + } + final String LATIME = "America/Los_Angeles"; final String PST = "PST"; final String PST8PDT = "PST8PDT"; final String US_PACIFIC = "US/Pacific"; final String LATIME_IN_OSAKA =