Path: blob/master/test/jdk/java/util/Calendar/JapaneseEraNameTest.java
41149 views
/*1* Copyright (c) 2018, 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* @modules jdk.localedata29* @run testng/othervm JapaneseEraNameTest30* @run testng/othervm -Djava.locale.providers=CLDR JapaneseEraNameTest31*/3233import static java.util.Calendar.*;34import static java.util.Locale.*;35import java.util.Calendar;36import java.util.Locale;3738import org.testng.annotations.DataProvider;39import org.testng.annotations.Test;40import static org.testng.Assert.assertEquals;4142@Test43public class JapaneseEraNameTest {44static final Calendar c = new Calendar.Builder()45.setCalendarType("japanese")46.setFields(ERA, 5, YEAR, 1, MONTH, MAY, DAY_OF_MONTH, 1)47.build();4849@DataProvider(name="names")50Object[][] names() {51return new Object[][] {52// type, locale, name53{ LONG, JAPAN, "\u4ee4\u548c" },54{ LONG, US, "Reiwa" },55{ LONG, CHINA, "\u4ee4\u548c" },56{ SHORT, JAPAN, "\u4ee4\u548c" },57{ SHORT, US, "Reiwa" },58{ SHORT, CHINA, "\u4ee4\u548c" },59};60}6162@Test(dataProvider="names")63public void testJapaneseNewEraName(int type, Locale locale, String expected) {64assertEquals(c.getDisplayName(ERA, type, locale), expected);65}66}676869