author | shurailine |
Mon, 08 Feb 2016 18:14:48 -0800 | |
changeset 35768 | 7066da300a08 |
parent 32772 | dcf1f63aa63f |
permissions | -rw-r--r-- |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
1 |
/* |
35768
7066da300a08
8149391: Fix module dependences in java/util tests
shurailine
parents:
32772
diff
changeset
|
2 |
* Copyright (c) 2012, 2016, Oracle and/or its affiliates. All rights reserved. |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
4 |
* |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
21596 | 7 |
* published by the Free Software Foundation. |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
8 |
* |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
13 |
* accompanied this code). |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
14 |
* |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
18 |
* |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
21 |
* questions. |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
22 |
*/ |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
23 |
|
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
24 |
/* |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
25 |
* @test |
32772
dcf1f63aa63f
8136518: java/util/TimeZone/CLDRDisplayNamesTest.java fails for de.
naoto
parents:
32093
diff
changeset
|
26 |
* @bug 8005471 8008577 8129881 8130845 8136518 |
35768
7066da300a08
8149391: Fix module dependences in java/util tests
shurailine
parents:
32772
diff
changeset
|
27 |
* @modules jdk.localedata |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
28 |
* @run main/othervm -Djava.locale.providers=CLDR CLDRDisplayNamesTest |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
29 |
* @summary Make sure that localized time zone names of CLDR are used |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
30 |
* if specified. |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
31 |
*/ |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
32 |
|
32015 | 33 |
import java.text.*; |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
34 |
import java.util.*; |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
35 |
import static java.util.TimeZone.*; |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
36 |
|
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
37 |
public class CLDRDisplayNamesTest { |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
38 |
/* |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
39 |
* The first element is a language tag. The rest are localized |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
40 |
* display names of America/Los_Angeles copied from the CLDR |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
41 |
* resources data. If data change in CLDR, test data below will |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
42 |
* need to be changed accordingly. |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
43 |
* |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
44 |
* Generic names are NOT tested (until they are supported by API). |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
45 |
*/ |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
46 |
static final String[][] CLDR_DATA = { |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
47 |
{ |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
48 |
"ja-JP", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
49 |
"\u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u6a19\u6e96\u6642", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
50 |
"PST", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
51 |
"\u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u590f\u6642\u9593", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
52 |
"PDT", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
53 |
//"\u30a2\u30e1\u30ea\u30ab\u592a\u5e73\u6d0b\u6642\u9593", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
54 |
//"PT" |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
55 |
}, |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
56 |
{ |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
57 |
"zh-CN", |
31263 | 58 |
"\u5317\u7f8e\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4", |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
59 |
"PST", |
31263 | 60 |
"\u5317\u7f8e\u592a\u5e73\u6d0b\u590f\u4ee4\u65f6\u95f4", |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
61 |
"PDT", |
31263 | 62 |
//"\u5317\u7f8e\u592a\u5e73\u6d0b\u65f6\u95f4", |
63 |
//"PT", |
|
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
64 |
}, |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
65 |
{ |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
66 |
"de-DE", |
31263 | 67 |
"Nordamerikanische Westk\u00fcsten-Normalzeit", |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
68 |
"PST", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
69 |
"Nordamerikanische Westk\u00fcsten-Sommerzeit", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
70 |
"PDT", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
71 |
//"Nordamerikanische Westk\u00fcstenzeit", |
31263 | 72 |
//"PT", |
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
73 |
}, |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
74 |
}; |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
75 |
|
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
76 |
public static void main(String[] args) { |
32015 | 77 |
// Make sure that localized time zone names of CLDR are used |
78 |
// if specified. |
|
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
79 |
TimeZone tz = TimeZone.getTimeZone("America/Los_Angeles"); |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
80 |
int errors = 0; |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
81 |
for (String[] data : CLDR_DATA) { |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
82 |
Locale locale = Locale.forLanguageTag(data[0]); |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
83 |
for (int i = 1; i < data.length; i++) { |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
84 |
int style = ((i % 2) == 1) ? LONG : SHORT; |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
85 |
boolean daylight = (i == 3 || i == 4); |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
86 |
String name = tz.getDisplayName(daylight, style, locale); |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
87 |
if (!data[i].equals(name)) { |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
88 |
System.err.printf("error: got '%s' expected '%s' (style=%d, daylight=%s, locale=%s)%n", |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
89 |
name, data[i], style, daylight, locale); |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
90 |
errors++; |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
91 |
} |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
92 |
} |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
93 |
} |
32015 | 94 |
|
95 |
// for 8129881 |
|
96 |
tz = TimeZone.getTimeZone("Europe/Vienna"); |
|
32772
dcf1f63aa63f
8136518: java/util/TimeZone/CLDRDisplayNamesTest.java fails for de.
naoto
parents:
32093
diff
changeset
|
97 |
String name = tz.getDisplayName(false, SHORT, Locale.ENGLISH); |
32015 | 98 |
if (!"CET".equals(name)) { |
99 |
System.err.printf("error: got '%s' expected 'CET' %n", name); |
|
100 |
errors++; |
|
101 |
} |
|
102 |
||
103 |
// for 8130845 |
|
104 |
SimpleDateFormat fmtROOT = new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy", Locale.ROOT); |
|
105 |
SimpleDateFormat fmtUS = new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy", Locale.US); |
|
106 |
SimpleDateFormat fmtUK = new SimpleDateFormat("EEE MMM d hh:mm:ss z yyyy", Locale.UK); |
|
107 |
Locale originalLocale = Locale.getDefault(); |
|
108 |
try { |
|
109 |
Locale.setDefault(Locale.ROOT); |
|
110 |
fmtROOT.parse("Thu Nov 13 04:35:51 AKST 2008"); |
|
111 |
fmtUS.parse("Thu Nov 13 04:35:51 AKST 2008"); |
|
112 |
fmtUK.parse("Thu Nov 13 04:35:51 GMT-09:00 2008"); |
|
113 |
} catch (ParseException pe) { |
|
114 |
System.err.println(pe); |
|
115 |
errors++; |
|
116 |
} finally { |
|
117 |
Locale.setDefault(originalLocale); |
|
118 |
} |
|
119 |
||
14926
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
120 |
if (errors > 0) { |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
121 |
throw new RuntimeException("test failed"); |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
122 |
} |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
123 |
} |
1cb5d2255451
8005471: DateFormat: Time zone info is not localized when adapter is CLDR
okutsu
parents:
diff
changeset
|
124 |
} |