Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/sun/util/resources/cldr/TimeZoneNamesTest.java
41153 views
1
/*
2
* Copyright (c) 2018, 2021, Oracle and/or its affiliates. All rights reserved.
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
*/
23
24
/*
25
* @test
26
* @bug 8181157 8202537 8234347 8236548 8261279
27
* @modules jdk.localedata
28
* @summary Checks CLDR time zone names are generated correctly at runtime
29
* @run testng/othervm -Djava.locale.providers=CLDR TimeZoneNamesTest
30
*/
31
32
import java.text.DateFormatSymbols;
33
import java.time.ZoneId;
34
import java.time.format.TextStyle;
35
import java.util.Arrays;
36
import java.util.Locale;
37
import java.util.Objects;
38
import java.util.TimeZone;
39
40
import static org.testng.Assert.assertEquals;
41
import static org.testng.Assert.assertFalse;
42
import org.testng.annotations.DataProvider;
43
import org.testng.annotations.Test;
44
45
@Test
46
public class TimeZoneNamesTest {
47
48
@DataProvider(name="noResourceTZs")
49
Object[][] data() {
50
return new Object[][] {
51
// tzid, locale, style, expected
52
53
// This list is as of CLDR version 33, and should be examined
54
// on the CLDR data upgrade.
55
56
// no "metazone" zones
57
{"Asia/Srednekolymsk", Locale.US, "Srednekolymsk Standard Time",
58
"GMT+11:00",
59
"Srednekolymsk Daylight Time",
60
"GMT+11:00",
61
"Srednekolymsk Time",
62
"GMT+11:00"},
63
{"Asia/Srednekolymsk", Locale.FRANCE, "Srednekolymsk (heure standard)",
64
"UTC+11:00",
65
"Srednekolymsk (heure d\u2019\u00e9t\u00e9)",
66
"UTC+11:00",
67
"heure : Srednekolymsk",
68
"UTC+11:00"},
69
{"America/Punta_Arenas", Locale.US, "Punta Arenas Standard Time",
70
"GMT-03:00",
71
"Punta Arenas Daylight Time",
72
"GMT-03:00",
73
"Punta Arenas Time",
74
"GMT-03:00"},
75
{"America/Punta_Arenas", Locale.FRANCE, "Punta Arenas (heure standard)",
76
"UTC\u221203:00",
77
"Punta Arenas (heure d\u2019\u00e9t\u00e9)",
78
"UTC\u221203:00",
79
"heure : Punta Arenas",
80
"UTC\u221203:00"},
81
{"Asia/Famagusta", Locale.US, "Famagusta Standard Time",
82
"GMT+02:00",
83
"Famagusta Daylight Time",
84
"GMT+03:00",
85
"Famagusta Time",
86
"GMT+02:00"},
87
{"Asia/Famagusta", Locale.FRANCE, "Famagouste (heure standard)",
88
"UTC+02:00",
89
"Famagouste (heure d\u2019\u00e9t\u00e9)",
90
"UTC+03:00",
91
"heure : Famagouste",
92
"UTC+02:00"},
93
{"Europe/Astrakhan", Locale.US, "Astrakhan Standard Time",
94
"GMT+04:00",
95
"Astrakhan Daylight Time",
96
"GMT+04:00",
97
"Astrakhan Time",
98
"GMT+04:00"},
99
{"Europe/Astrakhan", Locale.FRANCE, "Astrakhan (heure standard)",
100
"UTC+04:00",
101
"Astrakhan (heure d\u2019\u00e9t\u00e9)",
102
"UTC+04:00",
103
"heure : Astrakhan",
104
"UTC+04:00"},
105
{"Europe/Saratov", Locale.US, "Saratov Standard Time",
106
"GMT+04:00",
107
"Saratov Daylight Time",
108
"GMT+04:00",
109
"Saratov Time",
110
"GMT+04:00"},
111
{"Europe/Saratov", Locale.FRANCE, "Saratov (heure standard)",
112
"UTC+04:00",
113
"Saratov (heure d\u2019\u00e9t\u00e9)",
114
"UTC+04:00",
115
"heure : Saratov",
116
"UTC+04:00"},
117
{"Europe/Ulyanovsk", Locale.US, "Ulyanovsk Standard Time",
118
"GMT+04:00",
119
"Ulyanovsk Daylight Time",
120
"GMT+04:00",
121
"Ulyanovsk Time",
122
"GMT+04:00"},
123
{"Europe/Ulyanovsk", Locale.FRANCE, "Oulianovsk (heure standard)",
124
"UTC+04:00",
125
"Oulianovsk (heure d\u2019\u00e9t\u00e9)",
126
"UTC+04:00",
127
"heure : Oulianovsk",
128
"UTC+04:00"},
129
{"Pacific/Bougainville", Locale.US, "Bougainville Standard Time",
130
"GMT+11:00",
131
"Bougainville Daylight Time",
132
"GMT+11:00",
133
"Bougainville Time",
134
"GMT+11:00"},
135
{"Pacific/Bougainville", Locale.FRANCE, "Bougainville (heure standard)",
136
"UTC+11:00",
137
"Bougainville (heure d\u2019\u00e9t\u00e9)",
138
"UTC+11:00",
139
"heure : Bougainville",
140
"UTC+11:00"},
141
{"Europe/Istanbul", Locale.US, "Istanbul Standard Time",
142
"GMT+03:00",
143
"Istanbul Daylight Time",
144
"GMT+03:00",
145
"Istanbul Time",
146
"GMT+03:00"},
147
{"Europe/Istanbul", Locale.FRANCE, "Istanbul (heure standard)",
148
"UTC+03:00",
149
"Istanbul (heure d\u2019\u00e9t\u00e9)",
150
"UTC+03:00",
151
"heure : Istanbul",
152
"UTC+03:00"},
153
{"Asia/Istanbul", Locale.US, "Istanbul Standard Time",
154
"GMT+03:00",
155
"Istanbul Daylight Time",
156
"GMT+03:00",
157
"Istanbul Time",
158
"GMT+03:00"},
159
{"Asia/Istanbul", Locale.FRANCE, "Istanbul (heure standard)",
160
"UTC+03:00",
161
"Istanbul (heure d\u2019\u00e9t\u00e9)",
162
"UTC+03:00",
163
"heure : Istanbul",
164
"UTC+03:00"},
165
{"Turkey", Locale.US, "Istanbul Standard Time",
166
"GMT+03:00",
167
"Istanbul Daylight Time",
168
"GMT+03:00",
169
"Istanbul Time",
170
"GMT+03:00"},
171
{"Turkey", Locale.FRANCE, "Istanbul (heure standard)",
172
"UTC+03:00",
173
"Istanbul (heure d\u2019\u00e9t\u00e9)",
174
"UTC+03:00",
175
"heure : Istanbul",
176
"UTC+03:00"},
177
};
178
}
179
180
181
@Test(dataProvider="noResourceTZs")
182
public void test_tzNames(String tzid, Locale locale, String lstd, String sstd, String ldst, String sdst, String lgen, String sgen) {
183
// Standard time
184
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.LONG, locale), lstd);
185
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(false, TimeZone.SHORT, locale), sstd);
186
187
// daylight saving time
188
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.LONG, locale), ldst);
189
assertEquals(TimeZone.getTimeZone(tzid).getDisplayName(true, TimeZone.SHORT, locale), sdst);
190
191
// generic name
192
assertEquals(ZoneId.of(tzid).getDisplayName(TextStyle.FULL, locale), lgen);
193
assertEquals(ZoneId.of(tzid).getDisplayName(TextStyle.SHORT, locale), sgen);
194
}
195
196
// Make sure getZoneStrings() returns non-empty string array
197
@Test
198
public void test_getZoneStrings() {
199
assertFalse(
200
Arrays.stream(Locale.getAvailableLocales())
201
.limit(30)
202
.peek(l -> System.out.println("Locale: " + l))
203
.map(l -> DateFormatSymbols.getInstance(l).getZoneStrings())
204
.flatMap(zs -> Arrays.stream(zs))
205
.peek(names -> System.out.println(" tz: " + names[0]))
206
.flatMap(names -> Arrays.stream(names))
207
.filter(name -> Objects.isNull(name) || name.isEmpty())
208
.findAny()
209
.isPresent(),
210
"getZoneStrings() returned array containing non-empty string element(s)");
211
}
212
}
213
214