jdk/test/sun/util/locale/provider/Bug8038436.java
author mchung
Wed, 10 Aug 2016 15:51:25 -0700
changeset 40261 86a49ba76f52
parent 39305 b10720494ec4
child 40791 a080a12eaa93
permissions -rw-r--r--
8136930: Simplify use of module-system options by custom launchers Reviewed-by: alanb, ksrini, henryjen, sundar
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
/*
39305
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
     2
 * Copyright (c) 2014, 2016 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
39305
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    26
 * @bug 8038436 8158504
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
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    30
 * @compile -XDignore.symbol.file Bug8038436.java
40261
86a49ba76f52 8136930: Simplify use of module-system options by custom launchers
mchung
parents: 39305
diff changeset
    31
 * @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
    32
 * @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
    33
 */
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
import java.security.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    36
import java.util.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    37
import java.util.stream.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    38
import sun.util.locale.provider.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    39
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    40
public class Bug8038436 {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    41
    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
    42
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    43
        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
    44
26360
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    45
        case "security":
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    46
            securityTests();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    47
            break;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    48
        case "availlocs":
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    49
            availableLocalesTests();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    50
            break;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    51
        default:
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    52
            throw new RuntimeException("no test was specified.");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    53
        }
39305
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
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    56
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    57
    private static void securityTests() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    58
        Policy.setPolicy(new MyPolicy());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    59
        System.setSecurityManager(new SecurityManager());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    60
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    61
        /*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    62
         * Test for AccessClassInPackage security exception. Confirms that
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    63
         * 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
    64
         * does not allow any RuntimePermission, on loading LocaleDataMetaInfo
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    65
         * from jdk.localedata module.
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
        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
    68
                           new GregorianCalendar()));
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    69
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
         * 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
    72
         * 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
    73
         */
39305
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    74
        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
    75
                .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
    76
                .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
    77
b10720494ec4 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales
rgoel
parents: 30820
diff changeset
    78
        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
    79
            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
    80
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    81
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    82
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    83
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    84
    static class MyPolicy extends Policy {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    85
        final PermissionCollection perms = new Permissions();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    86
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    87
        MyPolicy() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    88
            // allows no RuntimePermission
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    89
        }
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
        public PermissionCollection getPermissions(ProtectionDomain domain) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    92
            return perms;
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
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    95
        public PermissionCollection getPermissions(CodeSource codesource) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    96
            return perms;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    97
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    98
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    99
        public boolean implies(ProtectionDomain domain, Permission perm) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   100
            return perms.implies(perm);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   101
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   102
    }
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
    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
   105
        "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
   106
        "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
   107
        "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
   108
        "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
   109
        "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
   110
        "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
   111
        "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
   112
        "ja, ja-JP, ko, ko-KR, lt, lt-LT, lv, lv-LV, mk, mk-MK, ms, ms-MY, mt, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   113
        "mt-MT, nl, nl-BE, nl-NL, no, no-NO, no-NO, pl, pl-PL, pt, pt-BR, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   114
        "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
   115
        "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
   116
        "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
   117
        "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
   118
    static final String[] dfpLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   119
    static final String[] datefspLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   120
    static final String[] decimalfspLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   121
    static final String[] calnpLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   122
    static final String[] cpLocs = ("ar, be, bg, ca, cs, da, el, es, et, fi, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   123
        "fr, he, hi, hr, hu, is, ja, ko, lt, lv, mk, no, pl, ro, ru, sk, sl, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   124
        "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
   125
        "zh-Hant-TW, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   126
    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
   127
        "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
   128
        "ar-TN, ar-YE, be, be-BY, bg, bg-BG, ca, ca-ES, cs, cs-CZ, da, da-DK, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   129
        "de, de-AT, de-CH, de-DE, de-GR, de-LU, el, el-CY, el-GR, en, en-AU, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   130
        "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
   131
        "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
   132
        "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
   133
        "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
   134
        "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
   135
        "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
   136
        "ja-JP-u-ca-japanese-x-lvariant-JP, ko, ko-KR, lt, lt-LT, lv, lv-LV, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   137
        "mk, mk-MK, ms, ms-MY, mt, mt-MT, nb-NO, nl, nl-BE, nl-NL, nn-NO, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   138
        "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
   139
        "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
   140
        "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
   141
        "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
   142
        "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
   143
        "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
   144
    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
   145
        "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
   146
        "ar-TN, ar-YE, be-BY, bg-BG, ca-ES, cs-CZ, da-DK, de, de-AT, de-CH, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   147
        "de-DE, de-GR, de-LU, el-CY, el-GR, 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
   148
        "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
   149
        "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
   150
        "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
   151
        "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
   152
        "hu-HU, id-ID, is-IS, it, it-CH, it-IT, ja, ja-JP, ko, ko-KR, lt-LT, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   153
        "lv-LV, mk-MK, ms-MY, mt-MT, nl-BE, nl-NL, no-NO, pl-PL, pt, pt-BR, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   154
        "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
   155
        "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
   156
        "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
   157
        "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
   158
    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
   159
        "en, en-MT, en-PH, en-SG, es, es-US, et, fi, fr, ga, he, hi, hr, hu, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   160
        "id, is, it, ja, ko, lt, lv, mk, ms, mt, nl, no, no-NO, pl, pt, pt-BR, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   161
        "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
   162
        "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
   163
    static final String[] tznpLocs = ("de, en, en-CA, en-GB, en-IE, es, fr, hi, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   164
        "it, ja, ko, pt-BR, sv, und, zh-CN, zh-HK, zh-Hans-CN, zh-Hant-HK, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   165
        "zh-Hant-TW, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   166
    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
   167
        "en, en-GB, en-IE, en-MT, es, es-ES, es-US, et, fi, fr, fr-CA, he, hi, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   168
        "hr, hu, id-ID, is, it, ja, ko, lt, lv, mk, ms-MY, mt, mt-MT, nl, no, " +
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   169
        "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
   170
        "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
   171
    static final String[] calpLocs = caldpLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   172
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   173
    /*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   174
     * 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
   175
     * 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
   176
     * 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
   177
     * data resource bundle were added.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   178
     */
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   179
    private static void availableLocalesTests() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   180
        LocaleProviderAdapter jre = LocaleProviderAdapter.forJRE();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   181
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   182
        checkAvailableLocales("BreakIteratorProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   183
            jre.getBreakIteratorProvider().getAvailableLocales(), bipLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   184
        checkAvailableLocales("CollatorProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   185
            jre.getCollatorProvider().getAvailableLocales(), cpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   186
        checkAvailableLocales("DateFormatProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   187
            jre.getDateFormatProvider().getAvailableLocales(), dfpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   188
        checkAvailableLocales("DateFormatSymbolsProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   189
            jre.getDateFormatSymbolsProvider().getAvailableLocales(), datefspLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   190
        checkAvailableLocales("DecimalFormatSymbolsProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   191
            jre.getDecimalFormatSymbolsProvider().getAvailableLocales(), decimalfspLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   192
        checkAvailableLocales("NumberFormatProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   193
            jre.getNumberFormatProvider().getAvailableLocales(), nfpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   194
        checkAvailableLocales("CurrencyNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   195
            jre.getCurrencyNameProvider().getAvailableLocales(), currencynpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   196
        checkAvailableLocales("LocaleNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   197
            jre.getLocaleNameProvider().getAvailableLocales(), lnpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   198
        checkAvailableLocales("TimeZoneNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   199
            jre.getTimeZoneNameProvider().getAvailableLocales(), tznpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   200
        checkAvailableLocales("CalendarDataProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   201
            jre.getCalendarDataProvider().getAvailableLocales(), caldpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   202
        checkAvailableLocales("CalendarNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   203
            jre.getCalendarNameProvider().getAvailableLocales(), calnpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   204
        checkAvailableLocales("CalendarProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   205
            jre.getCalendarProvider().getAvailableLocales(), calpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   206
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   207
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   208
    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
   209
        System.out.println("Testing available locales for " + testName);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   210
        List<Locale> gotList = Arrays.asList(got).stream()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   211
            .map(Locale::toLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   212
            .sorted()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   213
            .map(Locale::forLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   214
            .collect(Collectors.toList());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   215
        List<Locale> expectedList = Arrays.asList(expected).stream()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   216
            .map(Locale::forLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   217
            .collect(Collectors.toList());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   218
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   219
        if (!gotList.equals(expectedList)) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   220
            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
   221
                                       expectedList.toString());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   222
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   223
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   224
}