2323
2424/*
2525 * @test
26- * @bug 8167143 8174269
26+ * @bug 8167143 8174269 8358170
2727 * @summary Test
2828 * Timezone parsing works for all locales for default providers preference
2929 * CLDR implicit locales are correctly reflected,
3030 * th_TH bundle is not wrongly cached in DateFormatSymbols,
3131 * correct candidate locale list is retrieved for
3232 * zh_Hant and zh_Hans and
33- * Implicit COMPAT Locales nn-NO, nb-NO are reflected in available locales
33+ * Implicit FALLBACK Locales nn-NO, nb-NO are reflected in available locales
3434 * @modules java.base/sun.util.locale.provider
3535 * java.base/sun.util.spi
3636 * jdk.localedata
3737 * @run main Bug8167143 testTimeZone
3838 * @run main Bug8167143 testCldr
3939 * @run main Bug8167143 testCache
4040 * @run main Bug8167143 testCandidateLocales
41+ * @run main Bug8167143 testFallback
4142 */
4243import java .text .ParseException ;
4344import java .text .SimpleDateFormat ;
@@ -64,7 +65,7 @@ public class Bug8167143 {
6465 Locale .forLanguageTag ("zh-Hant-TW" ),
6566 Locale .forLanguageTag ("zh-Hant-MO" ));
6667
67- private static final List <Locale > COMPAT_IMPLICIT_LOCS = List .of (Locale .forLanguageTag ("nn-NO" ),
68+ private static final List <Locale > FALLBACK_IMPLICIT_LOCS = List .of (Locale .forLanguageTag ("nn-NO" ),
6869 Locale .forLanguageTag ("nb-NO" ));
6970 /**
7071 * List of candidate locales for zh_Hant
@@ -97,8 +98,8 @@ public static void main(String[] args) {
9798 case "testCandidateLocales" :
9899 testCandidateLocales ();
99100 break ;
100- case "testCompat " :
101- testImplicitCompatLocales ();
101+ case "testFallback " :
102+ testImplicitFallbackLocales ();
102103 break ;
103104 default :
104105 throw new RuntimeException ("no test was specified." );
@@ -230,45 +231,26 @@ private static void reportDifference(List<Locale> got, List<Locale> expected, St
230231 }
231232
232233 /**
233- * checks that locales nn-NO and nb-NO should be present in list of supported locales for
234- * all Providers for COMPAT.
234+ * Checks that locales (nn-NO and nb-NO) implicitly supported in FALLBACK
235+ * provider should be present in output of getAvailableLocales() for
236+ * BreakIteratorProvider and CollatorProvider.
235237 */
236- private static void testImplicitCompatLocales () {
237- LocaleProviderAdapter jre = LocaleProviderAdapter .forJRE ();
238- checkPresenceCompat ("BreakIteratorProvider" ,
239- jre .getBreakIteratorProvider ().getAvailableLocales ());
240- checkPresenceCompat ("CollatorProvider" ,
241- jre .getCollatorProvider ().getAvailableLocales ());
242- checkPresenceCompat ("DateFormatProvider" ,
243- jre .getDateFormatProvider ().getAvailableLocales ());
244- checkPresenceCompat ("DateFormatSymbolsProvider" ,
245- jre .getDateFormatSymbolsProvider ().getAvailableLocales ());
246- checkPresenceCompat ("DecimalFormatSymbolsProvider" ,
247- jre .getDecimalFormatSymbolsProvider ().getAvailableLocales ());
248- checkPresenceCompat ("NumberFormatProvider" ,
249- jre .getNumberFormatProvider ().getAvailableLocales ());
250- checkPresenceCompat ("CurrencyNameProvider" ,
251- jre .getCurrencyNameProvider ().getAvailableLocales ());
252- checkPresenceCompat ("LocaleNameProvider" ,
253- jre .getLocaleNameProvider ().getAvailableLocales ());
254- checkPresenceCompat ("TimeZoneNameProvider" ,
255- jre .getTimeZoneNameProvider ().getAvailableLocales ());
256- checkPresenceCompat ("CalendarDataProvider" ,
257- jre .getCalendarDataProvider ().getAvailableLocales ());
258- checkPresenceCompat ("CalendarNameProvider" ,
259- jre .getCalendarNameProvider ().getAvailableLocales ());
260- checkPresenceCompat ("CalendarProvider" ,
261- jre .getCalendarProvider ().getAvailableLocales ());
238+ private static void testImplicitFallbackLocales () {
239+ LocaleProviderAdapter fallback = LocaleProviderAdapter .forType (Type .FALLBACK );
240+ checkPresenceFallback ("BreakIteratorProvider" ,
241+ fallback .getBreakIteratorProvider ().getAvailableLocales ());
242+ checkPresenceFallback ("CollatorProvider" ,
243+ fallback .getCollatorProvider ().getAvailableLocales ());
262244 }
263245
264- private static void checkPresenceCompat (String testName , Locale [] got ) {
246+ private static void checkPresenceFallback (String testName , Locale [] got ) {
265247 List <Locale > gotLocalesList = Arrays .asList (got );
266248 List <Locale > gotList = new ArrayList <>(gotLocalesList );
267- if (!gotList .removeAll (COMPAT_IMPLICIT_LOCS )) {
249+ if (!gotList .removeAll (FALLBACK_IMPLICIT_LOCS )) {
268250 // check which Implicit locale are not present in retrievedLocales List.
269- List <Locale > implicitLocales = new ArrayList <>(COMPAT_IMPLICIT_LOCS );
251+ List <Locale > implicitLocales = new ArrayList <>(FALLBACK_IMPLICIT_LOCS );
270252 implicitLocales .removeAll (gotList );
271- throw new RuntimeException ("Locales those not correctly reflected are "
253+ throw new RuntimeException ("Locale(s) not correctly reflected are "
272254 + implicitLocales + " for test " + testName );
273255 }
274256 }
0 commit comments