Path: blob/master/test/jdk/sun/util/resources/cldr/Bug8202764.java
41153 views
/*1* Copyright (c) 2018, 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 820276426* @modules jdk.localedata27* @summary Checks time zone names are consistent with aliased ids,28* between DateFormatSymbols.getZoneStrings() and getDisplayName()29* of TimeZone/ZoneId classes30* @run testng/othervm Bug820276431*/3233import static org.testng.Assert.assertEquals;3435import java.time.ZoneId;36import java.time.format.TextStyle;37import java.text.DateFormatSymbols;38import java.util.Arrays;39import java.util.Locale;40import java.util.Set;41import java.util.TimeZone;4243import org.testng.annotations.Test;4445public class Bug8202764 {4647@Test48public void testAliasedTZs() {49Set<String> zoneIds = ZoneId.getAvailableZoneIds();50Arrays.stream(DateFormatSymbols.getInstance(Locale.US).getZoneStrings())51.forEach(zone -> {52System.out.println(zone[0]);53TimeZone tz = TimeZone.getTimeZone(zone[0]);54assertEquals(zone[1], tz.getDisplayName(false, TimeZone.LONG, Locale.US));55assertEquals(zone[2], tz.getDisplayName(false, TimeZone.SHORT, Locale.US));56assertEquals(zone[3], tz.getDisplayName(true, TimeZone.LONG, Locale.US));57assertEquals(zone[4], tz.getDisplayName(true, TimeZone.SHORT, Locale.US));58if (zoneIds.contains(zone[0])) {59// Some of the ids, e.g. three-letter ids are not supported in ZoneId60ZoneId zi = tz.toZoneId();61assertEquals(zone[5], zi.getDisplayName(TextStyle.FULL, Locale.US));62assertEquals(zone[6], zi.getDisplayName(TextStyle.SHORT, Locale.US));63}64});65}66}676869