Path: blob/master/test/jdk/java/beans/XMLDecoder/Test6341798.java
41149 views
/*1* Copyright (c) 2005, 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*/2223/*24* @test25* @bug 634179826* @summary Tests name generation for turkish locale27* @author Sergey Malenkov28*/2930import java.beans.XMLDecoder;31import java.io.ByteArrayInputStream;32import java.util.Locale;3334import static java.util.Locale.ENGLISH;3536public class Test6341798 {37private static final Locale TURKISH = new Locale("tr");3839private static final String DATA40= "<java>\n"41+ " <object class=\"Test6341798$DataBean\">\n"42+ " <void property=\"illegal\">\n"43+ " <boolean>true</boolean>\n"44+ " </void>\n"45+ " </object>\n"46+ "</java> ";4748public static void main(String[] args) {49Locale reservedLocale = Locale.getDefault();50try {51test(ENGLISH, DATA.getBytes());52test(TURKISH, DATA.getBytes());53} finally {54// restore the reserved locale55Locale.setDefault(reservedLocale);56}57}5859private static void test(Locale locale, byte[] data) {60Locale.setDefault(locale);61System.out.println("locale = " + locale);6263XMLDecoder decoder = new XMLDecoder(new ByteArrayInputStream(data));64System.out.println("object = " + decoder.readObject());65decoder.close();66}6768public static class DataBean {69private boolean illegal;7071public boolean isIllegal() {72return this.illegal;73}7475public void setIllegal(boolean illegal) {76this.illegal = illegal;77}7879public String toString() {80if (this.illegal) {81return "property is set";82}83throw new Error("property is not set");84}85}86}878889