< prev index next >

test/jdk/java/util/TimeZone/Bug6329116.java

Print this page

  1 /*
  2  * Copyright (c) 2005, 2022, 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 6329116 6756569 6757131 6758988 6764308 6796489 6834474 6609737 6507067
 27  *      7039469 7090843 7103108 7103405 7158483 8008577 8059206 8064560 8072042
 28  *      8077685 8151876 8166875 8169191 8170316 8176044
 29  * @summary Make sure that timezone short display names are idenical to Olson's data.
 30  * @library /java/text/testlib
 31  * @build Bug6329116 TextFileReader
 32  * @run main/othervm -Djava.locale.providers=COMPAT,SPI Bug6329116
 33  */
 34 
 35 import java.io.*;
 36 import java.text.*;
 37 import java.util.*;
 38 
 39 public class Bug6329116 extends IntlTest {




 40 
 41     static Locale[] locales = Locale.getAvailableLocales();
 42     static String[] timezones = TimeZone.getAvailableIDs();
 43 
 44     public static void main(String[] args) throws IOException {
 45         if (bug6329116()) {
 46             throw new RuntimeException("At least one timezone display name is incorrect.");
 47         }
 48     }
 49 
 50     static boolean bug6329116() throws IOException {
 51         boolean err = false;
 52 
 53         HashMap<String, String> aliasTable = new HashMap<>();
 54         HashSet<String> timezoneTable = new HashSet<>();
 55         for (String t : timezones) {
 56             timezoneTable.add(t);
 57         }
 58 
 59         String line, key, value;
 60         StringTokenizer st;
 61 
 62         try (TextFileReader in = new TextFileReader("aliases.txt")) {
 63             while ((line = in.readLine()) != null) {
 64                 st = new StringTokenizer(line);
 65                 st.nextToken();
 66                 key = st.nextToken();
 67                 value = st.nextToken();
 68 
 69                 if (!value.equals("ROC")) {
 70                     if (aliasTable.containsKey(key)) {

183                 }
184             }
185         }
186 
187         if (!timezoneTable.isEmpty()) {
188             System.out.println("# Timezone(s) valid in JRE but untested in this test program:");
189             Iterator<String> it = timezoneTable.iterator();
190             while (it.hasNext()) {
191                 System.out.println(it.next());
192             }
193             System.out.println();
194         }
195 
196         if (!aliasTable.isEmpty()) {
197             System.out.println("# Timezone(s) exists in Olson's data as Link but unused in JRE:");
198             for (Map.Entry<String, String> entry : aliasTable.entrySet()) {
199                 System.out.println(entry);
200             }
201         }
202 
203         return err;


204     }
205 
206     static boolean useLocalzedShortDisplayName(TimeZone tz,
207                                                Locale locale,
208                                                String got,
209                                                boolean inDST) {
210         if (locale.getLanguage().equals("de")) {
211             String name = tz.getDisplayName(inDST, TimeZone.LONG, locale);
212             if (inDST) {
213                 if (("Mitteleurop\u00e4ische Sommerzeit".equals(name) && "MESZ".equals(got)) ||
214                     ("Osteurop\u00e4ische Sommerzeit".equals(name) && "OESZ".equals(got)) ||
215                     ("Westeurop\u00e4ische Sommerzeit".equals(name) && "WESZ".equals(got))) {
216                     return true;
217                 }
218             } else {
219                 if (("Mitteleurop\u00e4ische Zeit".equals(name) && "MEZ".equals(got)) ||
220                     ("Osteurop\u00e4ische Zeit".equals(name) && "OEZ".equals(got)) ||
221                     ("Westeurop\u00e4ische Zeit".equals(name) && "WEZ".equals(got))) {
222                     return true;
223                 }

  1 /*
  2  * Copyright (c) 2005, 2023, 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 6329116 6756569 6757131 6758988 6764308 6796489 6834474 6609737 6507067
 27  *      7039469 7090843 7103108 7103405 7158483 8008577 8059206 8064560 8072042
 28  *      8077685 8151876 8166875 8169191 8170316 8176044
 29  * @summary Make sure that timezone short display names are idenical to Olson's data.
 30  * @run junit/othervm -Djava.locale.providers=COMPAT,SPI Bug6329116


 31  */
 32 
 33 import java.io.*;
 34 import java.text.*;
 35 import java.util.*;
 36 
 37 import org.junit.jupiter.api.Test;
 38 
 39 import static org.junit.jupiter.api.Assertions.fail;
 40 
 41 public class Bug6329116 {
 42 
 43     static Locale[] locales = Locale.getAvailableLocales();
 44     static String[] timezones = TimeZone.getAvailableIDs();
 45 
 46     @Test
 47     public void bug6329116() throws IOException {





 48         boolean err = false;
 49 
 50         HashMap<String, String> aliasTable = new HashMap<>();
 51         HashSet<String> timezoneTable = new HashSet<>();
 52         for (String t : timezones) {
 53             timezoneTable.add(t);
 54         }
 55 
 56         String line, key, value;
 57         StringTokenizer st;
 58 
 59         try (TextFileReader in = new TextFileReader("aliases.txt")) {
 60             while ((line = in.readLine()) != null) {
 61                 st = new StringTokenizer(line);
 62                 st.nextToken();
 63                 key = st.nextToken();
 64                 value = st.nextToken();
 65 
 66                 if (!value.equals("ROC")) {
 67                     if (aliasTable.containsKey(key)) {

180                 }
181             }
182         }
183 
184         if (!timezoneTable.isEmpty()) {
185             System.out.println("# Timezone(s) valid in JRE but untested in this test program:");
186             Iterator<String> it = timezoneTable.iterator();
187             while (it.hasNext()) {
188                 System.out.println(it.next());
189             }
190             System.out.println();
191         }
192 
193         if (!aliasTable.isEmpty()) {
194             System.out.println("# Timezone(s) exists in Olson's data as Link but unused in JRE:");
195             for (Map.Entry<String, String> entry : aliasTable.entrySet()) {
196                 System.out.println(entry);
197             }
198         }
199 
200         if (err) {
201             fail("At least one timezone display name is incorrect.");
202         }
203     }
204 
205     static boolean useLocalzedShortDisplayName(TimeZone tz,
206                                                Locale locale,
207                                                String got,
208                                                boolean inDST) {
209         if (locale.getLanguage().equals("de")) {
210             String name = tz.getDisplayName(inDST, TimeZone.LONG, locale);
211             if (inDST) {
212                 if (("Mitteleurop\u00e4ische Sommerzeit".equals(name) && "MESZ".equals(got)) ||
213                     ("Osteurop\u00e4ische Sommerzeit".equals(name) && "OESZ".equals(got)) ||
214                     ("Westeurop\u00e4ische Sommerzeit".equals(name) && "WESZ".equals(got))) {
215                     return true;
216                 }
217             } else {
218                 if (("Mitteleurop\u00e4ische Zeit".equals(name) && "MEZ".equals(got)) ||
219                     ("Osteurop\u00e4ische Zeit".equals(name) && "OEZ".equals(got)) ||
220                     ("Westeurop\u00e4ische Zeit".equals(name) && "WEZ".equals(got))) {
221                     return true;
222                 }
< prev index next >