Path: blob/aarch64-shenandoah-jdk8u272-b10/jdk/test/sun/util/resources/Locale/Bug4965260.java
38854 views
/*1* Copyright (c) 2007, 2011, 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 496526025*@summary Verifies the language name of "nl" for supported locales26*/2728import java.util.Locale;2930public class Bug4965260 {3132// Define supported locales33static Locale[] locales2Test = new Locale[] {34new Locale("de"),35new Locale("es"),36new Locale("fr"),37new Locale("it"),38new Locale("sv")39};4041static String[] expectedNames = new String[] {42"Niederl\u00e4ndisch",43"neerland\u00e9s",44"n\u00e9erlandais",45"neerlandese",46"nederl\u00e4ndska"47};4849public static void main(String[] args) throws Exception {50Locale reservedLocale = Locale.getDefault();51try {52Locale.setDefault(Locale.ENGLISH);53if (locales2Test.length != expectedNames.length) {54throw new Exception("\nData sizes does not match!\n");55}5657StringBuffer message = new StringBuffer("");58Locale dutch = new Locale("nl", "BE");59String current;60for (int i = 0; i < locales2Test.length; i++) {61Locale locale = locales2Test[i];62current = dutch.getDisplayLanguage(locale);63if (!current.equals(expectedNames[i])) {64message.append("[");65message.append(locale.getDisplayLanguage());66message.append("] ");67message.append("Language name is ");68message.append(current);69message.append(" should be ");70message.append(expectedNames[i]);71message.append("\n");72}73}7475if (message.length() >0) {76throw new Exception("\n" + message.toString());77}78} finally {79// restore the reserved locale80Locale.setDefault(reservedLocale);81}82}83}848586