Path: blob/master/test/jdk/sun/util/resources/Locale/Bug4429024.java
41153 views
/*1* Copyright (c) 2007, 2016, 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* @summary checking localised language/country names in finnish25* @modules jdk.localedata26* @bug 4429024 4964035 6558856 800857727* @run main/othervm -Djava.locale.providers=JRE,SPI Bug442902428*/2930import java.util.Locale;3132public class Bug4429024 {3334public static void main(String[] args) throws Exception {3536int errors=0;3738String [][] fiLocales = {39{ "ar", "arabia" },40{ "ba", "baski" },41{ "bg", "bulgaria" },42{ "ca", "katalaani" },43{ "cs", "tsekki" },44{ "da", "tanska" },45{ "de", "saksa" },46{ "el", "kreikka" },47{ "en", "englanti" },48{ "es", "espanja" },49{ "fi", "suomi" },50{ "fr", "ranska" },51{ "he", "heprea" },52{ "hi", "hindi" },53{ "it", "italia" },54{ "ja", "japani" },55{ "lt", "liettua" },56{ "lv", "latvia" },57{ "nl", "hollanti" },58{ "no", "norja" },59{ "pl", "puola" },60{ "pt", "portugali" },61{ "ru", "ven\u00e4j\u00e4" },62{ "sv", "ruotsi" },63{ "th", "thai" },64{ "tr", "turkki" },65{ "zh", "kiina" }66};6768String[][] fiCountries = {69{ "BE", "Belgia" },70{ "BR", "Brasilia" },71{ "CA", "Kanada" },72{ "CH", "Sveitsi" },73{ "CN", "Kiina" },74{ "CZ", "Tsekin tasavalta" },75{ "DE", "Saksa" },76{ "DK", "Tanska" },77{ "ES", "Espanja" },78{ "FI", "Suomi" },79{ "FR", "Ranska" },80{ "GB", "Iso-Britannia" },81{ "GR", "Kreikka" },82{ "IE", "Irlanti" },83{ "IT", "Italia" },84{ "JP", "Japani" },85{ "KR", "Korea" },86{ "NL", "Alankomaat" },87{ "NO", "Norja" },88{ "PL", "Puola" },89{ "PT", "Portugali" },90{ "RU", "Ven\u00e4j\u00e4" },91{ "SE", "Ruotsi" },92{ "TR", "Turkki" },93{ "US", "Yhdysvallat" }94};9596for (int i=0; i < fiLocales.length; i++) {97errors += getLanguage(fiLocales[i][0], fiLocales[i][1]);98}99100for (int i=0; i < fiCountries.length; i++) {101errors += getCountry(fiCountries[i][0], fiCountries[i][1]);102}103104if(errors > 0){105throw new RuntimeException();106}107};108109110static int getLanguage(String inLang, String localizedName){111112Locale fiLocale = new Locale("fi", "FI");113Locale inLocale = new Locale (inLang, "");114115if (!inLocale.getDisplayLanguage(fiLocale).equals(localizedName)){116System.out.println("Language " + inLang +" should be \"" + localizedName + "\", not \"" + inLocale.getDisplayLanguage(fiLocale) + "\"");117return 1;118}119else{120return 0;121}122}123124static int getCountry(String inCountry, String localizedName){125126Locale fiLocale = new Locale("fi", "FI");127Locale inLocale = new Locale ("", inCountry);128129if (!inLocale.getDisplayCountry(fiLocale).equals(localizedName)){130System.out.println("Country " + inCountry + " should be \"" + localizedName + "\", not \"" + inLocale.getDisplayCountry(fiLocale) + "\"");131return 1;132}133else{134return 0;135}136137}138}139140141