1 /*
2 * Copyright (c) 2012, 2016, 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 8007572 8008161 8157792
27 * @summary Test whether the TimeZone generated from JSR310 tzdb is the same
28 * as the one from the tz data from javazic
29 * @build BackEnd Checksum DayOfWeek Gen GenDoc Main Mappings Month
30 * Rule RuleDay RuleRec Simple TestZoneInfo310 Time Timezone
31 * TzIDOldMapping Zone ZoneInfoFile ZoneInfoOld ZoneRec Zoneinfo
32 * @run main TestZoneInfo310
33 */
34
35 import java.io.File;
36 import java.lang.reflect.*;
37 import java.nio.file.*;
38 import java.util.*;
39 import java.util.regex.*;
40 import java.time.zone.*;
41 import java.time.ZoneId;
42
43 public class TestZoneInfo310 {
44
45 public static void main(String[] args) throws Throwable {
46
152 Arrays.sort(alias_new);
153
154 t0 = System.currentTimeMillis();
155 for (String zid : zids_new) {
156 TimeZone.getTimeZone(zid);
157 }
158 t1 = System.currentTimeMillis();
159 System.out.printf("NEW.TotalTZ()=%d (ms)%n", t1 - t0);
160
161 if (!Arrays.equals(zids_old, zids_new)) {
162 throw new RuntimeException(" FAILED: availableIds don't match");
163 }
164
165 if (!Arrays.equals(alias_old, alias_new)) {
166 throw new RuntimeException(" FAILED: aliases don't match");
167 }
168
169 for (String zid : zids_new) {
170 ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid));
171 ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid);
172 if (! zi.equalsTo(ziOLD)) {
173 System.out.println(zi.diffsTo(ziOLD));
174 throw new RuntimeException(" FAILED: " + zid);
175 }
176 }
177 delete(fZidir);
178
179 // test tzdb version
180 if (!ver.equals(sun.util.calendar.ZoneInfoFile.getVersion())) {
181 System.out.printf(" FAILED: ver=%s, expected=%s%n",
182 sun.util.calendar.ZoneInfoFile.getVersion(), ver);
183 throw new RuntimeException("Version test failed");
184 }
185
186 // test getAvailableIDs(raw);
187 zids_new = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
188 //Arrays.sort(zids_new);
189 zids_old = ZoneInfoOld.getAvailableIDs(-8 * 60 * 60 * 1000);
190 if (!Arrays.equals(zids_new, zids_old)) {
191 System.out.println("------------------------");
|
1 /*
2 * Copyright (c) 2012, 2019, 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 8007572 8008161 8157792 8224560
27 * @summary Test whether the TimeZone generated from JSR310 tzdb is the same
28 * as the one from the tz data from javazic
29 * @build BackEnd Checksum DayOfWeek Gen GenDoc Main Mappings Month
30 * Rule RuleDay RuleRec Simple TestZoneInfo310 Time Timezone
31 * TzIDOldMapping Zone ZoneInfoFile ZoneInfoOld ZoneRec Zoneinfo
32 * @run main TestZoneInfo310
33 */
34
35 import java.io.File;
36 import java.lang.reflect.*;
37 import java.nio.file.*;
38 import java.util.*;
39 import java.util.regex.*;
40 import java.time.zone.*;
41 import java.time.ZoneId;
42
43 public class TestZoneInfo310 {
44
45 public static void main(String[] args) throws Throwable {
46
152 Arrays.sort(alias_new);
153
154 t0 = System.currentTimeMillis();
155 for (String zid : zids_new) {
156 TimeZone.getTimeZone(zid);
157 }
158 t1 = System.currentTimeMillis();
159 System.out.printf("NEW.TotalTZ()=%d (ms)%n", t1 - t0);
160
161 if (!Arrays.equals(zids_old, zids_new)) {
162 throw new RuntimeException(" FAILED: availableIds don't match");
163 }
164
165 if (!Arrays.equals(alias_old, alias_new)) {
166 throw new RuntimeException(" FAILED: aliases don't match");
167 }
168
169 for (String zid : zids_new) {
170 ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid));
171 ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid);
172 /*
173 * Temporary ignoring the failing TimeZones which are having zone
174 * rules defined till year 2037 and/or above and have negative DST
175 * save time in IANA tzdata. This bug is tracked via JDK-8223388.
176 */
177 if (zid.equals("Africa/Casablanca") || zid.equals("Africa/El_Aaiun")
178 || zid.equals("Asia/Tehran") || zid.equals("Iran")) {
179 continue;
180 }
181 if (! zi.equalsTo(ziOLD)) {
182 System.out.println(zi.diffsTo(ziOLD));
183 throw new RuntimeException(" FAILED: " + zid);
184 }
185 }
186 delete(fZidir);
187
188 // test tzdb version
189 if (!ver.equals(sun.util.calendar.ZoneInfoFile.getVersion())) {
190 System.out.printf(" FAILED: ver=%s, expected=%s%n",
191 sun.util.calendar.ZoneInfoFile.getVersion(), ver);
192 throw new RuntimeException("Version test failed");
193 }
194
195 // test getAvailableIDs(raw);
196 zids_new = TimeZone.getAvailableIDs(-8 * 60 * 60 * 1000);
197 //Arrays.sort(zids_new);
198 zids_old = ZoneInfoOld.getAvailableIDs(-8 * 60 * 60 * 1000);
199 if (!Arrays.equals(zids_new, zids_old)) {
200 System.out.println("------------------------");
|