Path: blob/master/test/jdk/java/util/Locale/bcp47u/spi/DateFormatSymbolsProviderTests.java
41159 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 820808026* @summary Tests DateFormatSymbols provider implementations27* @library provider28* @build provider/module-info provider/foo.DateFormatSymbolsProviderImpl29* @run main/othervm -Djava.locale.providers=SPI,CLDR DateFormatSymbolsProviderTests30*/3132import java.text.DateFormatSymbols;33import java.util.Locale;34import java.util.Map;3536/**37* Test DateFormatSymbolsProvider SPI with BCP47 U extensions38*/39public class DateFormatSymbolsProviderTests {40private static final Map<Locale, String> data = Map.of(41Locale.forLanguageTag("en-AA"), "foo",42Locale.forLanguageTag("en-US-u-rg-aazzzz"), "foo",43Locale.forLanguageTag("en-US-u-ca-japanese"), "bar"44);4546public static void main(String... args) {47data.forEach((l, e) -> {48DateFormatSymbols dfs = DateFormatSymbols.getInstance(l);49String[] months = dfs.getMonths();50System.out.printf("January string for locale %s is %s.%n", l.toString(), months[0]);51if (!months[0].equals(e)) {52throw new RuntimeException("DateFormatSymbols provider is not called for" + l);53}54});55}56}575859