# HG changeset patch # User rgoel # Date 1467089221 -32400 # Node ID b10720494ec4df2db61568815f377c58f4367274 # Parent 8d9ceb81a46edc139111bdb0344faa2fd6a0712f 8158504: test/sun/util/locale/provider/Bug8038436.java: non English locale(s) included in available locales Reviewed-by: okutsu, naoto diff -r 8d9ceb81a46e -r b10720494ec4 jdk/test/sun/util/locale/provider/Bug8038436.java --- a/jdk/test/sun/util/locale/provider/Bug8038436.java Tue Jun 28 09:57:09 2016 +0530 +++ b/jdk/test/sun/util/locale/provider/Bug8038436.java Tue Jun 28 13:47:01 2016 +0900 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,24 +23,25 @@ /* * @test - * @bug 8038436 + * @bug 8038436 8158504 * @summary Test for changes in 8038436 * @modules java.base/sun.util.locale.provider * java.base/sun.util.spi * @compile -XDignore.symbol.file Bug8038436.java - * @run main/othervm Bug8038436 -Djava.ext.dirs=foo security - * @run main/othervm Bug8038436 -Djava.locale.providers=JRE availlocs + * @run main/othervm -limitmods java.base Bug8038436 security + * @run main/othervm -Djava.locale.providers=COMPAT Bug8038436 availlocs */ import java.security.*; -import java.text.*; import java.util.*; import java.util.stream.*; import sun.util.locale.provider.*; public class Bug8038436 { public static void main(String[] args) { - switch (args[1]) { + + switch (args[0]) { + case "security": securityTests(); break; @@ -50,6 +51,7 @@ default: throw new RuntimeException("no test was specified."); } + } private static void securityTests() { @@ -67,12 +69,14 @@ /* * Check only English/ROOT locales are returned if the jdk.localedata - * module is not installed (implied by "java.ext.dirs" set to "foo"). + * module is not loaded (implied by "-limitmods java.base"). */ - if (Arrays.asList(Locale.getAvailableLocales()) - .stream() - .anyMatch(l -> l != Locale.ROOT && l.getLanguage() != "en")) { - throw new RuntimeException("non English locale(s) included in available locales"); + List nonEnglishLocales= (Arrays.stream(Locale.getAvailableLocales()) + .filter(l -> (l != Locale.ROOT && !(l.getLanguage() == "en" && (l.getCountry() == "US" || l.getCountry() == "" )))) + .collect(Collectors.toList())); + + if (!nonEnglishLocales.isEmpty()) { + throw new RuntimeException("non English locale(s)" + nonEnglishLocales + " included in available locales"); } }