Path: blob/jdk8u272-b10-aarch32-20201026/jdk/test/java/util/Calendar/JapaneseEraNameTest.java
48795 views
/*1* Copyright (c) 2019, 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 8202088 8207152 8217609 821989026* @summary Test the localized Japanese new era name (May 1st. 2019-)27* is retrieved no matter CLDR provider contains the name or not.28* @run main/othervm -Djava.locale.providers=CLDR JapaneseEraNameTest29*30*/3132import static java.util.Calendar.*;33import static java.util.Locale.*;34import java.util.Calendar;35import java.util.Locale;363738public class JapaneseEraNameTest {39static final Calendar c = new Calendar.Builder()40.setCalendarType("japanese")41.setFields(ERA, 5, YEAR, 1, MONTH, MAY, DAY_OF_MONTH, 1)42.build();434445static final Object[][] names = {46// Since the test fails for below particular data47// on prior 8u versions for all eras, commenting it48// temporarily. Will be fixed as part of JDK-8220020.49// { LONG, JAPAN, "\u4ee4\u548c" },50{ LONG, US, "Reiwa" },51{ LONG, CHINA, "Reiwa" },52{ SHORT, JAPAN, "\u4ee4\u548c" },53{ SHORT, US, "Reiwa" },54{ SHORT, CHINA, "R" },55};5657public static void main(String[] args) {58for (Object[] data : names) {59if(!c.getDisplayName(ERA, (int)data[0], (Locale)data[1])60.equals(data[2])) {61throw new RuntimeException("JapaneseEraNameTest failed for " +62String.format("%1$s %2$s %3$s", data[0], data[1], data[2]));63}64}65}66}676869