author | naoto |
Tue, 12 Nov 2019 14:05:18 -0800 | |
changeset 59043 | 1a79b4bfc85a |
parent 58972 | dc998d4a227e |
permissions | -rw-r--r-- |
13583 | 1 |
/* |
53163
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
2 |
* Copyright (c) 2012, 2019, Oracle and/or its affiliates. All rights reserved. |
13583 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. |
|
8 |
* |
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
13 |
* accompanied this code). |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License version |
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
18 |
* |
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
22 |
*/ |
|
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
23 |
import java.text.*; |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
24 |
import java.text.spi.*; |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
25 |
import java.util.*; |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
26 |
import java.util.spi.*; |
59043
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
27 |
import java.util.stream.IntStream; |
13583 | 28 |
import sun.util.locale.provider.LocaleProviderAdapter; |
29 |
||
30 |
public class LocaleProviders { |
|
31 |
||
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
32 |
private static final boolean IS_WINDOWS = System.getProperty("os.name").startsWith("Windows"); |
58972
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
33 |
private static final boolean IS_MAC = System.getProperty("os.name").startsWith("Mac"); |
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
34 |
|
13583 | 35 |
public static void main(String[] args) { |
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
36 |
String methodName = args[0]; |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
37 |
|
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
38 |
switch (methodName) { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
39 |
case "getPlatformLocale": |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
40 |
if (args[1].equals("format")) { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
41 |
getPlatformLocale(Locale.Category.FORMAT); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
42 |
} else { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
43 |
getPlatformLocale(Locale.Category.DISPLAY); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
44 |
} |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
45 |
break; |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
46 |
|
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
47 |
case "adapterTest": |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
48 |
adapterTest(args[1], args[2], (args.length >= 4 ? args[3] : "")); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
49 |
break; |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
50 |
|
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
51 |
case "bug7198834Test": |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
52 |
bug7198834Test(); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
53 |
break; |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
54 |
|
14185
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
55 |
case "tzNameTest": |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
56 |
tzNameTest(args[1]); |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
57 |
break; |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
58 |
|
14336
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
59 |
case "bug8001440Test": |
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
60 |
bug8001440Test(); |
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
61 |
break; |
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
62 |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
63 |
case "bug8010666Test": |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
64 |
bug8010666Test(); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
65 |
break; |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
66 |
|
17440
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
67 |
case "bug8013086Test": |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
68 |
bug8013086Test(args[1], args[2]); |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
69 |
break; |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
70 |
|
17944
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
71 |
case "bug8013903Test": |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
72 |
bug8013903Test(); |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
73 |
break; |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
74 |
|
22989
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
75 |
case "bug8027289Test": |
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
76 |
bug8027289Test(args[1]); |
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
77 |
break; |
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
78 |
|
54097
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
79 |
case "bug8220227Test": |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
80 |
bug8220227Test(); |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
81 |
break; |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
82 |
|
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
83 |
case "bug8228465Test": |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
84 |
bug8228465Test(); |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
85 |
break; |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
86 |
|
58972
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
87 |
case "bug8232871Test": |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
88 |
bug8232871Test(); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
89 |
break; |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
90 |
|
59043
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
91 |
case "bug8232860Test": |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
92 |
bug8232860Test(); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
93 |
break; |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
94 |
|
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
95 |
default: |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
96 |
throw new RuntimeException("Test method '"+methodName+"' not found."); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
97 |
} |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
98 |
} |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
99 |
|
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
100 |
static void getPlatformLocale(Locale.Category cat) { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
101 |
Locale defloc = Locale.getDefault(cat); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
102 |
System.out.printf("%s,%s\n", defloc.getLanguage(), defloc.getCountry()); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
103 |
} |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
104 |
|
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
105 |
static void adapterTest(String expected, String lang, String ctry) { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
106 |
Locale testLocale = new Locale(lang, ctry); |
21853
8aa7444a01a8
8028771: regression test java/util/Locale/LocaleProviders.sh failed
naoto
parents:
18539
diff
changeset
|
107 |
LocaleProviderAdapter ldaExpected = |
8aa7444a01a8
8028771: regression test java/util/Locale/LocaleProviders.sh failed
naoto
parents:
18539
diff
changeset
|
108 |
LocaleProviderAdapter.forType(LocaleProviderAdapter.Type.valueOf(expected)); |
8aa7444a01a8
8028771: regression test java/util/Locale/LocaleProviders.sh failed
naoto
parents:
18539
diff
changeset
|
109 |
if (!ldaExpected.getDateFormatProvider().isSupportedLocale(testLocale)) { |
8aa7444a01a8
8028771: regression test java/util/Locale/LocaleProviders.sh failed
naoto
parents:
18539
diff
changeset
|
110 |
System.out.println("test locale: "+testLocale+" is not supported by the expected provider: "+ldaExpected+". Ignoring the test."); |
8aa7444a01a8
8028771: regression test java/util/Locale/LocaleProviders.sh failed
naoto
parents:
18539
diff
changeset
|
111 |
return; |
8aa7444a01a8
8028771: regression test java/util/Locale/LocaleProviders.sh failed
naoto
parents:
18539
diff
changeset
|
112 |
} |
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
113 |
String preference = System.getProperty("java.locale.providers", ""); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
114 |
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, testLocale); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
115 |
LocaleProviderAdapter.Type type = lda.getAdapterType(); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
116 |
System.out.printf("testLocale: %s, got: %s, expected: %s\n", testLocale, type, expected); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
117 |
if (!type.toString().equals(expected)) { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
118 |
throw new RuntimeException("Returned locale data adapter is not correct."); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
119 |
} |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
120 |
} |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
121 |
|
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
122 |
static void bug7198834Test() { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
123 |
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(DateFormatProvider.class, Locale.US); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
124 |
LocaleProviderAdapter.Type type = lda.getAdapterType(); |
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
125 |
if (type == LocaleProviderAdapter.Type.HOST && IS_WINDOWS) { |
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
126 |
DateFormat df = DateFormat.getDateInstance(DateFormat.FULL, Locale.US); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
127 |
String date = df.format(new Date()); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
128 |
if (date.charAt(date.length()-1) == ' ') { |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
129 |
throw new RuntimeException("Windows Host Locale Provider returns a trailing space."); |
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
130 |
} |
14024
694c379c2958
7196799: CLDR adapter can not be invoked when region code is specified in Locale
naoto
parents:
13583
diff
changeset
|
131 |
} else { |
14028
5f3d5ae5f1ea
7198834: HOST Adapter: one extra empty space in the end of the pattern string
naoto
parents:
14024
diff
changeset
|
132 |
System.out.println("Windows HOST locale adapter not found. Ignoring this test."); |
13583 | 133 |
} |
134 |
} |
|
14185
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
135 |
|
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
136 |
static void tzNameTest(String id) { |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
137 |
TimeZone tz = TimeZone.getTimeZone(id); |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
138 |
String tzName = tz.getDisplayName(false, TimeZone.SHORT, Locale.US); |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
139 |
if (tzName.startsWith("GMT")) { |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
140 |
throw new RuntimeException("JRE's localized time zone name for "+id+" could not be retrieved. Returned name was: "+tzName); |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
141 |
} |
916ec0a4d039
8000245: SimpleDateFormat.format(date, StringBuffer, FieldPosition) doesn't work as expected with custom extensions
naoto
parents:
14028
diff
changeset
|
142 |
} |
14336
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
143 |
|
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
144 |
static void bug8001440Test() { |
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
145 |
Locale locale = Locale.forLanguageTag("th-TH-u-nu-hoge"); |
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
146 |
NumberFormat nf = NumberFormat.getInstance(locale); |
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
147 |
String nu = nf.format(1234560); |
4a3418a2c07f
8001440: CLDR adapter: Invalid number extension in language tag causes exception in NumberFormat.format()
naoto
parents:
14185
diff
changeset
|
148 |
} |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
149 |
|
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
150 |
// This test assumes Windows localized language/country display names. |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
151 |
static void bug8010666Test() { |
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
152 |
if (IS_WINDOWS) { |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
153 |
NumberFormat nf = NumberFormat.getInstance(Locale.US); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
154 |
try { |
17476 | 155 |
double ver = nf.parse(System.getProperty("os.version")) |
156 |
.doubleValue(); |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
157 |
System.out.printf("Windows version: %.1f\n", ver); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
158 |
if (ver >= 6.0) { |
17476 | 159 |
LocaleProviderAdapter lda = |
160 |
LocaleProviderAdapter.getAdapter( |
|
161 |
LocaleNameProvider.class, Locale.ENGLISH); |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
162 |
LocaleProviderAdapter.Type type = lda.getAdapterType(); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
163 |
if (type == LocaleProviderAdapter.Type.HOST) { |
17476 | 164 |
LocaleNameProvider lnp = lda.getLocaleNameProvider(); |
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
165 |
Locale mkmk = Locale.forLanguageTag("mk-MK"); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
166 |
String result = mkmk.getDisplayLanguage(Locale.ENGLISH); |
17476 | 167 |
String hostResult = |
168 |
lnp.getDisplayLanguage(mkmk.getLanguage(), |
|
169 |
Locale.ENGLISH); |
|
170 |
System.out.printf(" Display language name for" + |
|
171 |
" (mk_MK): result(HOST): \"%s\", returned: \"%s\"\n", |
|
172 |
hostResult, result); |
|
173 |
if (result == null || |
|
174 |
hostResult != null && |
|
175 |
!result.equals(hostResult)) { |
|
176 |
throw new RuntimeException("Display language name" + |
|
177 |
" mismatch for \"mk\". Returned name was" + |
|
178 |
" \"" + result + "\", result(HOST): \"" + |
|
179 |
hostResult + "\""); |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
180 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
181 |
result = Locale.US.getDisplayLanguage(Locale.ENGLISH); |
17476 | 182 |
hostResult = |
183 |
lnp.getDisplayLanguage(Locale.US.getLanguage(), |
|
184 |
Locale.ENGLISH); |
|
185 |
System.out.printf(" Display language name for" + |
|
186 |
" (en_US): result(HOST): \"%s\", returned: \"%s\"\n", |
|
187 |
hostResult, result); |
|
188 |
if (result == null || |
|
189 |
hostResult != null && |
|
190 |
!result.equals(hostResult)) { |
|
191 |
throw new RuntimeException("Display language name" + |
|
192 |
" mismatch for \"en\". Returned name was" + |
|
193 |
" \"" + result + "\", result(HOST): \"" + |
|
194 |
hostResult + "\""); |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
195 |
} |
17476 | 196 |
if (ver >= 6.1) { |
197 |
result = Locale.US.getDisplayCountry(Locale.ENGLISH); |
|
198 |
hostResult = lnp.getDisplayCountry( |
|
199 |
Locale.US.getCountry(), Locale.ENGLISH); |
|
200 |
System.out.printf(" Display country name for" + |
|
201 |
" (en_US): result(HOST): \"%s\", returned: \"%s\"\n", |
|
202 |
hostResult, result); |
|
203 |
if (result == null || |
|
204 |
hostResult != null && |
|
205 |
!result.equals(hostResult)) { |
|
206 |
throw new RuntimeException("Display country name" + |
|
207 |
" mismatch for \"US\". Returned name was" + |
|
208 |
" \"" + result + "\", result(HOST): \"" + |
|
209 |
hostResult + "\""); |
|
210 |
} |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
211 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
212 |
} else { |
17476 | 213 |
throw new RuntimeException("Windows Host" + |
214 |
" LocaleProviderAdapter was not selected for" + |
|
215 |
" English locale."); |
|
17169
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
216 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
217 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
218 |
} catch (ParseException pe) { |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
219 |
throw new RuntimeException("Parsing Windows version failed: "+pe.toString()); |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
220 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
221 |
} |
5e5039c3181d
8010666: Implement Currency/LocaleNameProvider in Windows Host LocaleProviderAdapter
naoto
parents:
14336
diff
changeset
|
222 |
} |
17440
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
223 |
|
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
224 |
static void bug8013086Test(String lang, String ctry) { |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
225 |
try { |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
226 |
// Throws a NullPointerException if the test fails. |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
227 |
System.out.println(new SimpleDateFormat("z", new Locale(lang, ctry)).parse("UTC")); |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
228 |
} catch (ParseException pe) { |
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
229 |
// ParseException is fine in this test, as it's not "UTC" |
13583 | 230 |
} |
17440
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
231 |
} |
17944
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
232 |
|
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
233 |
static void bug8013903Test() { |
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
234 |
if (IS_WINDOWS) { |
17944
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
235 |
Date sampleDate = new Date(0x10000000000L); |
34878
7d7e55ff253a
8039301: [ja] Host Locale Provider uses non-translated Calendar field names
naoto
parents:
22989
diff
changeset
|
236 |
String hostResult = "\u5e73\u6210 16.11.03 (Wed) AM 11:53:47"; |
17944
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
237 |
String jreResult = "\u5e73\u6210 16.11.03 (\u6c34) \u5348\u524d 11:53:47"; |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
238 |
Locale l = new Locale("ja", "JP", "JP"); |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
239 |
SimpleDateFormat sdf = new SimpleDateFormat("GGGG yyyy.MMM.dd '('E')' a hh:mm:ss", l); |
18539
cc30fa6fcf7c
6863624: java/util/Currency/PropertiesTest.sh writable check is incorrect
naoto
parents:
18162
diff
changeset
|
240 |
sdf.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles")); |
17944
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
241 |
String result = sdf.format(sampleDate); |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
242 |
System.out.println(result); |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
243 |
if (LocaleProviderAdapter.getAdapterPreference() |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
244 |
.contains(LocaleProviderAdapter.Type.JRE)) { |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
245 |
if (!jreResult.equals(result)) { |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
246 |
throw new RuntimeException("Format failed. result: \"" + |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
247 |
result + "\", expected: \"" + jreResult); |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
248 |
} |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
249 |
} else { |
34878
7d7e55ff253a
8039301: [ja] Host Locale Provider uses non-translated Calendar field names
naoto
parents:
22989
diff
changeset
|
250 |
// Windows display names. Subject to change if Windows changes its format. |
7d7e55ff253a
8039301: [ja] Host Locale Provider uses non-translated Calendar field names
naoto
parents:
22989
diff
changeset
|
251 |
if (!hostResult.equals(result)) { |
17944
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
252 |
throw new RuntimeException("Format failed. result: \"" + |
34878
7d7e55ff253a
8039301: [ja] Host Locale Provider uses non-translated Calendar field names
naoto
parents:
22989
diff
changeset
|
253 |
result + "\", expected: \"" + hostResult); |
17944
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
254 |
} |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
255 |
} |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
256 |
} |
bbd67fc49daa
8013903: Japanese calendar field names are not displayed with -Djava.locale.providers=HOST on Windows
naoto
parents:
17476
diff
changeset
|
257 |
} |
22989
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
258 |
|
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
259 |
static void bug8027289Test(String expectedCodePoint) { |
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
260 |
if (IS_WINDOWS) { |
53163
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
261 |
char[] expectedSymbol = Character.toChars(Integer.valueOf(expectedCodePoint, 16)); |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
262 |
NumberFormat nf = NumberFormat.getCurrencyInstance(Locale.CHINA); |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
263 |
char formatted = nf.format(7000).charAt(0); |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
264 |
System.out.println("returned: " + formatted + ", expected: " + expectedSymbol[0]); |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
265 |
if (formatted != expectedSymbol[0]) { |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
266 |
throw new RuntimeException( |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
267 |
"Unexpected Chinese currency symbol. returned: " |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
268 |
+ formatted + ", expected: " + expectedSymbol[0]); |
76f7dbf458fe
8215913: [Test_bug]java/util/Locale/LocaleProvidersRun.java failed on de_DE and ja_JP locale.
dzhou
parents:
47216
diff
changeset
|
269 |
} |
22989
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
270 |
} |
2d6804cfdc0e
8027289: [Windows zh_CN] NumberFormat: Incorrect sequence of loading currency symbol
naoto
parents:
21853
diff
changeset
|
271 |
} |
54097
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
272 |
|
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
273 |
static void bug8220227Test() { |
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
274 |
if (IS_WINDOWS) { |
54097
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
275 |
Locale l = new Locale("xx","XX"); |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
276 |
String country = l.getDisplayCountry(); |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
277 |
if (country.endsWith("(XX)")) { |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
278 |
throw new RuntimeException( |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
279 |
"Unexpected Region name: " + country); |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
280 |
} |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
281 |
} |
9fc262a75638
8220227: Host Locale Provider getDisplayCountry returns error message under non-English Win10
tnakamura
parents:
53163
diff
changeset
|
282 |
} |
57549
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
283 |
|
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
284 |
static void bug8228465Test() { |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
285 |
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US); |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
286 |
LocaleProviderAdapter.Type type = lda.getAdapterType(); |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
287 |
if (type == LocaleProviderAdapter.Type.HOST && IS_WINDOWS) { |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
288 |
var names = new GregorianCalendar() |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
289 |
.getDisplayNames(Calendar.ERA, Calendar.SHORT_FORMAT, Locale.US); |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
290 |
if (!names.keySet().contains("AD") || |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
291 |
names.get("AD").intValue() != 1) { |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
292 |
throw new RuntimeException( |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
293 |
"Short Era name for 'AD' is missing or incorrect"); |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
294 |
} else { |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
295 |
System.out.println("bug8228465Test succeeded."); |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
296 |
} |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
297 |
} |
bfe9696bf57f
8228465: HOST locale provider holds wrong era name for GregorianCalendar in US locale
naoto
parents:
54097
diff
changeset
|
298 |
} |
58972
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
299 |
|
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
300 |
static void bug8232871Test() { |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
301 |
LocaleProviderAdapter lda = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
302 |
LocaleProviderAdapter.Type type = lda.getAdapterType(); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
303 |
var lang = Locale.getDefault().getLanguage(); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
304 |
var cal = Calendar.getInstance(); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
305 |
var calType = cal.getCalendarType(); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
306 |
var expected = "\u4ee4\u548c1\u5e745\u67081\u65e5 \u6c34\u66dc\u65e5 \u5348\u524d0:00:00 \u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593"; |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
307 |
|
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
308 |
if (type == LocaleProviderAdapter.Type.HOST && |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
309 |
IS_MAC && |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
310 |
lang.equals("ja") && |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
311 |
calType.equals("japanese")) { |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
312 |
cal.set(1, 4, 1, 0, 0, 0); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
313 |
cal.setTimeZone(TimeZone.getTimeZone("America/Los_Angeles")); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
314 |
DateFormat df = DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL, |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
315 |
Locale.JAPAN); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
316 |
df.setCalendar(cal); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
317 |
var result = df.format(cal.getTime()); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
318 |
if (result.equals(expected)) { |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
319 |
System.out.println("bug8232871Test succeeded."); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
320 |
} else { |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
321 |
throw new RuntimeException( |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
322 |
"Japanese calendar names mismatch. result: " + |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
323 |
result + |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
324 |
", expected: " + |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
325 |
expected); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
326 |
} |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
327 |
} else { |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
328 |
System.out.println("Test ignored. Either :-\n" + |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
329 |
"OS is not macOS, or\n" + |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
330 |
"provider is not HOST: " + type + ", or\n" + |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
331 |
"Language is not Japanese: " + lang + ", or\n" + |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
332 |
"native calendar is not JapaneseCalendar: " + calType); |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
333 |
} |
dc998d4a227e
8232871: Host Locale Provider on Mac does not return translated values of Japanese calendar
naoto
parents:
57549
diff
changeset
|
334 |
} |
59043
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
335 |
|
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
336 |
static void bug8232860Test() { |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
337 |
var inputList = List.of(123, 123.4); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
338 |
var nfExpectedList = List.of("123", "123.4"); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
339 |
var ifExpectedList = List.of("123", "123"); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
340 |
|
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
341 |
var type = LocaleProviderAdapter.getAdapter(CalendarNameProvider.class, Locale.US) |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
342 |
.getAdapterType(); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
343 |
if (type == LocaleProviderAdapter.Type.HOST && (IS_WINDOWS || IS_MAC)) { |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
344 |
final var numf = NumberFormat.getNumberInstance(Locale.US); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
345 |
final var intf = NumberFormat.getIntegerInstance(Locale.US); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
346 |
|
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
347 |
IntStream.range(0, inputList.size()) |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
348 |
.forEach(i -> { |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
349 |
var input = inputList.get(i); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
350 |
var nfExpected = nfExpectedList.get(i); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
351 |
var result = numf.format(input); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
352 |
if (!result.equals(nfExpected)) { |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
353 |
throw new RuntimeException("Incorrect number format. " + |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
354 |
"input: " + input + ", expected: " + |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
355 |
nfExpected + ", result: " + result); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
356 |
} |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
357 |
|
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
358 |
var ifExpected = ifExpectedList.get(i); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
359 |
result = intf.format(input); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
360 |
if (!result.equals(ifExpected)) { |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
361 |
throw new RuntimeException("Incorrect integer format. " + |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
362 |
"input: " + input + ", expected: " + |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
363 |
ifExpected + ", result: " + result); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
364 |
} |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
365 |
}); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
366 |
System.out.println("bug8232860Test succeeded."); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
367 |
} else { |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
368 |
System.out.println("Test ignored. Either :-\n" + |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
369 |
"OS is neither macOS/Windows, or\n" + |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
370 |
"provider is not HOST: " + type); |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
371 |
} |
1a79b4bfc85a
8232860: Error formatting integer values with MessageFormat.format() using HOST provider
naoto
parents:
58972
diff
changeset
|
372 |
} |
17440
fb37aa6b305e
8013086: NPE thrown by SimpleDateFormat with TimeZoneNameProvider supplied
naoto
parents:
17169
diff
changeset
|
373 |
} |