Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/java/util/PluggableLocale/CalendarDataProviderTest.java
47209 views
/*1* Copyright (c) 2012, 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*/22/*23*24*/2526import java.text.*;27import java.util.*;28import static java.util.Calendar.*;29import sun.util.locale.provider.*;30import sun.util.resources.*;31import com.bar.CalendarDataProviderImpl;3233/**34* Test case for CalendarDataProvider.35*36* Test strategy:37* com.bar.CalendarDataProviderImpl supports only ja_JP_kids locale. It returns38* unusual week parameter values, WEDNESDAY - first day of week, 7 - minimal39* days in the first week.40*41* A Calendar instance created with ja_JP_kids should use the week parameters42* provided by com.bar.CalendarDataProviderImpl.43*/44public class CalendarDataProviderTest {4546public static void main(String[] s) {47new CalendarDataProviderTest().test();48}4950void test() {51Locale kids = new Locale("ja", "JP", "kids"); // test provider's supported locale52Calendar kcal = Calendar.getInstance(kids);53Calendar jcal = Calendar.getInstance(Locale.JAPAN);5455// check the week parameters56checkResult("firstDayOfWeek", kcal.getFirstDayOfWeek(), WEDNESDAY);57checkResult("minimalDaysInFirstWeek", kcal.getMinimalDaysInFirstWeek(), 7);58}5960private <T> void checkResult(String msg, T got, T expected) {61if (!expected.equals(got)) {62String s = String.format("%s: got='%s', expected='%s'", msg, got, expected);63throw new RuntimeException(s);64}65}66}676869