Path: blob/master/test/jdk/sun/util/resources/Locale/Bug4965260.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* @bug 4965260 800857725* @modules jdk.localedata26* @summary Verifies the language name of "nl" for supported locales27* @run main/othervm -Djava.locale.providers=JRE,SPI Bug496526028*/2930import java.util.Locale;3132public class Bug4965260 {3334// Define supported locales35static Locale[] locales2Test = new Locale[] {36new Locale("de"),37new Locale("es"),38new Locale("fr"),39new Locale("it"),40new Locale("sv")41};4243static String[] expectedNames = new String[] {44"Niederl\u00e4ndisch",45"neerland\u00e9s",46"n\u00e9erlandais",47"neerlandese",48"nederl\u00e4ndska"49};5051public static void main(String[] args) throws Exception {52Locale reservedLocale = Locale.getDefault();53try {54Locale.setDefault(Locale.ENGLISH);55if (locales2Test.length != expectedNames.length) {56throw new Exception("\nData sizes does not match!\n");57}5859StringBuffer message = new StringBuffer("");60Locale dutch = new Locale("nl", "BE");61String current;62for (int i = 0; i < locales2Test.length; i++) {63Locale locale = locales2Test[i];64current = dutch.getDisplayLanguage(locale);65if (!current.equals(expectedNames[i])) {66message.append("[");67message.append(locale.getDisplayLanguage());68message.append("] ");69message.append("Language name is ");70message.append(current);71message.append(" should be ");72message.append(expectedNames[i]);73message.append("\n");74}75}7677if (message.length() >0) {78throw new Exception("\n" + message.toString());79}80} finally {81// restore the reserved locale82Locale.setDefault(reservedLocale);83}84}85}868788