jdk/test/java/util/PluggableLocale/TimeZoneNameProviderTest.java
author okutsu
Mon, 10 Dec 2012 10:52:11 +0900
changeset 14765 0987999ed367
parent 14185 916ec0a4d039
child 15260 7af2d7a87806
permissions -rw-r--r--
8000983: Support narrow display names for calendar fields 8003267: Support generic time zone names in TimeZoneNameProvider (SPI) Reviewed-by: naoto
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10138
diff changeset
     2
 * Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2
diff changeset
    21
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
import java.text.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
import java.util.*;
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10138
diff changeset
    29
import sun.util.locale.provider.*;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
import sun.util.resources.*;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
public class TimeZoneNameProviderTest extends ProviderTest {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
    com.bar.TimeZoneNameProviderImpl tznp = new com.bar.TimeZoneNameProviderImpl();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
    public static void main(String[] s) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
        new TimeZoneNameProviderTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    TimeZoneNameProviderTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
        test1();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
        test2();
14765
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
    43
        test3();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
        aliasTest();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    void test1() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
        Locale[] available = Locale.getAvailableLocales();
14185
916ec0a4d039 8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents: 13583
diff changeset
    49
        List<Locale> jreimplloc = Arrays.asList(LocaleProviderAdapter.forJRE().getTimeZoneNameProvider().getAvailableLocales());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
        List<Locale> providerLocales = Arrays.asList(tznp.getAvailableLocales());
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
        String[] ids = TimeZone.getAvailableIDs();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
        for (Locale target: available) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
            // pure JRE implementation
13583
dc0017b1a452 6336885: RFE: Locale Data Deployment Enhancements
naoto
parents: 10138
diff changeset
    55
            OpenListResourceBundle rb = LocaleProviderAdapter.forJRE().getLocaleData().getTimeZoneNames(target);
14185
916ec0a4d039 8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents: 13583
diff changeset
    56
            boolean jreSupportsTarget = jreimplloc.contains(target);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
            for (String id: ids) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
                // the time zone
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
                TimeZone tz = TimeZone.getTimeZone(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
                // JRE string array for the id
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
                String[] jrearray = null;
14185
916ec0a4d039 8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents: 13583
diff changeset
    64
                if (jreSupportsTarget) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
                    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
                        jrearray = rb.getStringArray(id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
                    } catch (MissingResourceException mre) {}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
                for (int i = 1; i <=(tz.useDaylightTime()?4:2); i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
                    // the localized name
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
                    String name = tz.getDisplayName(i>=3, i%2, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                    // provider's name (if any)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                    String providersname = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
                    if (providerLocales.contains(target)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
                        providersname = tznp.getDisplayName(id, i>=3, i%2, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
14185
916ec0a4d039 8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents: 13583
diff changeset
    80
                    // JRE's name
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
                    String jresname = null;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
                    if (jrearray != null) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
                        jresname = jrearray[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
                    checkValidity(target, jresname, providersname, name,
14185
916ec0a4d039 8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents: 13583
diff changeset
    87
                        jreSupportsTarget && jresname != null);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    final String pattern = "z";
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    final Locale OSAKA = new Locale("ja", "JP", "osaka");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    final Locale KYOTO = new Locale("ja", "JP", "kyoto");
14765
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
    96
    final Locale GENERIC = new Locale("ja", "JP", "generic");
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    final String[] TIMEZONES = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        "GMT", "America/Los_Angeles", "SystemV/PST8",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
        "SystemV/PST8PDT", "PST8PDT",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    final String[] DISPLAY_NAMES_OSAKA = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        tznp.getDisplayName(TIMEZONES[0], false, TimeZone.SHORT, OSAKA),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        tznp.getDisplayName(TIMEZONES[1], false, TimeZone.SHORT, OSAKA),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
        tznp.getDisplayName(TIMEZONES[2], false, TimeZone.SHORT, OSAKA),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
        tznp.getDisplayName(TIMEZONES[3], false, TimeZone.SHORT, OSAKA),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
        tznp.getDisplayName(TIMEZONES[4], false, TimeZone.SHORT, OSAKA)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    final String[] DISPLAY_NAMES_KYOTO = {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
        tznp.getDisplayName(TIMEZONES[0], false, TimeZone.SHORT, KYOTO),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
        tznp.getDisplayName(TIMEZONES[1], false, TimeZone.SHORT, KYOTO),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
        tznp.getDisplayName(TIMEZONES[2], false, TimeZone.SHORT, KYOTO),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
        tznp.getDisplayName(TIMEZONES[3], false, TimeZone.SHORT, KYOTO),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
        tznp.getDisplayName(TIMEZONES[4], false, TimeZone.SHORT, KYOTO)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
    void test2() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
        Locale defaultLocale = Locale.getDefault();
10138
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
   119
        TimeZone reservedTimeZone = TimeZone.getDefault();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
        Date d = new Date(2005-1900, Calendar.DECEMBER, 22);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
        String formatted;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
        TimeZone tz;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
        SimpleDateFormat df;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
            for (int i = 0; i < TIMEZONES.length; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
                tz = TimeZone.getTimeZone(TIMEZONES[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                TimeZone.setDefault(tz);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
                df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance(OSAKA));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                Locale.setDefault(defaultLocale);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                System.out.println(formatted = df.format(d));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                if(!formatted.equals(DISPLAY_NAMES_OSAKA[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    throw new RuntimeException("TimeZone " + TIMEZONES[i] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                        ": formatted zone names mismatch. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                        formatted + " should match with " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                        DISPLAY_NAMES_OSAKA[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                df.parse(DISPLAY_NAMES_OSAKA[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
                Locale.setDefault(KYOTO);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
                df = new SimpleDateFormat(pattern, DateFormatSymbols.getInstance());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
                System.out.println(formatted = df.format(d));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
                if(!formatted.equals(DISPLAY_NAMES_KYOTO[i])) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
                    throw new RuntimeException("Timezone " + TIMEZONES[i] +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
                        ": formatted zone names mismatch. " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
                        formatted + " should match with " +
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
                        DISPLAY_NAMES_KYOTO[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
                df.parse(DISPLAY_NAMES_KYOTO[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
        } catch (ParseException pe) {
10138
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
   154
            throw new RuntimeException("parse error occured" + pe);
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
   155
        } finally {
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
   156
            // restore the reserved locale and time zone
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
            Locale.setDefault(defaultLocale);
10138
b7572da25d15 7068662: Reserve and restore the default locale
xuelei
parents: 5506
diff changeset
   158
            TimeZone.setDefault(reservedTimeZone);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
14765
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   162
    void test3() {
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   163
        final String[] TZNAMES = {
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   164
            LATIME, PST, PST8PDT, US_PACIFIC,
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   165
            TOKYOTIME, JST, JAPAN,
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   166
        };
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   167
        for (String tzname : TZNAMES) {
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   168
            TimeZone tz = TimeZone.getTimeZone(tzname);
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   169
            for (int style : new int[] { TimeZone.LONG, TimeZone.SHORT }) {
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   170
                String osakaStd = tz.getDisplayName(false, style, OSAKA);
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   171
                if (osakaStd != null) {
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   172
                    // No API for getting generic time zone names
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   173
                    String generic = TimeZoneNameUtility.retrieveGenericDisplayName(tzname,
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   174
                                                                                    style, GENERIC);
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   175
                    String expected = "Generic " + osakaStd;
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   176
                    if (!expected.equals(generic)) {
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   177
                        throw new RuntimeException("Wrong generic name: got=\"" + generic
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   178
                                                   + "\", expected=\"" + expected + "\"");
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   179
                    }
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   180
                }
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   181
            }
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   182
        }
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   183
    }
0987999ed367 8000983: Support narrow display names for calendar fields
okutsu
parents: 14185
diff changeset
   184
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
    final String LATIME = "America/Los_Angeles";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
    final String PST = "PST";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    final String PST8PDT = "PST8PDT";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
    final String US_PACIFIC = "US/Pacific";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    final String LATIME_IN_OSAKA =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
        tznp.getDisplayName(LATIME, false, TimeZone.LONG, OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    final String TOKYOTIME = "Asia/Tokyo";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    final String JST = "JST";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    final String JAPAN = "Japan";
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
    final String JST_IN_OSAKA =
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
        tznp.getDisplayName(JST, false, TimeZone.LONG, OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    void aliasTest() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
        // Check that provider's name for a standard id (America/Los_Angeles) is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
        // propagated to its aliases
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
        String latime = TimeZone.getTimeZone(LATIME).getDisplayName(OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
        if (!LATIME_IN_OSAKA.equals(latime)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
            throw new RuntimeException("Could not get provider's localized name.  result: "+latime+" expected: "+LATIME_IN_OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
        String pst = TimeZone.getTimeZone(PST).getDisplayName(OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
        if (!LATIME_IN_OSAKA.equals(pst)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
            throw new RuntimeException("Provider's localized name is not available for an alias ID: "+PST+".  result: "+pst+" expected: "+LATIME_IN_OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
        String us_pacific = TimeZone.getTimeZone(US_PACIFIC).getDisplayName(OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
        if (!LATIME_IN_OSAKA.equals(us_pacific)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
            throw new RuntimeException("Provider's localized name is not available for an alias ID: "+US_PACIFIC+".  result: "+us_pacific+" expected: "+LATIME_IN_OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        // Check that provider's name for an alias id (JST) is
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
        // propagated to its standard id and alias ids.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
        String jstime = TimeZone.getTimeZone(JST).getDisplayName(OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
        if (!JST_IN_OSAKA.equals(jstime)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
            throw new RuntimeException("Could not get provider's localized name.  result: "+jstime+" expected: "+JST_IN_OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
        String tokyotime = TimeZone.getTimeZone(TOKYOTIME).getDisplayName(OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
        if (!JST_IN_OSAKA.equals(tokyotime)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
            throw new RuntimeException("Provider's localized name is not available for a standard ID: "+TOKYOTIME+".  result: "+tokyotime+" expected: "+JST_IN_OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        String japan = TimeZone.getTimeZone(JAPAN).getDisplayName(OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        if (!JST_IN_OSAKA.equals(japan)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            throw new RuntimeException("Provider's localized name is not available for an alias ID: "+JAPAN+".  result: "+japan+" expected: "+JST_IN_OSAKA);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
}