jdk/test/sun/util/locale/provider/Bug8038436.java
author rgoel
Tue, 24 Jan 2017 12:06:03 +0530
changeset 43295 58870c7a62e0
parent 42930 b878b7b2788e
permissions -rw-r--r--
8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols Reviewed-by: naoto
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     1
/*
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
     2
 * Copyright (c) 2014, 2017, Oracle and/or its affiliates. All rights reserved.
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     4
 *
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     7
 * published by the Free Software Foundation.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     8
 *
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    13
 * accompanied this code).
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    14
 *
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    18
 *
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    21
 * questions.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    22
 */
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    23
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    24
/*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    25
 * @test
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
    26
 * @bug 8038436 8158504 8065555 8167143 8167273
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    27
 * @summary Test for changes in 8038436
30820
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 26360
diff changeset
    28
 * @modules java.base/sun.util.locale.provider
0d4717a011d3 8081347: Add @modules to jdk_core tests
mchung
parents: 26360
diff changeset
    29
 *          java.base/sun.util.spi
40791
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    30
 *          jdk.localedata
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    31
 * @compile -XDignore.symbol.file Bug8038436.java
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39305
diff changeset
    32
 * @run main/othervm  --limit-modules java.base      Bug8038436  security
39305
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    33
 * @run main/othervm  -Djava.locale.providers=COMPAT Bug8038436  availlocs
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    34
 */
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    35
40791
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    36
import java.security.CodeSource;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    37
import java.security.Permission;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    38
import java.security.PermissionCollection;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    39
import java.security.Permissions;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    40
import java.security.Policy;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    41
import java.security.ProtectionDomain;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    42
import java.util.Arrays;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    43
import java.util.Formatter;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    44
import java.util.GregorianCalendar;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    45
import java.util.List;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    46
import java.util.Locale;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    47
import java.util.stream.Collectors;
a080a12eaa93 8165604: Fix module dependencies for sun/util/* tests
skovalev
parents: 40261
diff changeset
    48
import sun.util.locale.provider.LocaleProviderAdapter;
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    49
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    50
public class Bug8038436 {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    51
    public static void main(String[] args) {
39305
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    52
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    53
        switch (args[0]) {
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    54
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    55
        case "security":
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    56
            securityTests();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    57
            break;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    58
        case "availlocs":
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    59
            availableLocalesTests();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    60
            break;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    61
        default:
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    62
            throw new RuntimeException("no test was specified.");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    63
        }
39305
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    64
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    65
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    66
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    67
    private static void securityTests() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    68
        Policy.setPolicy(new MyPolicy());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    69
        System.setSecurityManager(new SecurityManager());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    70
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    71
        /*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    72
         * Test for AccessClassInPackage security exception. Confirms that
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    73
         * exeption won't be thrown if an application sets a Permission that
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    74
         * does not allow any RuntimePermission, on loading LocaleDataMetaInfo
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    75
         * from jdk.localedata module.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    76
         */
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    77
        System.out.println(new Formatter(Locale.JAPAN).format("%1$tB %1$te, %1$tY",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    78
                           new GregorianCalendar()));
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    79
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    80
        /*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    81
         * Check only English/ROOT locales are returned if the jdk.localedata
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39305
diff changeset
    82
         * module is not loaded (implied by "--limit-modules java.base").
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    83
         */
39305
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    84
        List<Locale> nonEnglishLocales= (Arrays.stream(Locale.getAvailableLocales())
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    85
                .filter(l -> (l != Locale.ROOT && !(l.getLanguage() == "en" && (l.getCountry() == "US" || l.getCountry() == "" ))))
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    86
                .collect(Collectors.toList()));
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    87
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    88
        if (!nonEnglishLocales.isEmpty()) {
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    89
            throw new RuntimeException("non English locale(s)" + nonEnglishLocales + " included in available locales");
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    90
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    91
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    92
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    93
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    94
    static class MyPolicy extends Policy {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    95
        final PermissionCollection perms = new Permissions();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    96
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    97
        MyPolicy() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    98
            // allows no RuntimePermission
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    99
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   100
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   101
        public PermissionCollection getPermissions(ProtectionDomain domain) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   102
            return perms;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   103
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   104
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   105
        public PermissionCollection getPermissions(CodeSource codesource) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   106
            return perms;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   107
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   108
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   109
        public boolean implies(ProtectionDomain domain, Permission perm) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   110
            return perms.implies(perm);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   111
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   112
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   113
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   114
    static final String[] bipLocs = ("ar, ar-JO, ar-LB, ar-SY, be, be-BY, bg, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   115
        "bg-BG, ca, ca-ES, cs, cs-CZ, da, da-DK, de, de-AT, de-CH, de-DE, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   116
        "de-LU, el, el-CY, el-GR, en, en-AU, en-CA, en-GB, en-IE, en-IN, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   117
        "en-MT, en-NZ, en-PH, en-SG, en-US, en-ZA, es, es-AR, es-BO, es-CL, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   118
        "es-CO, es-CR, es-DO, es-EC, es-ES, es-GT, es-HN, es-MX, es-NI, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   119
        "es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE, et, et-EE, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   120
        "fi, fi-FI, fr, fr-BE, fr-CA, fr-CH, fr-FR, ga, ga-IE, he, he-IL, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   121
        "hi-IN, hr, hr-HR, hu, hu-HU, id, id-ID, is, is-IS, it, it-CH, it-IT, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   122
        "ja, ja-JP, ko, ko-KR, lt, lt-LT, lv, lv-LV, mk, mk-MK, ms, ms-MY, mt, " +
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
   123
        "mt-MT, nb, nb-NO, nl, nl-BE, nl-NL, nn-NO, no, no-NO, no-NO, pl, pl-PL, pt, pt-BR, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   124
        "pt-PT, ro, ro-RO, ru, ru-RU, sk, sk-SK, sl, sl-SI, sq, sq-AL, sr, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   125
        "sr-BA, sr-CS, sr-Latn, sr-Latn-ME, sr-ME, sr-RS, sv, sv-SE, th, th-TH, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   126
        "tr, tr-TR, uk, uk-UA, und, vi, vi-VN, zh, zh-CN, zh-HK, zh-Hans-CN, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   127
        "zh-Hans-SG, zh-Hant-HK, zh-Hant-TW, zh-SG, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   128
    static final String[] dfpLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   129
    static final String[] datefspLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   130
    static final String[] decimalfspLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   131
    static final String[] calnpLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   132
    static final String[] cpLocs = ("ar, be, bg, ca, cs, da, el, es, et, fi, " +
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
   133
        "fr, he, hi, hr, hu, is, ja, ko, lt, lv, mk, nb, nb-NO, nn-NO, no, pl, ro, ru, sk, sl, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   134
        "sq, sr, sr-Latn, sv, th, tr, uk, und, vi, zh, zh-HK, zh-Hant-HK, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   135
        "zh-Hant-TW, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   136
    static final String[] nfpLocs = ("ar, ar-AE, ar-BH, ar-DZ, ar-EG, ar-IQ, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   137
        "ar-JO, ar-KW, ar-LB, ar-LY, ar-MA, ar-OM, ar-QA, ar-SA, ar-SD, ar-SY, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   138
        "ar-TN, ar-YE, be, be-BY, bg, bg-BG, ca, ca-ES, cs, cs-CZ, da, da-DK, " +
42231
055ef279e1bb 8065555: Remove incorrect locale data for inexistent language German (Greece)
lana
parents: 40791
diff changeset
   139
        "de, de-AT, de-CH, de-DE, de-LU, el, el-CY, el-GR, en, en-AU, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   140
        "en-CA, en-GB, en-IE, en-IN, en-MT, en-NZ, en-PH, en-SG, en-US, en-ZA, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   141
        "es, es-AR, es-BO, es-CL, es-CO, es-CR, es-CU, es-DO, es-EC, es-ES, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   142
        "es-GT, es-HN, es-MX, es-NI, es-PA, es-PE, es-PR, es-PY, es-SV, es-US, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   143
        "es-UY, es-VE, et, et-EE, fi, fi-FI, fr, fr-BE, fr-CA, fr-CH, fr-FR, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   144
        "fr-LU, ga, ga-IE, he, he-IL, hi, hi-IN, hr, hr-HR, hu, hu-HU, id, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   145
        "id-ID, is, is-IS, it, it-CH, it-IT, ja, ja-JP, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   146
        "ja-JP-u-ca-japanese-x-lvariant-JP, ko, ko-KR, lt, lt-LT, lv, lv-LV, " +
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
   147
        "mk, mk-MK, ms, ms-MY, mt, mt-MT, nb, nb-NO, nl, nl-BE, nl-NL, nn-NO, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   148
        "nn-NO, no, no-NO, pl, pl-PL, pt, pt-BR, pt-PT, ro, ro-RO, ru, ru-RU, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   149
        "sk, sk-SK, sl, sl-SI, sq, sq-AL, sr, sr-BA, sr-CS, sr-Latn, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   150
        "sr-Latn-BA, sr-Latn-ME, sr-Latn-RS, sr-ME, sr-RS, sv, sv-SE, th, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   151
        "th-TH, th-TH-u-nu-thai-x-lvariant-TH, tr, tr-TR, uk, uk-UA, und, vi, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   152
        "vi-VN, zh, zh-CN, zh-HK, zh-Hans-CN, zh-Hans-SG, zh-Hant-HK, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   153
        "zh-Hant-TW, zh-SG, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   154
    static final String[] currencynpLocs = ("ar-AE, ar-BH, ar-DZ, ar-EG, ar-IQ, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   155
        "ar-JO, ar-KW, ar-LB, ar-LY, ar-MA, ar-OM, ar-QA, ar-SA, ar-SD, ar-SY, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   156
        "ar-TN, ar-YE, be-BY, bg-BG, ca-ES, cs-CZ, da-DK, de, de-AT, de-CH, " +
42231
055ef279e1bb 8065555: Remove incorrect locale data for inexistent language German (Greece)
lana
parents: 40791
diff changeset
   157
        "de-DE, de-LU, el-CY, el-GR, en-AU, en-CA, en-GB, en-IE, en-IN, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   158
        "en-MT, en-NZ, en-PH, en-SG, en-US, en-ZA, es, es-AR, es-BO, es-CL, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   159
        "es-CO, es-CR, es-CU, es-DO, es-EC, es-ES, es-GT, es-HN, es-MX, es-NI, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   160
        "es-PA, es-PE, es-PR, es-PY, es-SV, es-US, es-UY, es-VE, et-EE, fi-FI, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   161
        "fr, fr-BE, fr-CA, fr-CH, fr-FR, fr-LU, ga-IE, he-IL, hi-IN, hr-HR, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   162
        "hu-HU, id-ID, is-IS, it, it-CH, it-IT, ja, ja-JP, ko, ko-KR, lt-LT, " +
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
   163
        "lv-LV, mk-MK, ms-MY, mt-MT, nb,  nb-NO, nl-BE, nl-NL, nn-NO, no-NO, pl-PL, pt, pt-BR, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   164
        "pt-PT, ro-RO, ru-RU, sk-SK, sl-SI, sq-AL, sr-BA, sr-CS, sr-Latn-BA, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   165
        "sr-Latn-ME, sr-Latn-RS, sr-ME, sr-RS, sv, sv-SE, th-TH, tr-TR, uk-UA, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   166
        "und, vi-VN, zh-CN, zh-HK, zh-Hans-CN, zh-Hans-SG, zh-Hant-HK, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   167
        "zh-Hant-TW, zh-SG, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   168
    static final String[] lnpLocs = ("ar, be, bg, ca, cs, da, de, el, el-CY, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   169
        "en, en-MT, en-PH, en-SG, es, es-US, et, fi, fr, ga, he, hi, hr, hu, " +
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
   170
        "id, is, it, ja, ko, lt, lv, mk, ms, mt, nb, nb-NO, nl, nn-NO, no, no-NO, pl, pt, pt-BR, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   171
        "pt-PT, ro, ru, sk, sl, sq, sr, sr-Latn, sv, th, tr, uk, und, vi, zh, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   172
        "zh-HK, zh-Hans-SG, zh-Hant-HK, zh-Hant-TW, zh-SG, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   173
    static final String[] tznpLocs = ("de, en, en-CA, en-GB, en-IE, es, fr, hi, " +
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
   174
        "it, ja, ko, nb,  nb-NO, nn-NO, pt-BR, sv, und, zh-CN, zh-HK, zh-Hans-CN, zh-Hant-HK, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   175
        "zh-Hant-TW, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   176
    static final String[] caldpLocs = ("ar, be, bg, ca, cs, da, de, el, el-CY, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   177
        "en, en-GB, en-IE, en-MT, es, es-ES, es-US, et, fi, fr, fr-CA, he, hi, " +
43295
58870c7a62e0 8167273: Calendar.getDisplayNames inconsistent with DateFormatSymbols
rgoel
parents: 42930
diff changeset
   178
        "hr, hu, id-ID, is, it, ja, ko, lt, lv, mk, ms-MY, mt, mt-MT, nb, nb-NO, nl, nn-NO, no, " +
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   179
        "pl, pt, pt-BR, pt-PT, ro, ru, sk, sl, sq, sr, sr-Latn-BA, sr-Latn-ME, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   180
        "sr-Latn-RS, sv, th, tr, uk, und, vi, zh, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   181
    static final String[] calpLocs = caldpLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   182
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   183
    /*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   184
     * Validate whether JRE's *Providers return supported locales list based on
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   185
     * their actual resource bundle exsistence. The above golden data
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   186
     * are manually extracted, so they need to be updated if new locale
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   187
     * data resource bundle were added.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   188
     */
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   189
    private static void availableLocalesTests() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   190
        LocaleProviderAdapter jre = LocaleProviderAdapter.forJRE();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   191
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   192
        checkAvailableLocales("BreakIteratorProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   193
            jre.getBreakIteratorProvider().getAvailableLocales(), bipLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   194
        checkAvailableLocales("CollatorProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   195
            jre.getCollatorProvider().getAvailableLocales(), cpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   196
        checkAvailableLocales("DateFormatProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   197
            jre.getDateFormatProvider().getAvailableLocales(), dfpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   198
        checkAvailableLocales("DateFormatSymbolsProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   199
            jre.getDateFormatSymbolsProvider().getAvailableLocales(), datefspLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   200
        checkAvailableLocales("DecimalFormatSymbolsProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   201
            jre.getDecimalFormatSymbolsProvider().getAvailableLocales(), decimalfspLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   202
        checkAvailableLocales("NumberFormatProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   203
            jre.getNumberFormatProvider().getAvailableLocales(), nfpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   204
        checkAvailableLocales("CurrencyNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   205
            jre.getCurrencyNameProvider().getAvailableLocales(), currencynpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   206
        checkAvailableLocales("LocaleNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   207
            jre.getLocaleNameProvider().getAvailableLocales(), lnpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   208
        checkAvailableLocales("TimeZoneNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   209
            jre.getTimeZoneNameProvider().getAvailableLocales(), tznpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   210
        checkAvailableLocales("CalendarDataProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   211
            jre.getCalendarDataProvider().getAvailableLocales(), caldpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   212
        checkAvailableLocales("CalendarNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   213
            jre.getCalendarNameProvider().getAvailableLocales(), calnpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   214
        checkAvailableLocales("CalendarProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   215
            jre.getCalendarProvider().getAvailableLocales(), calpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   216
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   217
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   218
    private static void checkAvailableLocales(String testName, Locale[] got, String[] expected) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   219
        System.out.println("Testing available locales for " + testName);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   220
        List<Locale> gotList = Arrays.asList(got).stream()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   221
            .map(Locale::toLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   222
            .sorted()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   223
            .map(Locale::forLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   224
            .collect(Collectors.toList());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   225
        List<Locale> expectedList = Arrays.asList(expected).stream()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   226
            .map(Locale::forLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   227
            .collect(Collectors.toList());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   228
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   229
        if (!gotList.equals(expectedList)) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   230
            throw new RuntimeException("\n" + gotList.toString() + "\n is not equal to \n" +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   231
                                       expectedList.toString());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   232
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   233
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   234
}