8210403: Refactor java.util.Locale:i18n shell tests to plain java tests
Reviewed-by: naoto
Contributed-by: ying.z.zhou@oracle.com
--- a/test/jdk/java/util/Locale/LocaleCategory.java Fri Oct 05 15:12:37 2018 -0700
+++ b/test/jdk/java/util/Locale/LocaleCategory.java Wed Oct 17 16:37:41 2018 +0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2010, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2010, 2018, 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
@@ -20,13 +20,29 @@
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
+
+/*
+ * @test
+ * @bug 4700857 6997928 7079486
+ * @summary tests for Locale.getDefault(Locale.Category) and
+ * Locale.setDefault(Locale.Category, Locale)
+ * @library /java/text/testlib
+ * @build TestUtils LocaleCategory
+ * @comment test user.xxx.display user.xxx.format properties
+ * @run main/othervm -Duser.language.display=ja
+ * -Duser.language.format=zh LocaleCategory
+ * @comment test user.xxx properties overriding user.xxx.display/format
+ * @run main/othervm -Duser.language=en
+ * -Duser.language.display=ja
+ * -Duser.language.format=zh LocaleCategory
+ */
+
import java.util.Locale;
public class LocaleCategory {
private static Locale base = null;
private static Locale disp = null;
private static Locale fmt = null;
- private static String enc = null;
public static void main(String[] args) {
Locale reservedLocale = Locale.getDefault();
@@ -37,7 +53,6 @@
try {
Locale.Builder builder = new Locale.Builder();
-
base = builder.setLanguage(System.getProperty("user.language", ""))
.setScript(System.getProperty("user.script", ""))
.setRegion(System.getProperty("user.country", ""))
@@ -68,32 +83,37 @@
}
}
- static void checkDefault() {
+ private static void checkDefault() {
if (!base.equals(Locale.getDefault()) ||
!disp.equals(Locale.getDefault(Locale.Category.DISPLAY)) ||
!fmt.equals(Locale.getDefault(Locale.Category.FORMAT))) {
- throw new RuntimeException("Some of the return values from getDefault() do not agree with the locale derived from \"user.xxxx\" system properties");
+ throw new RuntimeException("Some of the return values from "
+ + "getDefault() do not agree with the locale derived "
+ + "from \"user.xxxx\" system properties");
}
}
- static void testGetSetDefault() {
+ private static void testGetSetDefault() {
try {
Locale.setDefault(null, null);
- throw new RuntimeException("setDefault(null, null) should throw a NullPointerException");
+ throw new RuntimeException("setDefault(null, null) should throw a "
+ + "NullPointerException");
} catch (NullPointerException npe) {}
Locale.setDefault(Locale.CHINA);
if (!Locale.CHINA.equals(Locale.getDefault(Locale.Category.DISPLAY)) ||
!Locale.CHINA.equals(Locale.getDefault(Locale.Category.FORMAT))) {
- throw new RuntimeException("setDefault() should set all default locales for all categories");
+ throw new RuntimeException("setDefault() should set all default "
+ + "locales for all categories");
}
}
- static void testBug7079486() {
+ private static void testBug7079486() {
Locale zh_Hans_CN = Locale.forLanguageTag("zh-Hans-CN");
// make sure JRE has zh_Hans_CN localized string
- if (zh_Hans_CN.getDisplayScript(Locale.US).equals(zh_Hans_CN.getDisplayScript(zh_Hans_CN))) {
+ if (zh_Hans_CN.getDisplayScript(Locale.US)
+ .equals(zh_Hans_CN.getDisplayScript(zh_Hans_CN))) {
return;
}
@@ -104,7 +124,8 @@
String zh_script = zh_Hans_CN.getDisplayScript();
if (en_script.equals(zh_script)) {
- throw new RuntimeException("Locale.getDisplayScript() (no args) does not honor default DISPLAY locale");
+ throw new RuntimeException("Locale.getDisplayScript() (no args) "
+ + "does not honor default DISPLAY locale");
}
}
}
--- a/test/jdk/java/util/Locale/LocaleCategory.sh Fri Oct 05 15:12:37 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,104 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2011, 2012, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-# @test
-# @bug 4700857 6997928 7079486
-# @summary tests for Locale.getDefault(Locale.Category) and
-# Locale.setDefault(Locale.Category, Locale)
-# @library /java/text/testlib
-# @build LocaleCategory TestUtils
-# @run shell/timeout=600 LocaleCategory.sh
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "TESTCLASSPATH=${TESTCLASSPATH}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | *BSD | Darwin | AIX )
- PS=":"
- FS="/"
- ;;
- Windows* | CYGWIN* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-# test user.xxx.display user.xxx.format properties
-
-# run
-RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSPATH} -Duser.language.display=ja -Duser.language.format=zh LocaleCategory"
-
-echo ${RUNCMD}
-${RUNCMD}
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Execution successful"
-else
- echo "Execution of the test case failed."
-fi
-
-# test user.xxx properties overriding user.xxx.display/format
-
-# run
-RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} -classpath ${TESTCLASSPATH} -Duser.language=en -Duser.language.display=ja -Duser.language.format=zh LocaleCategory"
-
-echo ${RUNCMD}
-${RUNCMD}
-result=$?
-
-if [ $result -eq 0 ]
-then
- echo "Execution successful"
-else
- echo "Execution of the test case failed."
-fi
-
-exit $result
--- a/test/jdk/java/util/Locale/LocaleProviders.sh Fri Oct 05 15:12:37 2018 -0700
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,370 +0,0 @@
-#!/bin/sh
-#
-# Copyright (c) 2012, 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
-# under the terms of the GNU General Public License version 2 only, as
-# published by the Free Software Foundation.
-#
-# This code is distributed in the hope that it will be useful, but WITHOUT
-# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
-# version 2 for more details (a copy is included in the LICENSE file that
-# accompanied this code).
-#
-# You should have received a copy of the GNU General Public License version
-# 2 along with this work; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
-#
-# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
-# or visit www.oracle.com if you need additional information or have any
-# questions.
-#
-#
-# @test
-# @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8008577
-# 8010666 8013086 8013233 8013903 8015960 8028771 8054482 8062006
-# 8150432
-# @summary tests for "java.locale.providers" system property
-# @modules java.base/sun.util.locale
-# java.base/sun.util.locale.provider
-# @compile LocaleProviders.java
-# @run shell/timeout=600 LocaleProviders.sh
-
-if [ "${TESTSRC}" = "" ]
-then
- echo "TESTSRC not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTSRC=${TESTSRC}"
-if [ "${TESTJAVA}" = "" ]
-then
- echo "TESTJAVA not set. Test cannot execute. Failed."
- exit 1
-fi
-if [ "${COMPILEJAVA}" = "" ]
-then
- COMPILEJAVA="${TESTJAVA}"
-fi
-echo "TESTJAVA=${TESTJAVA}"
-if [ "${TESTCLASSES}" = "" ]
-then
- echo "TESTCLASSES not set. Test cannot execute. Failed."
- exit 1
-fi
-echo "TESTCLASSES=${TESTCLASSES}"
-echo "CLASSPATH=${CLASSPATH}"
-
-# set platform-dependent variables
-OS=`uname -s`
-case "$OS" in
- SunOS | Linux | *BSD | Darwin | AIX )
- PS=":"
- FS="/"
- ;;
- Windows* | CYGWIN* )
- PS=";"
- FS="\\"
- ;;
- * )
- echo "Unrecognized system!"
- exit 1;
- ;;
-esac
-
-# create SPI implementations
-mk() {
- d=`dirname $1`
- if [ ! -d $d ]; then mkdir -p $d; fi
- cat - >$1
-}
-
-SPIDIR=${TESTCLASSES}${FS}spi
-rm -rf ${SPIDIR}
-mk ${SPIDIR}${FS}src${FS}tznp.java << EOF
-import java.util.spi.TimeZoneNameProvider;
-import java.util.Locale;
-
-public class tznp extends TimeZoneNameProvider {
- public String getDisplayName(String ID, boolean daylight, int style, Locale locale) {
- return "tznp";
- }
-
- public Locale[] getAvailableLocales() {
- Locale[] locales = {Locale.US};
- return locales;
- }
-}
-EOF
-mk ${SPIDIR}${FS}src${FS}tznp8013086.java << EOF
-import java.util.spi.TimeZoneNameProvider;
-import java.util.Locale;
-import java.util.TimeZone;
-
-public class tznp8013086 extends TimeZoneNameProvider {
- public String getDisplayName(String ID, boolean daylight, int style, Locale locale) {
- if (!daylight && style==TimeZone.LONG) {
- return "tznp8013086";
- } else {
- return null;
- }
- }
-
- public Locale[] getAvailableLocales() {
- Locale[] locales = {Locale.JAPAN};
- return locales;
- }
-}
-EOF
-mk ${SPIDIR}${FS}dest${FS}META-INF${FS}services${FS}java.util.spi.TimeZoneNameProvider << EOF
-tznp
-tznp8013086
-EOF
-
-EXTRAOPTS="--add-exports java.base/sun.util.locale=ALL-UNNAMED \
- --add-exports java.base/sun.util.locale.provider=ALL-UNNAMED"
-
-${COMPILEJAVA}${FS}bin${FS}javac ${TESTJAVACOPTS} ${TESTTOOLVMOPTS} -d ${SPIDIR}${FS}dest \
- ${SPIDIR}${FS}src${FS}tznp.java \
- ${SPIDIR}${FS}src${FS}tznp8013086.java
-${COMPILEJAVA}${FS}bin${FS}jar ${TESTTOOLVMOPTS} cvf ${SPIDIR}${FS}tznp.jar -C ${SPIDIR}${FS}dest .
-
-# get the platform default locales
-PLATDEF=`${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${EXTRAOPTS} -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale display`
-DEFLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
-DEFCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
-echo "DEFLANG=${DEFLANG}"
-echo "DEFCTRY=${DEFCTRY}"
-PLATDEF=`${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${EXTRAOPTS} -classpath ${TESTCLASSES} LocaleProviders getPlatformLocale format`
-DEFFMTLANG=`echo ${PLATDEF} | sed -e "s/,.*//"`
-DEFFMTCTRY=`echo ${PLATDEF} | sed -e "s/.*,//"`
-echo "DEFFMTLANG=${DEFFMTLANG}"
-echo "DEFFMTCTRY=${DEFFMTCTRY}"
-
-runTest()
-{
- RUNCMD="${TESTJAVA}${FS}bin${FS}java ${TESTVMOPTS} ${EXTRAOPTS} -classpath ${TESTCLASSES}${PS}${SPICLASSES} -Djava.locale.providers=$PREFLIST LocaleProviders $METHODNAME $PARAM1 $PARAM2 $PARAM3"
- echo ${RUNCMD}
- ${RUNCMD}
- result=$?
- if [ $result -eq 0 ]
- then
- echo "Execution successful"
- else
- echo "Execution of the test case failed."
- exit $result
- fi
-}
-
-# testing HOST is selected for the default locale, if specified on Windows or MacOSX
-METHODNAME=adapterTest
-PREFLIST=HOST,JRE
-case "$OS" in
- Windows_NT* )
- WINVER=`uname -r`
- if [ "${WINVER}" = "5" ]
- then
- PARAM1=JRE
- else
- PARAM1=HOST
- fi
- ;;
- CYGWIN_NT-6* | CYGWIN_NT-10* | Darwin )
- PARAM1=HOST
- ;;
- * )
- PARAM1=JRE
- ;;
-esac
-PARAM2=${DEFLANG}
-PARAM3=${DEFCTRY}
-runTest
-
-# testing HOST is NOT selected for the non-default locale, if specified
-METHODNAME=adapterTest
-PREFLIST=HOST,JRE
-PARAM1=JRE
-# Try to find the locale JRE supports which is not the platform default (HOST supports that one)
-if [ "${DEFLANG}" != "en" ] && [ "${DEFFMTLANG}" != "en" ]; then
- PARAM2=en
- PARAM3=US
-elif [ "${DEFLANG}" != "ja" ] && [ "${DEFFMTLANG}" != "ja" ]; then
- PARAM2=ja
- PARAM3=JP
-else
- PARAM2=zh
- PARAM3=CN
-fi
-SPICLASSES=
-runTest
-
-# testing SPI is NOT selected, as there is none.
-METHODNAME=adapterTest
-PREFLIST=SPI,JRE
-PARAM1=JRE
-PARAM2=en
-PARAM3=US
-SPICLASSES=
-runTest
-PREFLIST=SPI,COMPAT
-runTest
-
-# testing the order, variaton #1. This assumes en_GB DateFormat data are available both in JRE & CLDR
-METHODNAME=adapterTest
-PREFLIST=CLDR,JRE
-PARAM1=CLDR
-PARAM2=en
-PARAM3=GB
-SPICLASSES=
-runTest
-PREFLIST=CLDR,COMPAT
-runTest
-
-# testing the order, variaton #2. This assumes en_GB DateFormat data are available both in JRE & CLDR
-METHODNAME=adapterTest
-PREFLIST=JRE,CLDR
-PARAM1=JRE
-PARAM2=en
-PARAM3=GB
-SPICLASSES=
-runTest
-PREFLIST=COMPAT,CLDR
-runTest
-
-# testing the order, variaton #3 for non-existent locale in JRE assuming "haw" is not in JRE.
-METHODNAME=adapterTest
-PREFLIST=JRE,CLDR
-PARAM1=CLDR
-PARAM2=haw
-PARAM3=
-SPICLASSES=
-runTest
-PREFLIST=COMPAT,CLDR
-runTest
-
-# testing the order, variaton #4 for the bug 7196799. CLDR's "zh" data should be used in "zh_CN"
-METHODNAME=adapterTest
-PREFLIST=CLDR
-PARAM1=CLDR
-PARAM2=zh
-PARAM3=CN
-SPICLASSES=
-runTest
-
-# testing FALLBACK provider. SPI and invalid one cases.
-METHODNAME=adapterTest
-PREFLIST=SPI
-PARAM1=FALLBACK
-PARAM2=en
-PARAM3=US
-SPICLASSES=
-runTest
-PREFLIST=FOO
-PARAM1=CLDR
-PARAM2=en
-PARAM3=US
-SPICLASSES=
-runTest
-PREFLIST=BAR,SPI
-PARAM1=FALLBACK
-PARAM2=en
-PARAM3=US
-SPICLASSES=
-runTest
-
-# testing 7198834 fix. Only works on Windows Vista or upper.
-METHODNAME=bug7198834Test
-PREFLIST=HOST
-PARAM1=
-PARAM2=
-PARAM3=
-SPICLASSES=
-runTest
-
-# testing 8000245 fix.
-METHODNAME=tzNameTest
-PREFLIST=JRE
-PARAM1=Europe/Moscow
-PARAM2=
-PARAM3=
-SPICLASSES=${SPIDIR}
-runTest
-PREFLIST=COMPAT
-runTest
-
-# testing 8000615 fix.
-METHODNAME=tzNameTest
-PREFLIST=JRE
-PARAM1=America/Los_Angeles
-PARAM2=
-PARAM3=
-SPICLASSES=${SPIDIR}
-runTest
-PREFLIST=COMPAT
-runTest
-
-# testing 8001440 fix.
-METHODNAME=bug8001440Test
-PREFLIST=CLDR
-PARAM1=
-PARAM2=
-PARAM3=
-SPICLASSES=
-runTest
-
-# testing 8010666 fix.
-if [ "${DEFLANG}" = "en" ]
-then
- METHODNAME=bug8010666Test
- PREFLIST=HOST
- PARAM1=
- PARAM2=
- PARAM3=
- SPICLASSES=
- runTest
-fi
-
-# testing 8013086 fix.
-METHODNAME=bug8013086Test
-PREFLIST=JRE,SPI
-PARAM1=ja
-PARAM2=JP
-PARAM3=
-SPICLASSES=${SPIDIR}
-runTest
-PREFLIST=COMPAT,SPI
-runTest
-
-# testing 8013903 fix. (Windows only)
-METHODNAME=bug8013903Test
-PREFLIST=HOST,JRE
-PARAM1=
-PARAM2=
-PARAM3=
-SPICLASSES=
-runTest
-PREFLIST=HOST
-runTest
-PREFLIST=HOST,COMPAT
-runTest
-
-# testing 8027289 fix, if the platform format default is zh_CN
-# this assumes Windows' currency symbol for zh_CN is \u00A5, the yen
-# (yuan) sign.
-if [ "${DEFFMTLANG}" = "zh" ] && [ "${DEFFMTCTRY}" = "CN" ]; then
- METHODNAME=bug8027289Test
- PREFLIST=JRE,HOST
- PARAM1=FFE5
- PARAM2=
- PARAM3=
- SPICLASSES=
- runTest
- PREFLIST=COMPAT,HOST
- runTest
- PREFLIST=HOST
- PARAM1=00A5
- runTest
-fi
-
-exit $result
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Locale/LocaleProvidersRun.java Wed Oct 17 16:37:41 2018 +0800
@@ -0,0 +1,170 @@
+/*
+ * Copyright (c) 2012, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test
+ * @bug 6336885 7196799 7197573 7198834 8000245 8000615 8001440 8008577
+ * 8010666 8013086 8013233 8013903 8015960 8028771 8054482 8062006
+ * 8150432
+ * @summary tests for "java.locale.providers" system property
+ * @library /test/lib
+ * @build LocaleProviders
+ * providersrc.spi.src.tznp
+ * providersrc.spi.src.tznp8013086
+ * @modules java.base/sun.util.locale
+ * java.base/sun.util.locale.provider
+ * @run main LocaleProvidersRun
+ */
+
+import java.util.Locale;
+
+import jdk.test.lib.JDKToolLauncher;
+import jdk.test.lib.process.ProcessTools;
+import jdk.test.lib.Utils;
+
+public class LocaleProvidersRun {
+ public static void main(String[] args) throws Throwable {
+ //get the platform default locales
+ Locale platDefLoc = Locale.getDefault(Locale.Category.DISPLAY);
+ String defLang = platDefLoc.getLanguage();
+ String defCtry = platDefLoc.getCountry();
+ System.out.println("DEFLANG = " + defLang);
+ System.out.println("DEFCTRY = " + defCtry);
+
+ Locale platDefFormat = Locale.getDefault(Locale.Category.FORMAT);
+ String defFmtLang = platDefFormat.getLanguage();
+ String defFmtCtry = platDefFormat.getCountry();
+ System.out.println("DEFFMTLANG = " + defFmtLang);
+ System.out.println("DEFFMTCTRY = " + defFmtCtry);
+
+ //Run Test
+ //testing HOST is selected for the default locale,
+ // if specified on Windows or MacOSX
+ String osName = System.getProperty("os.name");
+ String param1 = "JRE";
+ if(osName.startsWith("Windows") || osName.startsWith("Mac")) {
+ param1 = "HOST";
+ }
+ testRun("HOST,JRE", "adapterTest", param1, defLang, defCtry);
+
+ //testing HOST is NOT selected for the non-default locale, if specified
+ //Try to find the locale JRE supports which is not the platform default
+ // (HOST supports that one)
+ String param2;
+ String param3;
+ if (!defLang.equals("en") && !defFmtLang.equals("en")){
+ param2 = "en";
+ param3 = "US";
+ } else if(!defLang.equals("ja") && !defFmtLang.equals("ja")){
+ param2 = "ja";
+ param3 = "JP";
+ } else {
+ param2 = "zh";
+ param3 = "CN";
+ }
+ testRun("HOST,JRE", "adapterTest", "JRE", param2, param3);
+
+ //testing SPI is NOT selected, as there is none.
+ testRun("SPI,JRE", "adapterTest", "JRE", "en", "US");
+ testRun("SPI,COMPAT", "adapterTest", "JRE", "en", "US");
+
+ //testing the order, variant #1. This assumes en_GB DateFormat data are
+ // available both in JRE & CLDR
+ testRun("CLDR,JRE", "adapterTest", "CLDR", "en", "GB");
+ testRun("CLDR,COMPAT", "adapterTest", "CLDR", "en", "GB");
+
+ //testing the order, variant #2. This assumes en_GB DateFormat data are
+ // available both in JRE & CLDR
+ testRun("JRE,CLDR", "adapterTest", "JRE", "en", "GB");
+ testRun("COMPAT,CLDR", "adapterTest", "JRE", "en", "GB");
+
+ //testing the order, variant #3 for non-existent locale in JRE
+ // assuming "haw" is not in JRE.
+ testRun("JRE,CLDR", "adapterTest", "CLDR", "haw", "");
+ testRun("COMPAT,CLDR", "adapterTest", "CLDR", "haw", "");
+
+ //testing the order, variant #4 for the bug 7196799. CLDR's "zh" data
+ // should be used in "zh_CN"
+ testRun("CLDR", "adapterTest", "CLDR", "zh", "CN");
+
+ //testing FALLBACK provider. SPI and invalid one cases.
+ testRun("SPI", "adapterTest", "FALLBACK", "en", "US");
+ testRun("FOO", "adapterTest", "CLDR", "en", "US");
+ testRun("BAR,SPI", "adapterTest", "FALLBACK", "en", "US");
+
+ //testing 7198834 fix.
+ testRun("HOST", "bug7198834Test", "", "", "");
+
+ //testing 8000245 fix.
+ testRun("JRE", "tzNameTest", "Europe/Moscow", "", "");
+ testRun("COMPAT", "tzNameTest", "Europe/Moscow", "", "");
+
+ //testing 8000615 fix.
+ testRun("JRE", "tzNameTest", "America/Los_Angeles", "", "");
+ testRun("COMPAT", "tzNameTest", "America/Los_Angeles", "", "");
+
+ //testing 8001440 fix.
+ testRun("CLDR", "bug8001440Test", "", "", "");
+
+ //testing 8010666 fix.
+ if (defLang.equals("en")) {
+ testRun("HOST", "bug8010666Test", "", "", "");
+ }
+
+ //testing 8013086 fix.
+ testRun("JRE,SPI", "bug8013086Test", "ja", "JP", "");
+ testRun("COMPAT,SPI", "bug8013086Test", "ja", "JP", "");
+
+ //testing 8013903 fix. (Windows only)
+ testRun("HOST,JRE", "bug8013903Test", "", "", "");
+ testRun("HOST", "bug8013903Test", "", "", "");
+ testRun("HOST,COMPAT", "bug8013903Test", "", "", "");
+
+ //testing 8027289 fix, if the platform format default is zh_CN
+ // this assumes Windows' currency symbol for zh_CN is \u00A5, the yen
+ // (yuan) sign.
+ if (!defLang.equals("en") && !defCtry.equals("CN")){
+ testRun("JRE,HOST", "bug8027289Test", "FFE5", "", "");
+ testRun("COMPAT,HOST", "bug8027289Test", "FFE5", "", "");
+ testRun("HOST", "bug8027289Test", "00A5", "", "");
+ }
+ }
+
+ private static void testRun(String prefList, String methodName,
+ String param1, String param2, String param3) throws Throwable{
+ JDKToolLauncher launcher = JDKToolLauncher.createUsingTestJDK("java");
+ launcher.addToolArg("-cp")
+ .addToolArg(Utils.TEST_CLASS_PATH)
+ .addToolArg("-Djava.locale.providers=" + prefList)
+ .addToolArg("LocaleProviders")
+ .addToolArg(methodName)
+ .addToolArg(param1)
+ .addToolArg(param2)
+ .addToolArg(param3);
+ int exitCode = ProcessTools.executeCommand(launcher.getCommand())
+ .getExitValue();
+ if (exitCode != 0) {
+ throw new RuntimeException("Unexpected exit code: " + exitCode);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Locale/providersrc/spi/dest/META-INF/services/java.util.spi.TimeZoneNameProvider Wed Oct 17 16:37:41 2018 +0800
@@ -0,0 +1,2 @@
+tznp
+tznp8013086
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Locale/providersrc/spi/src/tznp.java Wed Oct 17 16:37:41 2018 +0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2012, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package providersrc.spi.src;
+
+import java.util.spi.TimeZoneNameProvider;
+import java.util.Locale;
+
+public class tznp extends TimeZoneNameProvider {
+ public String getDisplayName(String ID, boolean daylight, int style,
+ Locale locale) {
+ return "tznp";
+ }
+
+ public Locale[] getAvailableLocales() {
+ Locale[] locales = {Locale.US};
+ return locales;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test/jdk/java/util/Locale/providersrc/spi/src/tznp8013086.java Wed Oct 17 16:37:41 2018 +0800
@@ -0,0 +1,43 @@
+/*
+ * Copyright (c) 2012, 2018, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package providersrc.spi.src;
+import java.util.spi.TimeZoneNameProvider;
+import java.util.Locale;
+import java.util.TimeZone;
+
+public class tznp8013086 extends TimeZoneNameProvider {
+ public String getDisplayName(String ID, boolean daylight, int style,
+ Locale locale) {
+ if (!daylight && style == TimeZone.LONG) {
+ return "tznp8013086";
+ } else {
+ return null;
+ }
+ }
+
+ public Locale[] getAvailableLocales() {
+ Locale[] locales = {Locale.JAPAN};
+ return locales;
+ }
+}