Java Code Examples for sun.util.locale.provider.LocaleProviderAdapter#getAdapterType()

The following examples show how to use sun.util.locale.provider.LocaleProviderAdapter#getAdapterType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LocaleProviders.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void adapterTest(String expected, String lang, String ctry) {
    Locale testLocale = new Locale(lang, ctry);
    LocaleProviderAdapter ldaExpected =
        LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected));
    if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) {
        System.out.println("test locale: "+testLocale+" is not supported by the expected provider: "+ldaExpected+". Ignoring the test.");
        return;
    }
    String preference = System.getProperty("java.locale.providers", "");
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, testLocale);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    System.out.printf("testLocale: %s, got: %s, expected: %s\n", testLocale, type, expected);
    if (!type.toString().equals(expected)) {
        throw new RuntimeException("Returned locale data adapter is not correct.");
    }
}
 
Example 2
Source File: LocaleProviders.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
static void adapterTest(String expected, String lang, String ctry) {
    Locale testLocale = new Locale(lang, ctry);
    LocaleProviderAdapter ldaExpected =
        LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected));
    if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) {
        System.out.println("test locale: "+testLocale+" is not supported by the expected provider: "+ldaExpected+". Ignoring the test.");
        return;
    }
    String preference = System.getProperty("java.locale.providers", "");
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, testLocale);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    System.out.printf("testLocale: %s, got: %s, expected: %s\n", testLocale, type, expected);
    if (!type.toString().equals(expected)) {
        throw new RuntimeException("Returned locale data adapter is not correct.");
    }
}
 
Example 3
Source File: LocaleProviders.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
static void adapterTest(String expected, String lang, String ctry) {
    Locale testLocale = new Locale(lang, ctry);
    LocaleProviderAdapter ldaExpected =
        LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected));
    if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) {
        System.out.println("test locale: "+testLocale+" is not supported by the expected provider: "+ldaExpected+". Ignoring the test.");
        return;
    }
    String preference = System.getProperty("java.locale.providers", "");
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, testLocale);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    System.out.printf("testLocale: %s, got: %s, expected: %s\n", testLocale, type, expected);
    if (!type.toString().equals(expected)) {
        throw new RuntimeException("Returned locale data adapter is not correct.");
    }
}
 
Example 4
Source File: LocaleProviders.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
static void adapterTest(String expected, String lang, String ctry) {
    Locale testLocale = new Locale(lang, ctry);
    LocaleProviderAdapter ldaExpected =
        LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected));
    if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) {
        System.out.println("test locale: "+testLocale+" is not supported by the expected provider: "+ldaExpected+". Ignoring the test.");
        return;
    }
    String preference = System.getProperty("java.locale.providers", "");
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, testLocale);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    System.out.printf("testLocale: %s, got: %s, expected: %s\n", testLocale, type, expected);
    if (!type.toString().equals(expected)) {
        throw new RuntimeException("Returned locale data adapter is not correct.");
    }
}
 
Example 5
Source File: LocaleProviders.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
static void adapterTest(String expected, String lang, String ctry) {
    Locale testLocale = new Locale(lang, ctry);
    LocaleProviderAdapter ldaExpected =
        LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected));
    if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) {
        System.out.println("test locale: "+testLocale+" is not supported by the expected provider: "+ldaExpected+". Ignoring the test.");
        return;
    }
    String preference = System.getProperty("java.locale.providers", "");
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, testLocale);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    System.out.printf("testLocale: %s, got: %s, expected: %s\n", testLocale, type, expected);
    if (!type.toString().equals(expected)) {
        throw new RuntimeException("Returned locale data adapter is not correct.");
    }
}
 
Example 6
Source File: LocaleProviders.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void bug7198834Test() {
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    if (type == LocaleProviderAdapter.Type.HOST && System.getProperty("os.name").startsWith("Windows")) {
        DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
        String date = df.format(new Date());
        if (date.charAt(date.length()-1) == ' ') {
            throw new RuntimeException("Windows Host Locale Provider returns a trailing space.");
        }
    } else {
        System.out.println("Windows HOST locale adapter not found. Ignoring this test.");
    }
}
 
Example 7
Source File: LocaleProviders.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
static void bug7198834Test() {
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    if (type == LocaleProviderAdapter.Type.HOST && System.getProperty("os.name").startsWith("Windows")) {
        DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
        String date = df.format(new Date());
        if (date.charAt(date.length()-1) == ' ') {
            throw new RuntimeException("Windows Host Locale Provider returns a trailing space.");
        }
    } else {
        System.out.println("Windows HOST locale adapter not found. Ignoring this test.");
    }
}
 
Example 8
Source File: LocaleProviders.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
static void bug7198834Test() {
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    if (type == LocaleProviderAdapter.Type.HOST && System.getProperty("os.name").startsWith("Windows")) {
        DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
        String date = df.format(new Date());
        if (date.charAt(date.length()-1) == ' ') {
            throw new RuntimeException("Windows Host Locale Provider returns a trailing space.");
        }
    } else {
        System.out.println("Windows HOST locale adapter not found. Ignoring this test.");
    }
}
 
Example 9
Source File: LocaleProviders.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
static void bug7198834Test() {
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    if (type == LocaleProviderAdapter.Type.HOST && System.getProperty("os.name").startsWith("Windows")) {
        DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
        String date = df.format(new Date());
        if (date.charAt(date.length()-1) == ' ') {
            throw new RuntimeException("Windows Host Locale Provider returns a trailing space.");
        }
    } else {
        System.out.println("Windows HOST locale adapter not found. Ignoring this test.");
    }
}
 
Example 10
Source File: LocaleProviders.java    From jdk8u60 with GNU General Public License v2.0 5 votes vote down vote up
static void bug7198834Test() {
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    if (type == LocaleProviderAdapter.Type.HOST && System.getProperty("os.name").startsWith("Windows")) {
        DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
        String date = df.format(new Date());
        if (date.charAt(date.length()-1) == ' ') {
            throw new RuntimeException("Windows Host Locale Provider returns a trailing space.");
        }
    } else {
        System.out.println("Windows HOST locale adapter not found. Ignoring this test.");
    }
}
 
Example 11
Source File: LocaleProviders.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
static void bug7198834Test() {
    LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US);
    LocaleProviderAdapter.Type type = lda.getAdapterType();
    if (type == LocaleProviderAdapter.Type.HOST && System.getProperty("os.name").startsWith("Windows")) {
        DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US);
        String date = df.format(new Date());
        if (date.charAt(date.length()-1) == ' ') {
            throw new RuntimeException("Windows Host Locale Provider returns a trailing space.");
        }
    } else {
        System.out.println("Windows HOST locale adapter not found. Ignoring this test.");
    }
}
 
Example 12
Source File: LocaleProviders.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 13
Source File: LocaleProviders.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 14
Source File: LocaleProviders.java    From openjdk-jdk8u with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 15
Source File: LocaleProviders.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 16
Source File: LocaleProviders.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 17
Source File: LocaleProviders.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 18
Source File: LocaleProviders.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 19
Source File: LocaleProviders.java    From openjdk-8 with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}
 
Example 20
Source File: LocaleProviders.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
static void bug8010666Test() {
    if (System.getProperty("os.name").startsWith("Windows")) {
        NumberFormat nf = NumberFormat.getInstance(Locale.US);
        try {
            double ver = nf.parse(System.getProperty("os.version"))
                           .doubleValue();
            System.out.printf("Windows version: %.1f\n", ver);
            if (ver >= 6.0) {
                LocaleProviderAdapter lda =
                    LocaleProviderAdapter.getAdapter(
                        LocaleNameProvider.class, Locale.ENGLISH);
                LocaleProviderAdapter.Type type = lda.getAdapterType();
                if (type == LocaleProviderAdapter.Type.HOST) {
                    LocaleNameProvider lnp = lda.getLocaleNameProvider();
                    Locale mkmk = Locale.forLanguageTag("mk-MK");
                    String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
                    String hostResult =
                        lnp.getDisplayLanguage(mkmk.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"mk\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
                    hostResult =
                        lnp.getDisplayLanguage(Locale.US.getLanguage(),
                                               Locale.ENGLISH);
                    System.out.printf("  Display language name for" +
                        " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                        hostResult, result);
                    if (result == null ||
                        hostResult != null &&
                        !result.equals(hostResult)) {
                        throw new RuntimeException("Display language name" +
                            " mismatch for \"en\". Returned name was" +
                            " \"" + result + "\", result(HOST): \"" +
                            hostResult + "\"");
                    }
                    if (ver >= 6.1) {
                        result = Locale.US.getDisplayCountry(Locale.ENGLISH);
                        hostResult = lnp.getDisplayCountry(
                            Locale.US.getCountry(), Locale.ENGLISH);
                        System.out.printf("  Display country name for" +
                            " (en_US): result(HOST): \"%s\", returned: \"%s\"\n",
                            hostResult, result);
                        if (result == null ||
                            hostResult != null &&
                            !result.equals(hostResult)) {
                            throw new RuntimeException("Display country name" +
                                " mismatch for \"US\". Returned name was" +
                                " \"" + result + "\", result(HOST): \"" +
                                hostResult + "\"");
                        }
                    }
                } else {
                    throw new RuntimeException("Windows Host" +
                        " LocaleProviderAdapter was not selected for" +
                        " English locale.");
                }
            }
        } catch (ParseException pe) {
            throw new RuntimeException("Parsing Windows version failed: "+pe.toString());
        }
    }
}