jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.java
changeset 14185 916ec0a4d039
parent 13583 dc0017b1a452
child 14765 0987999ed367
equal deleted inserted replaced
14184:5553422ece67 14185:916ec0a4d039
    43         aliasTest();
    43         aliasTest();
    44     }
    44     }
    45 
    45 
    46     void test1() {
    46     void test1() {
    47         Locale[] available = Locale.getAvailableLocales();
    47         Locale[] available = Locale.getAvailableLocales();
       
    48         List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getTimeZoneNameProvider().getAvailableLocales());
    48         List<Locale> providerLocales = Arrays.asList(tznp.getAvailableLocales());
    49         List<Locale> providerLocales = Arrays.asList(tznp.getAvailableLocales());
    49         String[] ids = TimeZone.getAvailableIDs();
    50         String[] ids = TimeZone.getAvailableIDs();
    50 
    51 
    51         for (Locale target: available) {
    52         for (Locale target: available) {
    52             // pure JRE implementation
    53             // pure JRE implementation
    53             OpenListResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getTimeZoneNames(target);
    54             OpenListResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getTimeZoneNames(target);
    54             boolean jreHasBundle = rb.getLocale().equals(target);
    55             boolean jreSupportsTarget = jreimplloc.contains(target);
    55 
    56 
    56             for (String id: ids) {
    57             for (String id: ids) {
    57                 // the time zone
    58                 // the time zone
    58                 TimeZone tz = TimeZone.getTimeZone(id);
    59                 TimeZone tz = TimeZone.getTimeZone(id);
    59 
    60 
    60                 // JRE string array for the id
    61                 // JRE string array for the id
    61                 String[] jrearray = null;
    62                 String[] jrearray = null;
    62                 if (jreHasBundle) {
    63                 if (jreSupportsTarget) {
    63                     try {
    64                     try {
    64                         jrearray = rb.getStringArray(id);
    65                         jrearray = rb.getStringArray(id);
    65                     } catch (MissingResourceException mre) {}
    66                     } catch (MissingResourceException mre) {}
    66                 }
    67                 }
    67 
    68 
    73                     String providersname = null;
    74                     String providersname = null;
    74                     if (providerLocales.contains(target)) {
    75                     if (providerLocales.contains(target)) {
    75                         providersname = tznp.getDisplayName(id, i>=3, i%2, target);
    76                         providersname = tznp.getDisplayName(id, i>=3, i%2, target);
    76                     }
    77                     }
    77 
    78 
    78                     // JRE's name (if any)
    79                     // JRE's name
    79                     String jresname = null;
    80                     String jresname = null;
    80                     if (jrearray != null) {
    81                     if (jrearray != null) {
    81                         jresname = jrearray[i];
    82                         jresname = jrearray[i];
    82                     }
    83                     }
    83 
    84 
    84                     checkValidity(target, jresname, providersname, name,
    85                     checkValidity(target, jresname, providersname, name,
    85                         jreHasBundle && rb.handleGetKeys().contains(id));
    86                         jreSupportsTarget && jresname != null);
    86                 }
    87                 }
    87             }
    88             }
    88         }
    89         }
    89     }
    90     }
    90 
    91