Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openjdk-multiarch-jdk8u
Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/util/Locale/LocaleProviders.sh
38813 views
1
#!/bin/sh
2
#
3
# Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
4
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5
#
6
# This code is free software; you can redistribute it and/or modify it
7
# under the terms of the GNU General Public License version 2 only, as
8
# published by the Free Software Foundation.
9
#
10
# This code is distributed in the hope that it will be useful, but WITHOUT
11
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13
# version 2 for more details (a copy is included in the LICENSE file that
14
# accompanied this code).
15
#
16
# You should have received a copy of the GNU General Public License version
17
# 2 along with this work; if not, write to the Free Software Foundation,
18
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19
#
20
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21
# or visit www.oracle.com if you need additional information or have any
22
# questions.
23
#
24
#
25
# @test
26
# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8010666
27
# 8013086 8013233 8013903 8015960 8028771 8150432
28
# @summary tests for "java.locale.providers" system property
29
# @compile -XDignore.symbol.file LocaleProviders.java
30
# @run shell/timeout=600 LocaleProviders.sh
31
32
if [ "${TESTSRC}" = "" ]
33
then
34
echo "TESTSRC not set. Test cannot execute. Failed."
35
exit 1
36
fi
37
echo "TESTSRC=${TESTSRC}"
38
if [ "${TESTJAVA}" = "" ]
39
then
40
echo "TESTJAVA not set. Test cannot execute. Failed."
41
exit 1
42
fi
43
if [ "${COMPILEJAVA}" = "" ]
44
then
45
COMPILEJAVA="${TESTJAVA}"
46
fi
47
echo "TESTJAVA=${TESTJAVA}"
48
if [ "${TESTCLASSES}" = "" ]
49
then
50
echo "TESTCLASSES not set. Test cannot execute. Failed."
51
exit 1
52
fi
53
echo "TESTCLASSES=${TESTCLASSES}"
54
echo "CLASSPATH=${CLASSPATH}"
55
56
# set platform-dependent variables
57
OS=`uname -s`
58
case "$OS" in
59
SunOS | Linux | *BSD | Darwin | AIX )
60
PS=":"
61
FS="/"
62
;;
63
Windows* | CYGWIN* )
64
PS=";"
65
FS="\\"
66
;;
67
* )
68
echo "Unrecognized system!"
69
exit 1;
70
;;
71
esac
72
73
# create SPI implementations
74
mk() {
75
d=`dirname $1`
76
if [ ! -d $d ]; then mkdir -p $d; fi
77
cat - >$1
78
}
79
80
SPIDIR=${TESTCLASSES}${FS}spi
81
rm -rf ${SPIDIR}
82
mk ${SPIDIR}${FS}src${FS}tznp.java << EOF
83
import java.util.spi.TimeZoneNameProvider;
84
import java.util.Locale;
85
86
public class tznp extends TimeZoneNameProvider {
87
public String getDisplayName(String ID, boolean daylight, int style, Locale locale) {
88
return "tznp";
89
}
90
91
public Locale[] getAvailableLocales() {
92
Locale[] locales = {Locale.US};
93
return locales;
94
}
95
}
96
EOF
97
mk ${SPIDIR}${FS}src${FS}tznp8013086.java << EOF
98
import java.util.spi.TimeZoneNameProvider;
99
import java.util.Locale;
100
import java.util.TimeZone;
101
102
public class tznp8013086 extends TimeZoneNameProvider {
103
public String getDisplayName(String ID, boolean daylight, int style, Locale locale) {
104
if (!daylight && style==TimeZone.LONG) {
105
return "tznp8013086";
106
} else {
107
return null;
108
}
109
}
110
111
public Locale[] getAvailableLocales() {
112
Locale[] locales = {Locale.JAPAN};
113
return locales;
114
}
115
}
116
EOF
117
mk ${SPIDIR}${FS}dest${FS}META-INF${FS}services${FS}java.util.spi.TimeZoneNameProvider << EOF
118
tznp
119
tznp8013086
120
EOF
121
${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${SPIDIR}${FS}dest \
122
${SPIDIR}${FS}src${FS}tznp.java \
123
${SPIDIR}${FS}src${FS}tznp8013086.java
124
${COMPILEJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS} cvf ${SPIDIR}${FS}tznp.jar -C ${SPIDIR}${FS}dest .
125
126
# get the platform default locales
127
PLATDEF=`${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale display`
128
DEFLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
129
DEFCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
130
echo "DEFLANG=${DEFLANG}"
131
echo "DEFCTRY=${DEFCTRY}"
132
PLATDEF=`${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale format`
133
DEFFMTLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
134
DEFFMTCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
135
echo "DEFFMTLANG=${DEFFMTLANG}"
136
echo "DEFFMTCTRY=${DEFFMTCTRY}"
137
138
runTest()
139
{
140
RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
141
echo ${RUNCMD}
142
${RUNCMD}
143
result=$?
144
if [ $result -eq 0 ]
145
then
146
echo "Execution successful"
147
else
148
echo "Execution of the test case failed."
149
exit $result
150
fi
151
}
152
153
# testing HOST is selected for the default locale, if specified on Windows or MacOSX
154
METHODNAME=adapterTest
155
PREFLIST=HOST,JRE
156
case "$OS" in
157
Windows_NT* )
158
WINVER=`uname -r`
159
if [ "${WINVER}" = "5" ]
160
then
161
PARAM1=JRE
162
else
163
PARAM1=HOST
164
fi
165
;;
166
CYGWIN_NT-6* | CYGWIN_NT-10* | Darwin )
167
PARAM1=HOST
168
;;
169
* )
170
PARAM1=JRE
171
;;
172
esac
173
PARAM2=${DEFLANG}
174
PARAM3=${DEFCTRY}
175
runTest
176
177
# testing HOST is NOT selected for the non-default locale, if specified
178
METHODNAME=adapterTest
179
PREFLIST=HOST,JRE
180
PARAM1=JRE
181
# Try to find the locale JRE supports which is not the platform default (HOST supports that one)
182
if [ "${DEFLANG}" != "en" ] && [ "${DEFFMTLANG}" != "en" ]; then
183
PARAM2=en
184
PARAM3=US
185
elif [ "${DEFLANG}" != "ja" ] && [ "${DEFFMTLANG}" != "ja" ]; then
186
PARAM2=ja
187
PARAM3=JP
188
else
189
PARAM2=zh
190
PARAM3=CN
191
fi
192
runTest
193
194
# testing SPI is NOT selected, as there is none.
195
METHODNAME=adapterTest
196
PREFLIST=SPI,JRE
197
PARAM1=JRE
198
PARAM2=en
199
PARAM3=US
200
runTest
201
202
# testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR
203
METHODNAME=adapterTest
204
PREFLIST=CLDR,JRE
205
PARAM1=CLDR
206
PARAM2=en
207
PARAM3=GB
208
runTest
209
210
# testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR
211
METHODNAME=adapterTest
212
PREFLIST=JRE,CLDR
213
PARAM1=JRE
214
PARAM2=en
215
PARAM3=GB
216
runTest
217
218
# testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE.
219
METHODNAME=adapterTest
220
PREFLIST=JRE,CLDR
221
PARAM1=CLDR
222
PARAM2=haw
223
PARAM3=GB
224
runTest
225
226
# testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN"
227
METHODNAME=adapterTest
228
PREFLIST=CLDR
229
PARAM1=CLDR
230
PARAM2=zh
231
PARAM3=CN
232
runTest
233
234
# testing FALLBACK provider. SPI and invalid one cases.
235
METHODNAME=adapterTest
236
PREFLIST=SPI
237
PARAM1=FALLBACK
238
PARAM2=en
239
PARAM3=US
240
runTest
241
PREFLIST=FOO
242
PARAM1=JRE
243
PARAM2=en
244
PARAM3=US
245
runTest
246
PREFLIST=BAR,SPI
247
PARAM1=FALLBACK
248
PARAM2=en
249
PARAM3=US
250
runTest
251
252
# testing 7198834 fix. Only works on Windows Vista or upper.
253
METHODNAME=bug7198834Test
254
PREFLIST=HOST
255
PARAM1=
256
PARAM2=
257
PARAM3=
258
runTest
259
260
# testing 8000245 fix.
261
METHODNAME=tzNameTest
262
PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
263
PARAM1=Europe/Moscow
264
PARAM2=
265
PARAM3=
266
runTest
267
268
# testing 8000615 fix.
269
METHODNAME=tzNameTest
270
PREFLIST="JRE -Djava.ext.dirs=${SPIDIR}"
271
PARAM1=America/Los_Angeles
272
PARAM2=
273
PARAM3=
274
runTest
275
276
# testing 8001440 fix.
277
METHODNAME=bug8001440Test
278
PREFLIST=CLDR
279
PARAM1=
280
PARAM2=
281
PARAM3=
282
runTest
283
284
# testing 8010666 fix.
285
if [ "${DEFLANG}" = "en" ]
286
then
287
METHODNAME=bug8010666Test
288
PREFLIST=HOST
289
PARAM1=
290
PARAM2=
291
PARAM3=
292
runTest
293
fi
294
295
# testing 8013086 fix.
296
METHODNAME=bug8013086Test
297
PREFLIST="JRE,SPI -Djava.ext.dirs=${SPIDIR}"
298
PARAM1=ja
299
PARAM2=JP
300
PARAM3=
301
runTest
302
303
# testing 8013903 fix. (Windows only)
304
METHODNAME=bug8013903Test
305
PREFLIST=HOST,JRE
306
PARAM1=
307
PARAM2=
308
PARAM3=
309
runTest
310
METHODNAME=bug8013903Test
311
PREFLIST=HOST
312
PARAM1=
313
PARAM2=
314
PARAM3=
315
runTest
316
317
exit $result
318
319