Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/util/resources/TimeZone/Bug6377794.java
38853 views
/*1* Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*/2223/*24*@test25*@bug 637779426*@summary Test case for tzdata2005r support for 9 locales27*/2829import java.util.Locale;30import java.util.TimeZone;3132public class Bug6377794 {33static Locale[] locales2Test = new Locale[] {34new Locale("en"),35new Locale("de"),36new Locale("es"),37new Locale("fr"),38new Locale("it"),39new Locale("ja"),40new Locale("ko"),41new Locale("sv"),42new Locale("zh","CN"),43new Locale("zh","TW")44};4546public static void main(String[] args) {47TimeZone SystemVYST9 = TimeZone.getTimeZone("SystemV/YST9");48Locale tzLocale;49for (int i = 0; i < locales2Test.length; i++) {50tzLocale = locales2Test[i];51if (!SystemVYST9.getDisplayName(false, TimeZone.SHORT, tzLocale).equals52("AKST"))53throw new RuntimeException("\n" + tzLocale + ": SHORT, " +54"non-daylight saving name for " +55"SystemV/YST9 should be \"AKST\"");56}5758/*59* For "SystemV/PST8", testing TimeZone.SHORT would return the same value60* before and after the fix. Therefore, the regression test was changed to test61* TimeZone.LONG instead.62*/6364TimeZone SystemVPST8 = TimeZone.getTimeZone("SystemV/PST8");65tzLocale = locales2Test[0];66if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals67("Pacific Standard Time"))68throw new RuntimeException("\n" + tzLocale + ": LONG, " +69"non-daylight saving name for " +70"SystemV/PST8 should be " +71"\"Pacific Standard Time\"");72tzLocale = locales2Test[1];73if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals74("Pazifische Normalzeit"))75throw new RuntimeException("\n" + tzLocale + ": LONG, " +76"non-daylight saving name for " +77"SystemV/PST8 should be " +78"\"Pazifische Normalzeit\"");79tzLocale = locales2Test[2];80if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals81("Hora est\u00e1ndar del Pac\u00edfico"))82throw new RuntimeException("\n" + tzLocale + ": LONG, " +83"non-daylight saving name for " +84"SystemV/PST8 should be " +85"\"Hora est\u00e1ndar del Pac\u00edfico\"");86tzLocale = locales2Test[3];87if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals88("Heure normale du Pacifique"))89throw new RuntimeException("\n" + tzLocale + ": LONG, " +90"non-daylight saving name for " +91"SystemV/PST8 should be " +92"\"Heure normale du Pacifique\"");93tzLocale = locales2Test[4];94if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals95("Ora solare della costa occidentale USA"))96throw new RuntimeException("\n" + tzLocale + ": LONG, " +97"non-daylight saving name for " +98"SystemV/PST8 should be " +99"\"Ora solare della costa occidentale USA\"");100tzLocale = locales2Test[5];101if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals102("\u592a\u5e73\u6d0b\u6a19\u6e96\u6642"))103throw new RuntimeException("\n" + tzLocale + ": LONG, " +104"non-daylight saving name for " +105"SystemV/PST8 should be " +106"\"\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\"");107tzLocale = locales2Test[6];108if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals109("\ud0dc\ud3c9\uc591 \ud45c\uc900\uc2dc"))110throw new RuntimeException("\n" + tzLocale + ": LONG, " +111"non-daylight saving name for " +112"SystemV/PST8 should be " +113"\"\ud0dc\ud3c9\uc591 \ud45c\uc900\uc2dc\"");114tzLocale = locales2Test[7];115if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals116("Stilla havet, normaltid"))117throw new RuntimeException("\n" + tzLocale + ": LONG, " +118"non-daylight saving name for " +119"SystemV/PST8 should be " +120"\"Stilla havet, normaltid\"");121tzLocale = locales2Test[8];122if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals123("\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4"))124throw new RuntimeException("\n" + tzLocale + ": LONG, " +125"non-daylight saving name for " +126"SystemV/PST8 should be " +127"\"\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4\"");128tzLocale = locales2Test[9];129if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals130("\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\u9593"))131throw new RuntimeException("\n" + tzLocale + ": LONG, " +132"non-daylight saving name for " +133"SystemV/PST8 should be " +134"\"\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\u9593\"");135}136}137138139