jdk/test/java/util/Calendar/CldrFormatNamesTest.java
author vlivanov
Wed, 02 Mar 2016 15:42:03 +0300
changeset 36349 6cc8e6f596b2
parent 35768 7066da300a08
child 38747 469920616f3a
permissions -rw-r--r--
8151020: [TESTBUG] UnsafeGetStableArrayElement::testL_* fail intermittently Reviewed-by: zmajo, shade
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
     1
/*
35768
7066da300a08 8149391: Fix module dependences in java/util tests
shurailine
parents: 31263
diff changeset
     2
 * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved.
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
     4
 *
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
21596
0e3a39f29dbc 8027696: Incorrect copyright header in the tests
serb
parents: 16852
diff changeset
     7
 * published by the Free Software Foundation.
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
     8
 *
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    13
 * accompanied this code).
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    14
 *
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    18
 *
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    21
 * questions.
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    22
 */
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    23
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    24
/*
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    25
 * @test
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    26
 * @bug 8004489 8006509 8008577
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 21596
diff changeset
    27
 * @summary Unit test for CLDR FormatData resources
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 21596
diff changeset
    28
 * @modules java.base/sun.util.locale.provider
35768
7066da300a08 8149391: Fix module dependences in java/util tests
shurailine
parents: 31263
diff changeset
    29
 *          jdk.localedata
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    30
 * @compile -XDignore.symbol.file CldrFormatNamesTest.java
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    31
 * @run main/othervm -Djava.locale.providers=CLDR CldrFormatNamesTest
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    32
 */
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    33
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    34
import java.util.*;
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    35
import static java.util.Calendar.*;
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    36
import sun.util.locale.provider.*;
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    37
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    38
public class CldrFormatNamesTest {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    39
    private static final Locale ARABIC = new Locale("ar");
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    40
    private static final Locale ZH_HANT = Locale.forLanguageTag("zh-Hant");
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    41
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    42
    /*
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    43
     * The first element is a Locale followed by key-value pairs
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    44
     * in a FormatData resource bundle. The value type is either
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    45
     * String or String[].
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    46
     */
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    47
    static final Object[][] CLDR_DATA = {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    48
        {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    49
            Locale.JAPAN,
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    50
            "field.zone", "\u30bf\u30a4\u30e0\u30be\u30fc\u30f3",
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15281
diff changeset
    51
            "java.time.japanese.DatePatterns", new String[] {
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    52
                "Gy\u5e74M\u6708d\u65e5EEEE",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    53
                "Gy\u5e74M\u6708d\u65e5",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    54
                "Gy\u5e74M\u6708d\u65e5",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    55
                "Gyy/MM/dd",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    56
            },
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15281
diff changeset
    57
            "java.time.roc.DatePatterns", new String[] {
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    58
                "Gy\u5e74M\u6708d\u65e5EEEE",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    59
                "Gy\u5e74M\u6708d\u65e5",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    60
                "Gy/MM/dd",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    61
                "Gy/MM/dd",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    62
            },
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    63
            "calendarname.buddhist", "\u30bf\u30a4\u4ecf\u6559\u66a6",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    64
        },
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    65
        {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    66
            Locale.PRC,
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    67
            "field.zone", "\u65f6\u533a",
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15281
diff changeset
    68
            "java.time.islamic.DatePatterns", new String[] {
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    69
                "Gy\u5e74M\u6708d\u65e5EEEE",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    70
                "Gy\u5e74M\u6708d\u65e5",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    71
                "Gy\u5e74M\u6708d\u65e5",
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    72
                "Gy/M/d",
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    73
            },
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    74
            "calendarname.islamic", "\u4f0a\u65af\u5170\u65e5\u5386",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    75
        },
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    76
        {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    77
            Locale.GERMANY,
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    78
            "field.dayperiod", "Tagesh\u00e4lfte",
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15281
diff changeset
    79
            "java.time.islamic.DatePatterns", new String[] {
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    80
                "EEEE, d. MMMM y G",
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    81
                "d. MMMM y G",
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    82
                "dd.MM.y G",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    83
                "dd.MM.yy GGGGG",
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    84
            },
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    85
            "calendarname.islamic", "Islamischer Kalender",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    86
        },
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    87
        {
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    88
            Locale.FRANCE,
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    89
            "field.dayperiod", "cadran",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    90
            "java.time.islamic.DatePatterns", new String[] {
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    91
                "EEEE d MMMM y G",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    92
                "d MMMM y G",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    93
                "d MMM y G",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    94
                "dd/MM/y GGGGG",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    95
            },
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    96
            "calendarname.islamic", "calendrier musulman",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
    97
        },
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    98
    };
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
    99
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   100
    // Islamic calendar symbol names in ar
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   101
    private static final String[] ISLAMIC_MONTH_NAMES = {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   102
        "\u0645\u062d\u0631\u0645",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   103
        "\u0635\u0641\u0631",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   104
        "\u0631\u0628\u064a\u0639 \u0627\u0644\u0623\u0648\u0644",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   105
        "\u0631\u0628\u064a\u0639 \u0627\u0644\u0622\u062e\u0631",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   106
        "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0623\u0648\u0644\u0649",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   107
        "\u062c\u0645\u0627\u062f\u0649 \u0627\u0644\u0622\u062e\u0631\u0629",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   108
        "\u0631\u062c\u0628",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   109
        "\u0634\u0639\u0628\u0627\u0646",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   110
        "\u0631\u0645\u0636\u0627\u0646",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   111
        "\u0634\u0648\u0627\u0644",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   112
        "\u0630\u0648 \u0627\u0644\u0642\u0639\u062f\u0629",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   113
        "\u0630\u0648 \u0627\u0644\u062d\u062c\u0629",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   114
    };
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   115
    private static final String[] ISLAMIC_ERA_NAMES = {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   116
        "",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   117
        "\u0647\u0640",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   118
    };
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   119
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   120
    // Minguo calendar symbol names in zh_Hant
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   121
    private static final String[] ROC_ERA_NAMES = {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   122
        "\u6c11\u570b\u524d",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   123
        "\u6c11\u570b",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   124
    };
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   125
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   126
    private static int errors = 0;
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   127
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   128
    // This test is CLDR data dependent.
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   129
    public static void main(String[] args) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   130
        for (Object[] data : CLDR_DATA) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   131
            Locale locale = (Locale) data[0];
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   132
            ResourceBundle rb = LocaleProviderAdapter.getResourceBundleBased()
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15281
diff changeset
   133
                                    .getLocaleResources(locale).getJavaTimeFormatData();
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   134
            for (int i = 1; i < data.length; ) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   135
                String key = (String) data[i++];
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   136
                Object expected = data[i++];
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   137
                if (rb.containsKey(key)) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   138
                    Object value = rb.getObject(key);
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   139
                    if (expected instanceof String) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   140
                        if (!expected.equals(value)) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   141
                            errors++;
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
   142
                            System.err.printf("error: key='%s', got '%s' expected '%s', rb: %s%n",
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
   143
                                              key, value, expected, rb);
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   144
                        }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   145
                    } else if (expected instanceof String[]) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   146
                        try {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   147
                            if (!Arrays.equals((Object[]) value, (Object[]) expected)) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   148
                                errors++;
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
   149
                                System.err.printf("error: key='%s', got '%s' expected '%s', rb: %s%n",
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   150
                                                  key, Arrays.asList((Object[])value),
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
   151
                                                  Arrays.asList((Object[])expected), rb);
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   152
                            }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   153
                        } catch (Exception e) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   154
                            errors++;
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   155
                            e.printStackTrace();
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   156
                        }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   157
                    }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   158
                } else {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   159
                    errors++;
31263
a81a0af34ca0 8008577: Use CLDR Locale Data by Default
naoto
parents: 30820
diff changeset
   160
                    System.err.println("No resource for " + key+", rb: "+rb);
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   161
                }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   162
            }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   163
        }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   164
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   165
        // test Islamic calendar names in Arabic
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   166
        testSymbolNames(ARABIC, "islamic", ISLAMIC_MONTH_NAMES, MONTH, LONG, "month");
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   167
        testSymbolNames(ARABIC, "islamic", ISLAMIC_ERA_NAMES, ERA, SHORT, "era");
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   168
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   169
        // test ROC (Minguo) calendar names in zh-Hant
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   170
        testSymbolNames(ZH_HANT, "roc", ROC_ERA_NAMES, ERA, SHORT, "era");
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   171
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   172
        if (errors > 0) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   173
            throw new RuntimeException("test failed");
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   174
        }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   175
    }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   176
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   177
    private static void testSymbolNames(Locale locale, String calType, String[] expected,
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   178
                                        int field, int style, String fieldName) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   179
        for (int i = 0; i < expected.length; i++) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   180
            String expt = expected[i];
16852
60207b2b4b42 8011172: JSR 310 DateTime API Updates II
sherman
parents: 15281
diff changeset
   181
            String name = CalendarDataUtility.retrieveJavaTimeFieldValueName(calType, field, i, style, locale);
15281
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   182
            if (!expt.equals(name)) {
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   183
                errors++;
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   184
                System.err.printf("error: wrong %s %s name in %s: value=%d, got='%s', expected='%s'%n",
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   185
                                  calType, fieldName, locale, i, name, expt);
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   186
            }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   187
        }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   188
    }
dd43cb9be0e1 8004489: Add support for Minguo and Hijrah calendars to CalendarNameProvider SPI
okutsu
parents:
diff changeset
   189
}