< prev index next >

test/jdk/java/util/TimeZone/TimeZoneTest.java

Print this page
rev 49854 : 8181157: CLDR Timezone name fallback implementation
Reviewed-by: sherman
   1 /*
   2  * Copyright (c) 1997, 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 4028006 4044013 4096694 4107276 4107570 4112869 4130885 7039469 7126465 7158483
  27  *      8008577 8077685 8098547 8133321 8138716 8148446 8151876 8159684 8166875
  28  * @modules java.base/sun.util.resources
  29  * @library /java/text/testlib
  30  * @summary test TimeZone
  31  */
  32 
  33 import java.io.*;
  34 import java.text.*;
  35 import java.util.*;
  36 import sun.util.resources.LocaleData;
  37 
  38 public class TimeZoneTest extends IntlTest
  39 {
  40     static final int millisPerHour = 3600000;
  41 
  42     public static void main(String[] args) throws Exception {
  43         new TimeZoneTest().run(args);
  44     }
  45 
  46     /**
  47      * Bug 4130885


 347         // THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
 348         //*****************************************************************
 349         logln("PST(zh_CN)->" + name);
 350 
 351         // Now be smart -- check to see if zh resource is even present.
 352         // If not, we expect the en fallback behavior.
 353         ResourceBundle enRB = LocaleData.getBundle("sun.util.resources.TimeZoneNames",
 354                                                    Locale.ENGLISH);
 355         ResourceBundle zhRB = LocaleData.getBundle("sun.util.resources.TimeZoneNames",
 356                                                    zh_CN);
 357 
 358         boolean noZH = enRB == zhRB;
 359 
 360         if (noZH) {
 361             logln("Warning: Not testing the zh_CN behavior because resource is absent");
 362             if (!name.equals("Pacific Standard Time"))
 363                 errln("Fail: Expected Pacific Standard Time");
 364         }
 365         else if (!name.equals("Pacific Standard Time") &&
 366                  !name.equals("\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4") &&

 367                  !name.equals("GMT-08:00") &&
 368                  !name.equals("GMT-8:00") &&
 369                  !name.equals("GMT-0800") &&
 370                  !name.equals("GMT-800")) {
 371             errln("Fail: Expected GMT-08:00 or something similar");
 372             errln("************************************************************");
 373             errln("THE ABOVE FAILURE MAY JUST MEAN THE LOCALE DATA HAS CHANGED");
 374             errln("************************************************************");
 375         }
 376 
 377         // Now try a non-existent zone
 378         zone2 = new SimpleTimeZone(90*60*1000, "xyzzy");
 379         name = zone2.getDisplayName(Locale.ENGLISH);
 380         logln("GMT+90min->" + name);
 381         if (!name.equals("GMT+01:30") &&
 382             !name.equals("GMT+1:30") &&
 383             !name.equals("GMT+0130") &&
 384             !name.equals("GMT+130"))
 385             errln("Fail: Expected GMT+01:30 or something similar");
 386     }


   1 /*
   2  * Copyright (c) 1997, 2018, 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 4028006 4044013 4096694 4107276 4107570 4112869 4130885 7039469 7126465 7158483
  27  *      8008577 8077685 8098547 8133321 8138716 8148446 8151876 8159684 8166875 8181157
  28  * @modules java.base/sun.util.resources
  29  * @library /java/text/testlib
  30  * @summary test TimeZone
  31  */
  32 
  33 import java.io.*;
  34 import java.text.*;
  35 import java.util.*;
  36 import sun.util.resources.LocaleData;
  37 
  38 public class TimeZoneTest extends IntlTest
  39 {
  40     static final int millisPerHour = 3600000;
  41 
  42     public static void main(String[] args) throws Exception {
  43         new TimeZoneTest().run(args);
  44     }
  45 
  46     /**
  47      * Bug 4130885


 347         // THE FOLLOWING LINE MUST BE UPDATED IF THE LOCALE DATA CHANGES
 348         //*****************************************************************
 349         logln("PST(zh_CN)->" + name);
 350 
 351         // Now be smart -- check to see if zh resource is even present.
 352         // If not, we expect the en fallback behavior.
 353         ResourceBundle enRB = LocaleData.getBundle("sun.util.resources.TimeZoneNames",
 354                                                    Locale.ENGLISH);
 355         ResourceBundle zhRB = LocaleData.getBundle("sun.util.resources.TimeZoneNames",
 356                                                    zh_CN);
 357 
 358         boolean noZH = enRB == zhRB;
 359 
 360         if (noZH) {
 361             logln("Warning: Not testing the zh_CN behavior because resource is absent");
 362             if (!name.equals("Pacific Standard Time"))
 363                 errln("Fail: Expected Pacific Standard Time");
 364         }
 365         else if (!name.equals("Pacific Standard Time") &&
 366                  !name.equals("\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4") &&
 367                  !name.equals("\u5317\u7f8e\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4") &&
 368                  !name.equals("GMT-08:00") &&
 369                  !name.equals("GMT-8:00") &&
 370                  !name.equals("GMT-0800") &&
 371                  !name.equals("GMT-800")) {
 372             errln("Fail: Expected GMT-08:00 or something similar");
 373             errln("************************************************************");
 374             errln("THE ABOVE FAILURE MAY JUST MEAN THE LOCALE DATA HAS CHANGED");
 375             errln("************************************************************");
 376         }
 377 
 378         // Now try a non-existent zone
 379         zone2 = new SimpleTimeZone(90*60*1000, "xyzzy");
 380         name = zone2.getDisplayName(Locale.ENGLISH);
 381         logln("GMT+90min->" + name);
 382         if (!name.equals("GMT+01:30") &&
 383             !name.equals("GMT+1:30") &&
 384             !name.equals("GMT+0130") &&
 385             !name.equals("GMT+130"))
 386             errln("Fail: Expected GMT+01:30 or something similar");
 387     }


< prev index next >