jdk/test/sun/util/locale/provider/Bug8038436.java
author naoto
Tue, 02 Sep 2014 14:11:38 -0700
changeset 26360 697f70835528
child 30820 0d4717a011d3
permissions -rw-r--r--
8038436: Re-examine the mechanism to determine available localedata and cldrdata Reviewed-by: alanb, mchung, okutsu
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
/*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
     2
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
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
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    26
 * @bug 8038436
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    27
 * @summary Test for changes in 8038436
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    28
 * @compile -XDignore.symbol.file Bug8038436.java
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    29
 * @run main/othervm Bug8038436 -Djava.ext.dirs=foo security
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    30
 * @run main/othervm Bug8038436 -Djava.locale.providers=JRE availlocs
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    31
 */
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    32
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    33
import java.security.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    34
import java.text.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    35
import java.util.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    36
import java.util.stream.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    37
import sun.util.locale.provider.*;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    38
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    39
public class Bug8038436 {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    40
    public static void main(String[] args) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    41
        switch (args[1]) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    42
        case "security":
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    43
            securityTests();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    44
            break;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    45
        case "availlocs":
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    46
            availableLocalesTests();
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
        default:
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    49
            throw new RuntimeException("no test was specified.");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    50
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    51
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    52
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    53
    private static void securityTests() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    54
        Policy.setPolicy(new MyPolicy());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    55
        System.setSecurityManager(new SecurityManager());
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
        /*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    58
         * Test for AccessClassInPackage security exception. Confirms that
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    59
         * 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
    60
         * does not allow any RuntimePermission, on loading LocaleDataMetaInfo
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    61
         * from jdk.localedata module.
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    62
         */
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    63
        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
    64
                           new GregorianCalendar()));
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
         * Check only English/ROOT locales are returned if the jdk.localedata
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    68
         * module is not installed (implied by "java.ext.dirs" set to "foo").
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
        if (Arrays.asList(Locale.getAvailableLocales())
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    71
                .stream()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    72
                .anyMatch(l -> l != Locale.ROOT && l.getLanguage() != "en")) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    73
            throw new RuntimeException("non English locale(s) included in available locales");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    74
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    75
    }
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
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    78
    static class MyPolicy extends Policy {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    79
        final PermissionCollection perms = new Permissions();
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
        MyPolicy() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    82
            // allows no RuntimePermission
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
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    85
        public PermissionCollection getPermissions(ProtectionDomain domain) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    86
            return perms;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    87
        }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    88
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    89
        public PermissionCollection getPermissions(CodeSource codesource) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    90
            return perms;
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
        public boolean implies(ProtectionDomain domain, Permission perm) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    94
            return perms.implies(perm);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    95
        }
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
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
    98
    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
    99
        "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
   100
        "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
   101
        "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
   102
        "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
   103
        "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
   104
        "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
   105
        "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
   106
        "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
   107
        "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
   108
        "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
   109
        "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
   110
        "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
   111
        "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
   112
    static final String[] dfpLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   113
    static final String[] datefspLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   114
    static final String[] decimalfspLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   115
    static final String[] calnpLocs = bipLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   116
    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
   117
        "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
   118
        "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
   119
        "zh-Hant-TW, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   120
    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
   121
        "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
   122
        "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
   123
        "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
   124
        "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
   125
        "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
   126
        "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
   127
        "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
   128
        "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
   129
        "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
   130
        "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
   131
        "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
   132
        "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
   133
        "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
   134
        "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
   135
        "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
   136
        "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
   137
        "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
   138
    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
   139
        "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
   140
        "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
   141
        "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
   142
        "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
   143
        "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
   144
        "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
   145
        "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
   146
        "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
   147
        "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
   148
        "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
   149
        "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
   150
        "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
   151
        "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
   152
    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
   153
        "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
   154
        "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
   155
        "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
   156
        "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
   157
    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
   158
        "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
   159
        "zh-Hant-TW, zh-TW, ").split(",\\s*");
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   160
    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
   161
        "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
   162
        "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
   163
        "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
   164
        "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
   165
    static final String[] calpLocs = caldpLocs;
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   166
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   167
    /*
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   168
     * 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
   169
     * 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
   170
     * 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
   171
     * data resource bundle were added.
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
    private static void availableLocalesTests() {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   174
        LocaleProviderAdapter jre = LocaleProviderAdapter.forJRE();
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   175
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   176
        checkAvailableLocales("BreakIteratorProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   177
            jre.getBreakIteratorProvider().getAvailableLocales(), bipLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   178
        checkAvailableLocales("CollatorProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   179
            jre.getCollatorProvider().getAvailableLocales(), cpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   180
        checkAvailableLocales("DateFormatProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   181
            jre.getDateFormatProvider().getAvailableLocales(), dfpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   182
        checkAvailableLocales("DateFormatSymbolsProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   183
            jre.getDateFormatSymbolsProvider().getAvailableLocales(), datefspLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   184
        checkAvailableLocales("DecimalFormatSymbolsProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   185
            jre.getDecimalFormatSymbolsProvider().getAvailableLocales(), decimalfspLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   186
        checkAvailableLocales("NumberFormatProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   187
            jre.getNumberFormatProvider().getAvailableLocales(), nfpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   188
        checkAvailableLocales("CurrencyNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   189
            jre.getCurrencyNameProvider().getAvailableLocales(), currencynpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   190
        checkAvailableLocales("LocaleNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   191
            jre.getLocaleNameProvider().getAvailableLocales(), lnpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   192
        checkAvailableLocales("TimeZoneNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   193
            jre.getTimeZoneNameProvider().getAvailableLocales(), tznpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   194
        checkAvailableLocales("CalendarDataProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   195
            jre.getCalendarDataProvider().getAvailableLocales(), caldpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   196
        checkAvailableLocales("CalendarNameProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   197
            jre.getCalendarNameProvider().getAvailableLocales(), calnpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   198
        checkAvailableLocales("CalendarProvider",
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   199
            jre.getCalendarProvider().getAvailableLocales(), calpLocs);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   200
    }
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   201
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   202
    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
   203
        System.out.println("Testing available locales for " + testName);
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   204
        List<Locale> gotList = Arrays.asList(got).stream()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   205
            .map(Locale::toLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   206
            .sorted()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   207
            .map(Locale::forLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   208
            .collect(Collectors.toList());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   209
        List<Locale> expectedList = Arrays.asList(expected).stream()
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   210
            .map(Locale::forLanguageTag)
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   211
            .collect(Collectors.toList());
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   212
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   213
        if (!gotList.equals(expectedList)) {
697f70835528 8038436: Re-examine the mechanism to determine available localedata and cldrdata
naoto
parents:
diff changeset
   214
            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
   215
                                       expectedList.toString());
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
}