Path: blob/master/test/jdk/java/util/Locale/bcp47u/SystemPropertyTests.java
41153 views
/*1* Copyright (c) 2017, 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* @library /test/lib26* @bug 818913427* @summary Tests the system properties28* @modules jdk.localedata29* @build DefaultLocaleTest30* @run testng/othervm SystemPropertyTests31*/3233import static jdk.test.lib.process.ProcessTools.executeTestJava;34import static org.testng.Assert.assertTrue;3536import java.util.Locale;3738import org.testng.annotations.DataProvider;39import org.testng.annotations.Test;4041/**42* Test Locale.getDefault() reflects the system property. Note that the43* result may change depending on the CLDR releases.44*/45@Test46public class SystemPropertyTests {4748private static String LANGPROP = "-Duser.language=en";49private static String SCPTPROP = "-Duser.script=";50private static String CTRYPROP = "-Duser.country=US";5152@DataProvider(name="data")53Object[][] data() {54return new Object[][] {55// system property, expected default, expected format, expected display56{"-Duser.extensions=u-ca-japanese",57"en_US_#u-ca-japanese",58"en_US_#u-ca-japanese",59"en_US_#u-ca-japanese",60},6162{"-Duser.extensions=u-ca-japanese-nu-thai",63"en_US_#u-ca-japanese-nu-thai",64"en_US_#u-ca-japanese-nu-thai",65"en_US_#u-ca-japanese-nu-thai",66},6768{"-Duser.extensions=foo",69"en_US",70"en_US",71"en_US",72},7374{"-Duser.extensions.format=u-ca-japanese",75"en_US",76"en_US_#u-ca-japanese",77"en_US",78},7980{"-Duser.extensions.display=u-ca-japanese",81"en_US",82"en_US",83"en_US_#u-ca-japanese",84},85};86}8788@Test(dataProvider="data")89public void runTest(String extprop, String defLoc,90String defFmtLoc, String defDspLoc) throws Exception {91int exitValue = executeTestJava(LANGPROP, SCPTPROP, CTRYPROP,92extprop, "DefaultLocaleTest", defLoc, defFmtLoc, defDspLoc)93.outputTo(System.out)94.errorTo(System.out)95.getExitValue();9697assertTrue(exitValue == 0);98}99}100101102