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

The following examples show how to use sun.util.locale.provider.LocaleProviderAdapter#getLocaleNameProvider() . 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 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 2
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 3
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 4
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 5
Source File: LocaleProviders.java    From openjdk-jdk8u-backup 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 6
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 7
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 8
Source File: LocaleProviders.java    From hottub 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 9
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());
        }
    }
}
 
Example 10
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 11
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 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 jdk8u-dev-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());
        }
    }
}