8013233: java/util/Locale/LocaleProviders.sh fails
Reviewed-by: okutsu
This commit is contained in:
parent
40a5f1f53c
commit
41c159f597
@ -118,27 +118,67 @@ public class LocaleProviders {
|
|||||||
if (System.getProperty("os.name").startsWith("Windows")) {
|
if (System.getProperty("os.name").startsWith("Windows")) {
|
||||||
NumberFormat nf = NumberFormat.getInstance(Locale.US);
|
NumberFormat nf = NumberFormat.getInstance(Locale.US);
|
||||||
try {
|
try {
|
||||||
double ver = nf.parse(System.getProperty("os.version")).doubleValue();
|
double ver = nf.parse(System.getProperty("os.version"))
|
||||||
|
.doubleValue();
|
||||||
System.out.printf("Windows version: %.1f\n", ver);
|
System.out.printf("Windows version: %.1f\n", ver);
|
||||||
if (ver >= 6.0) {
|
if (ver >= 6.0) {
|
||||||
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(LocaleNameProvider.class, Locale.ENGLISH);
|
LocaleProviderAdapter lda =
|
||||||
|
LocaleProviderAdapter.getAdapter(
|
||||||
|
LocaleNameProvider.class, Locale.ENGLISH);
|
||||||
LocaleProviderAdapter.Type type = lda.getAdapterType();
|
LocaleProviderAdapter.Type type = lda.getAdapterType();
|
||||||
if (type == LocaleProviderAdapter.Type.HOST) {
|
if (type == LocaleProviderAdapter.Type.HOST) {
|
||||||
|
LocaleNameProvider lnp = lda.getLocaleNameProvider();
|
||||||
Locale mkmk = Locale.forLanguageTag("mk-MK");
|
Locale mkmk = Locale.forLanguageTag("mk-MK");
|
||||||
String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
|
String result = mkmk.getDisplayLanguage(Locale.ENGLISH);
|
||||||
if (!"Macedonian (FYROM)".equals(result)) {
|
String hostResult =
|
||||||
throw new RuntimeException("Windows locale name provider did not return expected localized language name for \"mk\". Returned name was \"" + result + "\"");
|
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);
|
result = Locale.US.getDisplayLanguage(Locale.ENGLISH);
|
||||||
if (!"English".equals(result)) {
|
hostResult =
|
||||||
throw new RuntimeException("Windows locale name provider did not return expected localized language name for \"en\". Returned name was \"" + result + "\"");
|
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 + "\"");
|
||||||
}
|
}
|
||||||
result = Locale.US.getDisplayCountry(Locale.ENGLISH);
|
if (ver >= 6.1) {
|
||||||
if (ver >= 6.1 && !"United States".equals(result)) {
|
result = Locale.US.getDisplayCountry(Locale.ENGLISH);
|
||||||
throw new RuntimeException("Windows locale name provider did not return expected localized country name for \"US\". Returned name was \"" + result + "\"");
|
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 {
|
} else {
|
||||||
throw new RuntimeException("Windows Host LocaleProviderAdapter was not selected for English locale.");
|
throw new RuntimeException("Windows Host" +
|
||||||
|
" LocaleProviderAdapter was not selected for" +
|
||||||
|
" English locale.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (ParseException pe) {
|
} catch (ParseException pe) {
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
#
|
#
|
||||||
# @test
|
# @test
|
||||||
# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8010666
|
# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8010666
|
||||||
# 8013086
|
# 8013086 8013233
|
||||||
# @summary tests for "java.locale.providers" system property
|
# @summary tests for "java.locale.providers" system property
|
||||||
# @compile -XDignore.symbol.file LocaleProviders.java
|
# @compile -XDignore.symbol.file LocaleProviders.java
|
||||||
# @run shell/timeout=600 LocaleProviders.sh
|
# @run shell/timeout=600 LocaleProviders.sh
|
||||||
|
Loading…
Reference in New Issue
Block a user