Path: blob/master/test/jdk/java/util/Locale/Bug4152725.java
41149 views
/*1* Copyright (c) 2007, 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*/22/*23* @test24* @bug 415272525* @summary Verify that the default locale can be specified from the26* command line.27* @run main/othervm -Duser.language=de -Duser.country=DE -Duser.variant=EURO28* Bug4152725 de_DE_EURO29* @run main/othervm -Duser.language=ja -Duser.country= -Duser.variant=30* Bug4152725 ja31* @run main/othervm -Duser.language=en -Duser.country=SG -Duser.variant=32* Bug4152725 en_SG33* @run main/othervm -Duser.language= -Duser.country=DE -Duser.variant=EURO34* Bug4152725 _DE_EURO35* @run main/othervm -Duser.language=ja -Duser.country= -Duser.variant=YOMI36* Bug4152725 ja__YOMI37* @run main/othervm -Duser.language= -Duser.country= -Duser.variant=EURO38* Bug4152725 __EURO39* @run main/othervm -Duser.language=de -Duser.region=DE_EURO40* Bug4152725 de_DE_EURO41*/4243import java.util.Locale;4445public class Bug4152725 {4647public static void main(String[] args) {4849if (args.length != 1) {50throw new RuntimeException("expected locale needs to be specified");51}5253Locale locale = Locale.getDefault();5455// don't use Locale.toString - it's bogus56String language = locale.getLanguage();57String country = locale.getCountry();58String variant = locale.getVariant();59String localeID = null;60if (variant.length() > 0) {61localeID = language + "_" + country + "_" + variant;62} else if (country.length() > 0) {63localeID = language + "_" + country;64} else {65localeID = language;66}6768if (localeID.equals(args[0])) {69System.out.println("Correctly set from command line: " + localeID);70} else {71throw new RuntimeException("expected default locale: " + args[0]72+ ", actual default locale: " + localeID);73}74}75}767778