Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/util/resources/Locale/Bug4429024.java
38854 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@summary checking localised language/country names in finnish25@bug 4429024 4964035 655885626*/2728import java.util.Locale;2930public class Bug4429024 {3132public static void main(String[] args) throws Exception {3334int errors=0;3536String [][] fiLocales = {37{ "ar", "arabia" },38{ "ba", "baski" },39{ "bg", "bulgaria" },40{ "ca", "katalaani" },41{ "cs", "tsekki" },42{ "da", "tanska" },43{ "de", "saksa" },44{ "el", "kreikka" },45{ "en", "englanti" },46{ "es", "espanja" },47{ "fi", "suomi" },48{ "fr", "ranska" },49{ "he", "heprea" },50{ "hi", "hindi" },51{ "it", "italia" },52{ "ja", "japani" },53{ "lt", "liettua" },54{ "lv", "latvia" },55{ "nl", "hollanti" },56{ "no", "norja" },57{ "pl", "puola" },58{ "pt", "portugali" },59{ "ru", "ven\u00e4j\u00e4" },60{ "sv", "ruotsi" },61{ "th", "thai" },62{ "tr", "turkki" },63{ "zh", "kiina" }64};6566String[][] fiCountries = {67{ "BE", "Belgia" },68{ "BR", "Brasilia" },69{ "CA", "Kanada" },70{ "CH", "Sveitsi" },71{ "CN", "Kiina" },72{ "CZ", "Tsekin tasavalta" },73{ "DE", "Saksa" },74{ "DK", "Tanska" },75{ "ES", "Espanja" },76{ "FI", "Suomi" },77{ "FR", "Ranska" },78{ "GB", "Iso-Britannia" },79{ "GR", "Kreikka" },80{ "IE", "Irlanti" },81{ "IT", "Italia" },82{ "JP", "Japani" },83{ "KR", "Korea" },84{ "NL", "Alankomaat" },85{ "NO", "Norja" },86{ "PL", "Puola" },87{ "PT", "Portugali" },88{ "RU", "Ven\u00e4j\u00e4" },89{ "SE", "Ruotsi" },90{ "TR", "Turkki" },91{ "US", "Yhdysvallat" }92};9394for (int i=0; i < fiLocales.length; i++) {95errors += getLanguage(fiLocales[i][0], fiLocales[i][1]);96}9798for (int i=0; i < fiCountries.length; i++) {99errors += getCountry(fiCountries[i][0], fiCountries[i][1]);100}101102if(errors > 0){103throw new RuntimeException();104}105};106107108static int getLanguage(String inLang, String localizedName){109110Locale fiLocale = new Locale("fi", "FI");111Locale inLocale = new Locale (inLang, "");112113if (!inLocale.getDisplayLanguage(fiLocale).equals(localizedName)){114System.out.println("Language " + inLang +" should be \"" + localizedName + "\", not \"" + inLocale.getDisplayLanguage(fiLocale) + "\"");115return 1;116}117else{118return 0;119}120}121122static int getCountry(String inCountry, String localizedName){123124Locale fiLocale = new Locale("fi", "FI");125Locale inLocale = new Locale ("", inCountry);126127if (!inLocale.getDisplayCountry(fiLocale).equals(localizedName)){128System.out.println("Country " + inCountry + " should be \"" + localizedName + "\", not \"" + inLocale.getDisplayCountry(fiLocale) + "\"");129return 1;130}131else{132return 0;133}134135}136}137138139