Path: blob/master/test/jdk/sun/util/resources/TimeZone/Bug6377794.java
41155 views
/*1* Copyright (c) 2007, 2016, 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* @modules jdk.localedata27* @summary Test case for tzdata2005r support for 9 locales28* @run main/othervm -Djava.locale.providers=JRE,SPI Bug637779429*/3031import java.util.Locale;32import java.util.TimeZone;3334public class Bug6377794 {35static Locale[] locales2Test = new Locale[] {36new Locale("en"),37new Locale("de"),38new Locale("es"),39new Locale("fr"),40new Locale("it"),41new Locale("ja"),42new Locale("ko"),43new Locale("sv"),44new Locale("zh","CN"),45new Locale("zh","TW")46};4748public static void main(String[] args) {49TimeZone SystemVYST9 = TimeZone.getTimeZone("SystemV/YST9");50Locale tzLocale;51for (int i = 0; i < locales2Test.length; i++) {52tzLocale = locales2Test[i];53if (!SystemVYST9.getDisplayName(false, TimeZone.SHORT, tzLocale).equals54("AKST"))55throw new RuntimeException("\n" + tzLocale + ": SHORT, " +56"non-daylight saving name for " +57"SystemV/YST9 should be \"AKST\"");58}5960/*61* For "SystemV/PST8", testing TimeZone.SHORT would return the same value62* before and after the fix. Therefore, the regression test was changed to test63* TimeZone.LONG instead.64*/6566TimeZone SystemVPST8 = TimeZone.getTimeZone("SystemV/PST8");67tzLocale = locales2Test[0];68if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals69("Pacific Standard Time"))70throw new RuntimeException("\n" + tzLocale + ": LONG, " +71"non-daylight saving name for " +72"SystemV/PST8 should be " +73"\"Pacific Standard Time\"");74tzLocale = locales2Test[1];75if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals76("Pazifische Normalzeit"))77throw new RuntimeException("\n" + tzLocale + ": LONG, " +78"non-daylight saving name for " +79"SystemV/PST8 should be " +80"\"Pazifische Normalzeit\"");81tzLocale = locales2Test[2];82if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals83("Hora est\u00e1ndar del Pac\u00edfico"))84throw new RuntimeException("\n" + tzLocale + ": LONG, " +85"non-daylight saving name for " +86"SystemV/PST8 should be " +87"\"Hora est\u00e1ndar del Pac\u00edfico\"");88tzLocale = locales2Test[3];89if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals90("Heure normale du Pacifique"))91throw new RuntimeException("\n" + tzLocale + ": LONG, " +92"non-daylight saving name for " +93"SystemV/PST8 should be " +94"\"Heure normale du Pacifique\"");95tzLocale = locales2Test[4];96if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals97("Ora solare della costa occidentale USA"))98throw new RuntimeException("\n" + tzLocale + ": LONG, " +99"non-daylight saving name for " +100"SystemV/PST8 should be " +101"\"Ora solare della costa occidentale USA\"");102tzLocale = locales2Test[5];103if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals104("\u592a\u5e73\u6d0b\u6a19\u6e96\u6642"))105throw new RuntimeException("\n" + tzLocale + ": LONG, " +106"non-daylight saving name for " +107"SystemV/PST8 should be " +108"\"\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\"");109tzLocale = locales2Test[6];110if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals111("\ud0dc\ud3c9\uc591 \ud45c\uc900\uc2dc"))112throw new RuntimeException("\n" + tzLocale + ": LONG, " +113"non-daylight saving name for " +114"SystemV/PST8 should be " +115"\"\ud0dc\ud3c9\uc591 \ud45c\uc900\uc2dc\"");116tzLocale = locales2Test[7];117if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals118("Stilla havet, normaltid"))119throw new RuntimeException("\n" + tzLocale + ": LONG, " +120"non-daylight saving name for " +121"SystemV/PST8 should be " +122"\"Stilla havet, normaltid\"");123tzLocale = locales2Test[8];124if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals125("\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4"))126throw new RuntimeException("\n" + tzLocale + ": LONG, " +127"non-daylight saving name for " +128"SystemV/PST8 should be " +129"\"\u592a\u5e73\u6d0b\u6807\u51c6\u65f6\u95f4\"");130tzLocale = locales2Test[9];131if (!SystemVPST8.getDisplayName(false, TimeZone.LONG, tzLocale).equals132("\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\u9593"))133throw new RuntimeException("\n" + tzLocale + ": LONG, " +134"non-daylight saving name for " +135"SystemV/PST8 should be " +136"\"\u592a\u5e73\u6d0b\u6a19\u6e96\u6642\u9593\"");137}138}139140141