jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.java
changeset 14765 0987999ed367
parent 14185 916ec0a4d039
child 15260 7af2d7a87806
equal deleted inserted replaced
14764:6dd2370b4cd3 14765:0987999ed367
    38     }
    38     }
    39 
    39 
    40     TimeZoneNameProviderTest() {
    40     TimeZoneNameProviderTest() {
    41         test1();
    41         test1();
    42         test2();
    42         test2();
       
    43         test3();
    43         aliasTest();
    44         aliasTest();
    44     }
    45     }
    45 
    46 
    46     void test1() {
    47     void test1() {
    47         Locale[] available = Locale.getAvailableLocales();
    48         Locale[] available = Locale.getAvailableLocales();
    90     }
    91     }
    91 
    92 
    92     final String pattern = "z";
    93     final String pattern = "z";
    93     final Locale OSAKA = new Locale("ja", "JP", "osaka");
    94     final Locale OSAKA = new Locale("ja", "JP", "osaka");
    94     final Locale KYOTO = new Locale("ja", "JP", "kyoto");
    95     final Locale KYOTO = new Locale("ja", "JP", "kyoto");
       
    96     final Locale GENERIC = new Locale("ja", "JP", "generic");
    95 
    97 
    96     final String[] TIMEZONES = {
    98     final String[] TIMEZONES = {
    97         "GMT", "America/Los_Angeles", "SystemV/PST8",
    99         "GMT", "America/Los_Angeles", "SystemV/PST8",
    98         "SystemV/PST8PDT", "PST8PDT",
   100         "SystemV/PST8PDT", "PST8PDT",
    99     };
   101     };
   155             Locale.setDefault(defaultLocale);
   157             Locale.setDefault(defaultLocale);
   156             TimeZone.setDefault(reservedTimeZone);
   158             TimeZone.setDefault(reservedTimeZone);
   157         }
   159         }
   158     }
   160     }
   159 
   161 
       
   162     void test3() {
       
   163         final String[] TZNAMES = {
       
   164             LATIME, PST, PST8PDT, US_PACIFIC,
       
   165             TOKYOTIME, JST, JAPAN,
       
   166         };
       
   167         for (String tzname : TZNAMES) {
       
   168             TimeZone tz = TimeZone.getTimeZone(tzname);
       
   169             for (int style : new int[] { TimeZone.LONG, TimeZone.SHORT }) {
       
   170                 String osakaStd = tz.getDisplayName(false, style, OSAKA);
       
   171                 if (osakaStd != null) {
       
   172                     // No API for getting generic time zone names
       
   173                     String generic = TimeZoneNameUtility.retrieveGenericDisplayName(tzname,
       
   174                                                                                     style, GENERIC);
       
   175                     String expected = "Generic " + osakaStd;
       
   176                     if (!expected.equals(generic)) {
       
   177                         throw new RuntimeException("Wrong generic name: got=\"" + generic
       
   178                                                    + "\", expected=\"" + expected + "\"");
       
   179                     }
       
   180                 }
       
   181             }
       
   182         }
       
   183     }
       
   184 
   160     final String LATIME = "America/Los_Angeles";
   185     final String LATIME = "America/Los_Angeles";
   161     final String PST = "PST";
   186     final String PST = "PST";
   162     final String PST8PDT = "PST8PDT";
   187     final String PST8PDT = "PST8PDT";
   163     final String US_PACIFIC = "US/Pacific";
   188     final String US_PACIFIC = "US/Pacific";
   164     final String LATIME_IN_OSAKA =
   189     final String LATIME_IN_OSAKA =