Path: blob/jdk8u272-b10-aarch32-20201026/jdk/test/java/beans/XMLEncoder/Test4625418.java
83402 views
/*1* Copyright (c) 2006, 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*/2223/*24* @test25* @bug 462541826* @summary Tests XML <a href="http://download.java.net/jdk6/docs/technotes/guides/intl/encoding.doc.html">encoding</a>27* @author Sergey Malenkov28*29* @run main Test4625418 ASCII30* @run main Test4625418 Big531* ?run main Test4625418 Big5-HKSCS32* ?run main Test4625418 Big5_HKSCS33* @run main Test4625418 Big5_Solaris34* ?run main Test4625418 Cp03735* @run main Test4625418 Cp100636* ?run main Test4625418 Cp102537* -run main Test4625418 Cp102638* @run main Test4625418 Cp104639* @run main Test4625418 Cp104740* @run main Test4625418 Cp109741* @run main Test4625418 Cp109842* ?run main Test4625418 Cp111243* ?run main Test4625418 Cp112244* ?run main Test4625418 Cp112345* @run main Test4625418 Cp112446* ?run main Test4625418 Cp114047* ?run main Test4625418 Cp114148* ?run main Test4625418 Cp114249* ?run main Test4625418 Cp114350* ?run main Test4625418 Cp114451* ?run main Test4625418 Cp114552* ?run main Test4625418 Cp114653* ?run main Test4625418 Cp114754* ?run main Test4625418 Cp114855* ?run main Test4625418 Cp114956* @run main Test4625418 Cp125057* @run main Test4625418 Cp125158* @run main Test4625418 Cp125259* @run main Test4625418 Cp125360* @run main Test4625418 Cp125461* @run main Test4625418 Cp125562* @run main Test4625418 Cp125663* @run main Test4625418 Cp125764* @run main Test4625418 Cp125865* ?run main Test4625418 Cp138166* ?run main Test4625418 Cp138367* ?run main Test4625418 Cp27368* ?run main Test4625418 Cp27769* ?run main Test4625418 Cp27870* ?run main Test4625418 Cp28071* ?run main Test4625418 Cp28472* ?run main Test4625418 Cp28573* ?run main Test4625418 Cp29774* ?run main Test4625418 Cp3372275* ?run main Test4625418 Cp42076* ?run main Test4625418 Cp42477* @run main Test4625418 Cp43778* ?run main Test4625418 Cp50079* ?run main Test4625418 Cp5022080* ?run main Test4625418 Cp5022181* @run main Test4625418 Cp73782* @run main Test4625418 Cp77583* -run main Test4625418 Cp83484* ?run main Test4625418 Cp83885* @run main Test4625418 Cp85086* @run main Test4625418 Cp85287* @run main Test4625418 Cp85588* @run main Test4625418 Cp85689* @run main Test4625418 Cp85790* @run main Test4625418 Cp85891* @run main Test4625418 Cp86092* @run main Test4625418 Cp86193* @run main Test4625418 Cp86294* @run main Test4625418 Cp86395* @run main Test4625418 Cp86496* @run main Test4625418 Cp86597* @run main Test4625418 Cp86698* @run main Test4625418 Cp86899* @run main Test4625418 Cp869100* ?run main Test4625418 Cp870101* ?run main Test4625418 Cp871102* @run main Test4625418 Cp874103* ?run main Test4625418 Cp875104* ?run main Test4625418 Cp918105* @run main Test4625418 Cp921106* @run main Test4625418 Cp922107* -run main Test4625418 Cp930108* @run main Test4625418 Cp933109* ?run main Test4625418 Cp935110* ?run main Test4625418 Cp937111* ?run main Test4625418 Cp939112* ?run main Test4625418 Cp942113* ?run main Test4625418 Cp942C114* @run main Test4625418 Cp943115* ?run main Test4625418 Cp943C116* @run main Test4625418 Cp948117* @run main Test4625418 Cp949118* ?run main Test4625418 Cp949C119* @run main Test4625418 Cp950120* @run main Test4625418 Cp964121* ?run main Test4625418 Cp970122* ?run main Test4625418 EUC-JP123* @run main Test4625418 EUC-KR124* @run main Test4625418 EUC_CN125* ?run main Test4625418 EUC_JP126* ?run main Test4625418 EUC_JP_LINUX127* ?run main Test4625418 EUC_JP_Solaris128* @run main Test4625418 EUC_KR129* ?run main Test4625418 EUC_TW130* @run main Test4625418 GB18030131* @run main Test4625418 GB2312132* @run main Test4625418 GBK133* ?run main Test4625418 IBM-Thai134* @run main Test4625418 IBM00858135* ?run main Test4625418 IBM01140136* ?run main Test4625418 IBM01141137* ?run main Test4625418 IBM01142138* ?run main Test4625418 IBM01143139* ?run main Test4625418 IBM01144140* ?run main Test4625418 IBM01145141* ?run main Test4625418 IBM01146142* ?run main Test4625418 IBM01147143* ?run main Test4625418 IBM01148144* ?run main Test4625418 IBM01149145* ?run main Test4625418 IBM037146* -run main Test4625418 IBM1026147* @run main Test4625418 IBM1047148* ?run main Test4625418 IBM273149* ?run main Test4625418 IBM277150* ?run main Test4625418 IBM278151* ?run main Test4625418 IBM280152* ?run main Test4625418 IBM284153* ?run main Test4625418 IBM285154* ?run main Test4625418 IBM297155* ?run main Test4625418 IBM420156* ?run main Test4625418 IBM424157* @run main Test4625418 IBM437158* ?run main Test4625418 IBM500159* @run main Test4625418 IBM775160* @run main Test4625418 IBM850161* @run main Test4625418 IBM852162* @run main Test4625418 IBM855163* @run main Test4625418 IBM857164* @run main Test4625418 IBM860165* @run main Test4625418 IBM861166* @run main Test4625418 IBM862167* @run main Test4625418 IBM863168* @run main Test4625418 IBM864169* @run main Test4625418 IBM865170* @run main Test4625418 IBM866171* @run main Test4625418 IBM868172* @run main Test4625418 IBM869173* ?run main Test4625418 IBM870174* ?run main Test4625418 IBM871175* ?run main Test4625418 IBM918176* ?run main Test4625418 ISCII91177* -run main Test4625418 ISO-2022-CN178* @run main Test4625418 ISO-2022-JP179* @run main Test4625418 ISO-2022-KR180* @run main Test4625418 ISO-8859-1181* @run main Test4625418 ISO-8859-13182* @run main Test4625418 ISO-8859-15183* @run main Test4625418 ISO-8859-2184* @run main Test4625418 ISO-8859-3185* @run main Test4625418 ISO-8859-4186* @run main Test4625418 ISO-8859-5187* @run main Test4625418 ISO-8859-6188* @run main Test4625418 ISO-8859-7189* @run main Test4625418 ISO-8859-8190* @run main Test4625418 ISO-8859-9191* -run main Test4625418 ISO2022CN192* @run main Test4625418 ISO2022JP193* @run main Test4625418 ISO2022KR194* -run main Test4625418 ISO2022_CN_CNS195* -run main Test4625418 ISO2022_CN_GB196* @run main Test4625418 ISO8859_1197* @run main Test4625418 ISO8859_13198* @run main Test4625418 ISO8859_15199* @run main Test4625418 ISO8859_2200* @run main Test4625418 ISO8859_3201* @run main Test4625418 ISO8859_4202* @run main Test4625418 ISO8859_5203* @run main Test4625418 ISO8859_6204* @run main Test4625418 ISO8859_7205* @run main Test4625418 ISO8859_8206* @run main Test4625418 ISO8859_9207* -run main Test4625418 JISAutoDetect208* ?run main Test4625418 JIS_X0201209* -run main Test4625418 JIS_X0212-1990210* @run main Test4625418 KOI8-R211* @run main Test4625418 KOI8-U212* @run main Test4625418 KOI8_R213* @run main Test4625418 KOI8_U214* @run main Test4625418 MS874215* ?run main Test4625418 MS932216* ?run main Test4625418 MS936217* @run main Test4625418 MS949218* @run main Test4625418 MS950219* ?run main Test4625418 MS950_HKSCS220* @run main Test4625418 MacArabic221* @run main Test4625418 MacCentralEurope222* @run main Test4625418 MacCroatian223* @run main Test4625418 MacCyrillic224* -run main Test4625418 MacDingbat225* @run main Test4625418 MacGreek226* @run main Test4625418 MacHebrew227* @run main Test4625418 MacIceland228* @run main Test4625418 MacRoman229* @run main Test4625418 MacRomania230* -run main Test4625418 MacSymbol231* @run main Test4625418 MacThai232* @run main Test4625418 MacTurkish233* @run main Test4625418 MacUkraine234* ?run main Test4625418 PCK235* ?run main Test4625418 SJIS236* ?run main Test4625418 Shift_JIS237* @run main Test4625418 TIS-620238* @run main Test4625418 TIS620239* @run main Test4625418 US-ASCII240* @run main Test4625418 UTF-16241* @run main Test4625418 UTF-16BE242* @run main Test4625418 UTF-16LE243* @run main Test4625418 UTF-32244* @run main Test4625418 UTF-32BE245* @run main Test4625418 UTF-32LE246* @run main Test4625418 UTF-8247* @run main Test4625418 UTF8248* @run main Test4625418 UTF_32249* @run main Test4625418 UTF_32BE250* -run main Test4625418 UTF_32BE_BOM251* @run main Test4625418 UTF_32LE252* -run main Test4625418 UTF_32LE_BOM253* @run main Test4625418 UnicodeBig254* @run main Test4625418 UnicodeBigUnmarked255* @run main Test4625418 UnicodeLittle256* @run main Test4625418 UnicodeLittleUnmarked257* @run main Test4625418 windows-1250258* @run main Test4625418 windows-1251259* @run main Test4625418 windows-1252260* @run main Test4625418 windows-1253261* @run main Test4625418 windows-1254262* @run main Test4625418 windows-1255263* @run main Test4625418 windows-1256264* @run main Test4625418 windows-1257265* @run main Test4625418 windows-1258266* ?run main Test4625418 windows-31j267* -run main Test4625418 x-Big5_Solaris268* ?run main Test4625418 x-EUC-TW269* @run main Test4625418 x-IBM1006270* ?run main Test4625418 x-IBM1025271* @run main Test4625418 x-IBM1046272* @run main Test4625418 x-IBM1097273* @run main Test4625418 x-IBM1098274* ?run main Test4625418 x-IBM1112275* ?run main Test4625418 x-IBM1122276* ?run main Test4625418 x-IBM1123277* @run main Test4625418 x-IBM1124278* ?run main Test4625418 x-IBM1381279* ?run main Test4625418 x-IBM1383280* ?run main Test4625418 x-IBM33722281* @run main Test4625418 x-IBM737282* -run main Test4625418 x-IBM834283* @run main Test4625418 x-IBM856284* @run main Test4625418 x-IBM874285* ?run main Test4625418 x-IBM875286* @run main Test4625418 x-IBM921287* @run main Test4625418 x-IBM922288* -run main Test4625418 x-IBM930289* @run main Test4625418 x-IBM933290* ?run main Test4625418 x-IBM935291* ?run main Test4625418 x-IBM937292* ?run main Test4625418 x-IBM939293* ?run main Test4625418 x-IBM942294* ?run main Test4625418 x-IBM942C295* @run main Test4625418 x-IBM943296* ?run main Test4625418 x-IBM943C297* @run main Test4625418 x-IBM948298* @run main Test4625418 x-IBM949299* ?run main Test4625418 x-IBM949C300* @run main Test4625418 x-IBM950301* @run main Test4625418 x-IBM964302* ?run main Test4625418 x-IBM970303* ?run main Test4625418 x-ISCII91304* -run main Test4625418 x-ISO2022-CN-CNS305* -run main Test4625418 x-ISO2022-CN-GB306* -run main Test4625418 x-JIS0208307* -run main Test4625418 x-JISAutoDetect308* @run main Test4625418 x-Johab309* ?run main Test4625418 x-MS950-HKSCS310* @run main Test4625418 x-MacArabic311* @run main Test4625418 x-MacCentralEurope312* @run main Test4625418 x-MacCroatian313* @run main Test4625418 x-MacCyrillic314* -run main Test4625418 x-MacDingbat315* @run main Test4625418 x-MacGreek316* @run main Test4625418 x-MacHebrew317* @run main Test4625418 x-MacIceland318* @run main Test4625418 x-MacRoman319* @run main Test4625418 x-MacRomania320* -run main Test4625418 x-MacSymbol321* @run main Test4625418 x-MacThai322* @run main Test4625418 x-MacTurkish323* @run main Test4625418 x-MacUkraine324* ?run main Test4625418 x-PCK325* @run main Test4625418 x-UTF-16LE-BOM326* -run main Test4625418 x-UTF-32BE-BOM327* -run main Test4625418 x-UTF-32LE-BOM328* ?run main Test4625418 x-euc-jp-linux329* ?run main Test4625418 x-eucJP-Open330* @run main Test4625418 x-iso-8859-11331* @run main Test4625418 x-mswin-936332* ?run main Test4625418 x-windows-50220333* ?run main Test4625418 x-windows-50221334* @run main Test4625418 x-windows-874335* @run main Test4625418 x-windows-949336* @run main Test4625418 x-windows-950337* ?run main Test4625418 x-windows-iso2022jp338*/339340import java.beans.ExceptionListener;341import java.beans.XMLDecoder;342import java.beans.XMLEncoder;343import java.io.File;344import java.io.FileInputStream;345import java.io.FileNotFoundException;346import java.io.FileOutputStream;347import java.nio.charset.IllegalCharsetNameException;348import java.nio.charset.UnsupportedCharsetException;349350public final class Test4625418 implements ExceptionListener {351public static void main(String[] args) {352new Test4625418(args[0]).test(createString(0x10000));353System.out.println("Test passed: " + args[0]);354}355356private static String createString(int length) {357StringBuilder sb = new StringBuilder(length);358while (0 < length--)359sb.append((char) length);360361return sb.toString();362}363364private final String encoding;365366private Test4625418(String encoding) {367this.encoding = encoding;368}369370private void test(String string) {371try {372File file = new File("4625418." + this.encoding + ".xml");373374FileOutputStream output = new FileOutputStream(file);375XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0);376encoder.setExceptionListener(this);377encoder.writeObject(string);378encoder.close();379380FileInputStream input = new FileInputStream(file);381XMLDecoder decoder = new XMLDecoder(input);382decoder.setExceptionListener(this);383Object object = decoder.readObject();384decoder.close();385386if (!string.equals(object))387throw new Error(this.encoding + " - can't read properly");388389file.delete();390}391catch (FileNotFoundException exception) {392throw new Error(this.encoding + " - file not found", exception);393}394catch (IllegalCharsetNameException exception) {395throw new Error(this.encoding + " - illegal charset name", exception);396}397catch (UnsupportedCharsetException exception) {398throw new Error(this.encoding + " - unsupported charset", exception);399}400catch (UnsupportedOperationException exception) {401throw new Error(this.encoding + " - unsupported encoder", exception);402}403}404405public void exceptionThrown(Exception exception) {406throw new Error(this.encoding + " - internal", exception);407}408}409410411