2
|
1 |
/*
|
5506
|
2 |
* Copyright (c) 2006, 2007, Oracle and/or its affiliates. All rights reserved.
|
2
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
4 |
*
|
|
5 |
* This code is free software; you can redistribute it and/or modify it
|
|
6 |
* under the terms of the GNU General Public License version 2 only, as
|
|
7 |
* published by the Free Software Foundation.
|
|
8 |
*
|
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
13 |
* accompanied this code).
|
|
14 |
*
|
|
15 |
* You should have received a copy of the GNU General Public License version
|
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
18 |
*
|
5506
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
20 |
* or visit www.oracle.com if you need additional information or have any
|
|
21 |
* questions.
|
2
|
22 |
*/
|
|
23 |
|
|
24 |
/*
|
|
25 |
* @test
|
|
26 |
* @bug 4625418
|
|
27 |
* @summary Tests XML <a href="http://download.java.net/jdk6/docs/technotes/guides/intl/encoding.doc.html">encoding</a>
|
|
28 |
* @author Sergey Malenkov
|
|
29 |
*
|
|
30 |
* @run main Test4625418 ASCII
|
|
31 |
* @run main Test4625418 Big5
|
|
32 |
* ?run main Test4625418 Big5-HKSCS
|
|
33 |
* ?run main Test4625418 Big5_HKSCS
|
|
34 |
* @run main Test4625418 Big5_Solaris
|
|
35 |
* ?run main Test4625418 Cp037
|
|
36 |
* @run main Test4625418 Cp1006
|
|
37 |
* ?run main Test4625418 Cp1025
|
|
38 |
* -run main Test4625418 Cp1026
|
|
39 |
* @run main Test4625418 Cp1046
|
|
40 |
* @run main Test4625418 Cp1047
|
|
41 |
* @run main Test4625418 Cp1097
|
|
42 |
* @run main Test4625418 Cp1098
|
|
43 |
* ?run main Test4625418 Cp1112
|
|
44 |
* ?run main Test4625418 Cp1122
|
|
45 |
* ?run main Test4625418 Cp1123
|
|
46 |
* @run main Test4625418 Cp1124
|
|
47 |
* ?run main Test4625418 Cp1140
|
|
48 |
* ?run main Test4625418 Cp1141
|
|
49 |
* ?run main Test4625418 Cp1142
|
|
50 |
* ?run main Test4625418 Cp1143
|
|
51 |
* ?run main Test4625418 Cp1144
|
|
52 |
* ?run main Test4625418 Cp1145
|
|
53 |
* ?run main Test4625418 Cp1146
|
|
54 |
* ?run main Test4625418 Cp1147
|
|
55 |
* ?run main Test4625418 Cp1148
|
|
56 |
* ?run main Test4625418 Cp1149
|
|
57 |
* @run main Test4625418 Cp1250
|
|
58 |
* @run main Test4625418 Cp1251
|
|
59 |
* @run main Test4625418 Cp1252
|
|
60 |
* @run main Test4625418 Cp1253
|
|
61 |
* @run main Test4625418 Cp1254
|
|
62 |
* @run main Test4625418 Cp1255
|
|
63 |
* @run main Test4625418 Cp1256
|
|
64 |
* @run main Test4625418 Cp1257
|
|
65 |
* @run main Test4625418 Cp1258
|
|
66 |
* ?run main Test4625418 Cp1381
|
|
67 |
* ?run main Test4625418 Cp1383
|
|
68 |
* ?run main Test4625418 Cp273
|
|
69 |
* ?run main Test4625418 Cp277
|
|
70 |
* ?run main Test4625418 Cp278
|
|
71 |
* ?run main Test4625418 Cp280
|
|
72 |
* ?run main Test4625418 Cp284
|
|
73 |
* ?run main Test4625418 Cp285
|
|
74 |
* ?run main Test4625418 Cp297
|
|
75 |
* ?run main Test4625418 Cp33722
|
|
76 |
* ?run main Test4625418 Cp420
|
|
77 |
* ?run main Test4625418 Cp424
|
|
78 |
* @run main Test4625418 Cp437
|
|
79 |
* ?run main Test4625418 Cp500
|
|
80 |
* ?run main Test4625418 Cp50220
|
|
81 |
* ?run main Test4625418 Cp50221
|
|
82 |
* @run main Test4625418 Cp737
|
|
83 |
* @run main Test4625418 Cp775
|
|
84 |
* -run main Test4625418 Cp834
|
|
85 |
* ?run main Test4625418 Cp838
|
|
86 |
* @run main Test4625418 Cp850
|
|
87 |
* @run main Test4625418 Cp852
|
|
88 |
* @run main Test4625418 Cp855
|
|
89 |
* @run main Test4625418 Cp856
|
|
90 |
* @run main Test4625418 Cp857
|
|
91 |
* @run main Test4625418 Cp858
|
|
92 |
* @run main Test4625418 Cp860
|
|
93 |
* @run main Test4625418 Cp861
|
|
94 |
* @run main Test4625418 Cp862
|
|
95 |
* @run main Test4625418 Cp863
|
|
96 |
* @run main Test4625418 Cp864
|
|
97 |
* @run main Test4625418 Cp865
|
|
98 |
* @run main Test4625418 Cp866
|
|
99 |
* @run main Test4625418 Cp868
|
|
100 |
* @run main Test4625418 Cp869
|
|
101 |
* ?run main Test4625418 Cp870
|
|
102 |
* ?run main Test4625418 Cp871
|
|
103 |
* @run main Test4625418 Cp874
|
|
104 |
* ?run main Test4625418 Cp875
|
|
105 |
* ?run main Test4625418 Cp918
|
|
106 |
* @run main Test4625418 Cp921
|
|
107 |
* @run main Test4625418 Cp922
|
|
108 |
* -run main Test4625418 Cp930
|
|
109 |
* @run main Test4625418 Cp933
|
|
110 |
* ?run main Test4625418 Cp935
|
|
111 |
* ?run main Test4625418 Cp937
|
|
112 |
* ?run main Test4625418 Cp939
|
|
113 |
* ?run main Test4625418 Cp942
|
|
114 |
* ?run main Test4625418 Cp942C
|
|
115 |
* @run main Test4625418 Cp943
|
|
116 |
* ?run main Test4625418 Cp943C
|
|
117 |
* @run main Test4625418 Cp948
|
|
118 |
* @run main Test4625418 Cp949
|
|
119 |
* ?run main Test4625418 Cp949C
|
|
120 |
* @run main Test4625418 Cp950
|
|
121 |
* @run main Test4625418 Cp964
|
|
122 |
* ?run main Test4625418 Cp970
|
|
123 |
* ?run main Test4625418 EUC-JP
|
|
124 |
* @run main Test4625418 EUC-KR
|
|
125 |
* @run main Test4625418 EUC_CN
|
|
126 |
* ?run main Test4625418 EUC_JP
|
|
127 |
* ?run main Test4625418 EUC_JP_LINUX
|
|
128 |
* ?run main Test4625418 EUC_JP_Solaris
|
|
129 |
* @run main Test4625418 EUC_KR
|
|
130 |
* ?run main Test4625418 EUC_TW
|
|
131 |
* @run main Test4625418 GB18030
|
|
132 |
* @run main Test4625418 GB2312
|
|
133 |
* @run main Test4625418 GBK
|
|
134 |
* ?run main Test4625418 IBM-Thai
|
|
135 |
* @run main Test4625418 IBM00858
|
|
136 |
* ?run main Test4625418 IBM01140
|
|
137 |
* ?run main Test4625418 IBM01141
|
|
138 |
* ?run main Test4625418 IBM01142
|
|
139 |
* ?run main Test4625418 IBM01143
|
|
140 |
* ?run main Test4625418 IBM01144
|
|
141 |
* ?run main Test4625418 IBM01145
|
|
142 |
* ?run main Test4625418 IBM01146
|
|
143 |
* ?run main Test4625418 IBM01147
|
|
144 |
* ?run main Test4625418 IBM01148
|
|
145 |
* ?run main Test4625418 IBM01149
|
|
146 |
* ?run main Test4625418 IBM037
|
|
147 |
* -run main Test4625418 IBM1026
|
|
148 |
* @run main Test4625418 IBM1047
|
|
149 |
* ?run main Test4625418 IBM273
|
|
150 |
* ?run main Test4625418 IBM277
|
|
151 |
* ?run main Test4625418 IBM278
|
|
152 |
* ?run main Test4625418 IBM280
|
|
153 |
* ?run main Test4625418 IBM284
|
|
154 |
* ?run main Test4625418 IBM285
|
|
155 |
* ?run main Test4625418 IBM297
|
|
156 |
* ?run main Test4625418 IBM420
|
|
157 |
* ?run main Test4625418 IBM424
|
|
158 |
* @run main Test4625418 IBM437
|
|
159 |
* ?run main Test4625418 IBM500
|
|
160 |
* @run main Test4625418 IBM775
|
|
161 |
* @run main Test4625418 IBM850
|
|
162 |
* @run main Test4625418 IBM852
|
|
163 |
* @run main Test4625418 IBM855
|
|
164 |
* @run main Test4625418 IBM857
|
|
165 |
* @run main Test4625418 IBM860
|
|
166 |
* @run main Test4625418 IBM861
|
|
167 |
* @run main Test4625418 IBM862
|
|
168 |
* @run main Test4625418 IBM863
|
|
169 |
* @run main Test4625418 IBM864
|
|
170 |
* @run main Test4625418 IBM865
|
|
171 |
* @run main Test4625418 IBM866
|
|
172 |
* @run main Test4625418 IBM868
|
|
173 |
* @run main Test4625418 IBM869
|
|
174 |
* ?run main Test4625418 IBM870
|
|
175 |
* ?run main Test4625418 IBM871
|
|
176 |
* ?run main Test4625418 IBM918
|
|
177 |
* ?run main Test4625418 ISCII91
|
|
178 |
* -run main Test4625418 ISO-2022-CN
|
|
179 |
* @run main Test4625418 ISO-2022-JP
|
|
180 |
* @run main Test4625418 ISO-2022-KR
|
|
181 |
* @run main Test4625418 ISO-8859-1
|
|
182 |
* @run main Test4625418 ISO-8859-13
|
|
183 |
* @run main Test4625418 ISO-8859-15
|
|
184 |
* @run main Test4625418 ISO-8859-2
|
|
185 |
* @run main Test4625418 ISO-8859-3
|
|
186 |
* @run main Test4625418 ISO-8859-4
|
|
187 |
* @run main Test4625418 ISO-8859-5
|
|
188 |
* @run main Test4625418 ISO-8859-6
|
|
189 |
* @run main Test4625418 ISO-8859-7
|
|
190 |
* @run main Test4625418 ISO-8859-8
|
|
191 |
* @run main Test4625418 ISO-8859-9
|
|
192 |
* -run main Test4625418 ISO2022CN
|
|
193 |
* @run main Test4625418 ISO2022JP
|
|
194 |
* @run main Test4625418 ISO2022KR
|
|
195 |
* -run main Test4625418 ISO2022_CN_CNS
|
|
196 |
* -run main Test4625418 ISO2022_CN_GB
|
|
197 |
* @run main Test4625418 ISO8859_1
|
|
198 |
* @run main Test4625418 ISO8859_13
|
|
199 |
* @run main Test4625418 ISO8859_15
|
|
200 |
* @run main Test4625418 ISO8859_2
|
|
201 |
* @run main Test4625418 ISO8859_3
|
|
202 |
* @run main Test4625418 ISO8859_4
|
|
203 |
* @run main Test4625418 ISO8859_5
|
|
204 |
* @run main Test4625418 ISO8859_6
|
|
205 |
* @run main Test4625418 ISO8859_7
|
|
206 |
* @run main Test4625418 ISO8859_8
|
|
207 |
* @run main Test4625418 ISO8859_9
|
|
208 |
* -run main Test4625418 JISAutoDetect
|
|
209 |
* ?run main Test4625418 JIS_X0201
|
|
210 |
* -run main Test4625418 JIS_X0212-1990
|
|
211 |
* @run main Test4625418 KOI8-R
|
|
212 |
* @run main Test4625418 KOI8-U
|
|
213 |
* @run main Test4625418 KOI8_R
|
|
214 |
* @run main Test4625418 KOI8_U
|
|
215 |
* @run main Test4625418 MS874
|
|
216 |
* ?run main Test4625418 MS932
|
|
217 |
* ?run main Test4625418 MS936
|
|
218 |
* @run main Test4625418 MS949
|
|
219 |
* @run main Test4625418 MS950
|
|
220 |
* ?run main Test4625418 MS950_HKSCS
|
|
221 |
* @run main Test4625418 MacArabic
|
|
222 |
* @run main Test4625418 MacCentralEurope
|
|
223 |
* @run main Test4625418 MacCroatian
|
|
224 |
* @run main Test4625418 MacCyrillic
|
|
225 |
* -run main Test4625418 MacDingbat
|
|
226 |
* @run main Test4625418 MacGreek
|
|
227 |
* @run main Test4625418 MacHebrew
|
|
228 |
* @run main Test4625418 MacIceland
|
|
229 |
* @run main Test4625418 MacRoman
|
|
230 |
* @run main Test4625418 MacRomania
|
|
231 |
* -run main Test4625418 MacSymbol
|
|
232 |
* @run main Test4625418 MacThai
|
|
233 |
* @run main Test4625418 MacTurkish
|
|
234 |
* @run main Test4625418 MacUkraine
|
|
235 |
* ?run main Test4625418 PCK
|
|
236 |
* ?run main Test4625418 SJIS
|
|
237 |
* ?run main Test4625418 Shift_JIS
|
|
238 |
* @run main Test4625418 TIS-620
|
|
239 |
* @run main Test4625418 TIS620
|
|
240 |
* @run main Test4625418 US-ASCII
|
|
241 |
* @run main Test4625418 UTF-16
|
|
242 |
* @run main Test4625418 UTF-16BE
|
|
243 |
* @run main Test4625418 UTF-16LE
|
|
244 |
* @run main Test4625418 UTF-32
|
|
245 |
* @run main Test4625418 UTF-32BE
|
|
246 |
* @run main Test4625418 UTF-32LE
|
|
247 |
* @run main Test4625418 UTF-8
|
|
248 |
* @run main Test4625418 UTF8
|
|
249 |
* @run main Test4625418 UTF_32
|
|
250 |
* @run main Test4625418 UTF_32BE
|
|
251 |
* -run main Test4625418 UTF_32BE_BOM
|
|
252 |
* @run main Test4625418 UTF_32LE
|
|
253 |
* -run main Test4625418 UTF_32LE_BOM
|
|
254 |
* @run main Test4625418 UnicodeBig
|
|
255 |
* @run main Test4625418 UnicodeBigUnmarked
|
|
256 |
* @run main Test4625418 UnicodeLittle
|
|
257 |
* @run main Test4625418 UnicodeLittleUnmarked
|
|
258 |
* @run main Test4625418 windows-1250
|
|
259 |
* @run main Test4625418 windows-1251
|
|
260 |
* @run main Test4625418 windows-1252
|
|
261 |
* @run main Test4625418 windows-1253
|
|
262 |
* @run main Test4625418 windows-1254
|
|
263 |
* @run main Test4625418 windows-1255
|
|
264 |
* @run main Test4625418 windows-1256
|
|
265 |
* @run main Test4625418 windows-1257
|
|
266 |
* @run main Test4625418 windows-1258
|
|
267 |
* ?run main Test4625418 windows-31j
|
|
268 |
* -run main Test4625418 x-Big5_Solaris
|
|
269 |
* ?run main Test4625418 x-EUC-TW
|
|
270 |
* @run main Test4625418 x-IBM1006
|
|
271 |
* ?run main Test4625418 x-IBM1025
|
|
272 |
* @run main Test4625418 x-IBM1046
|
|
273 |
* @run main Test4625418 x-IBM1097
|
|
274 |
* @run main Test4625418 x-IBM1098
|
|
275 |
* ?run main Test4625418 x-IBM1112
|
|
276 |
* ?run main Test4625418 x-IBM1122
|
|
277 |
* ?run main Test4625418 x-IBM1123
|
|
278 |
* @run main Test4625418 x-IBM1124
|
|
279 |
* ?run main Test4625418 x-IBM1381
|
|
280 |
* ?run main Test4625418 x-IBM1383
|
|
281 |
* ?run main Test4625418 x-IBM33722
|
|
282 |
* @run main Test4625418 x-IBM737
|
|
283 |
* -run main Test4625418 x-IBM834
|
|
284 |
* @run main Test4625418 x-IBM856
|
|
285 |
* @run main Test4625418 x-IBM874
|
|
286 |
* ?run main Test4625418 x-IBM875
|
|
287 |
* @run main Test4625418 x-IBM921
|
|
288 |
* @run main Test4625418 x-IBM922
|
|
289 |
* -run main Test4625418 x-IBM930
|
|
290 |
* @run main Test4625418 x-IBM933
|
|
291 |
* ?run main Test4625418 x-IBM935
|
|
292 |
* ?run main Test4625418 x-IBM937
|
|
293 |
* ?run main Test4625418 x-IBM939
|
|
294 |
* ?run main Test4625418 x-IBM942
|
|
295 |
* ?run main Test4625418 x-IBM942C
|
|
296 |
* @run main Test4625418 x-IBM943
|
|
297 |
* ?run main Test4625418 x-IBM943C
|
|
298 |
* @run main Test4625418 x-IBM948
|
|
299 |
* @run main Test4625418 x-IBM949
|
|
300 |
* ?run main Test4625418 x-IBM949C
|
|
301 |
* @run main Test4625418 x-IBM950
|
|
302 |
* @run main Test4625418 x-IBM964
|
|
303 |
* ?run main Test4625418 x-IBM970
|
|
304 |
* ?run main Test4625418 x-ISCII91
|
|
305 |
* -run main Test4625418 x-ISO2022-CN-CNS
|
|
306 |
* -run main Test4625418 x-ISO2022-CN-GB
|
|
307 |
* -run main Test4625418 x-JIS0208
|
|
308 |
* -run main Test4625418 x-JISAutoDetect
|
|
309 |
* @run main Test4625418 x-Johab
|
|
310 |
* ?run main Test4625418 x-MS950-HKSCS
|
|
311 |
* @run main Test4625418 x-MacArabic
|
|
312 |
* @run main Test4625418 x-MacCentralEurope
|
|
313 |
* @run main Test4625418 x-MacCroatian
|
|
314 |
* @run main Test4625418 x-MacCyrillic
|
|
315 |
* -run main Test4625418 x-MacDingbat
|
|
316 |
* @run main Test4625418 x-MacGreek
|
|
317 |
* @run main Test4625418 x-MacHebrew
|
|
318 |
* @run main Test4625418 x-MacIceland
|
|
319 |
* @run main Test4625418 x-MacRoman
|
|
320 |
* @run main Test4625418 x-MacRomania
|
|
321 |
* -run main Test4625418 x-MacSymbol
|
|
322 |
* @run main Test4625418 x-MacThai
|
|
323 |
* @run main Test4625418 x-MacTurkish
|
|
324 |
* @run main Test4625418 x-MacUkraine
|
|
325 |
* ?run main Test4625418 x-PCK
|
|
326 |
* @run main Test4625418 x-UTF-16LE-BOM
|
|
327 |
* -run main Test4625418 x-UTF-32BE-BOM
|
|
328 |
* -run main Test4625418 x-UTF-32LE-BOM
|
|
329 |
* ?run main Test4625418 x-euc-jp-linux
|
|
330 |
* ?run main Test4625418 x-eucJP-Open
|
|
331 |
* @run main Test4625418 x-iso-8859-11
|
|
332 |
* @run main Test4625418 x-mswin-936
|
|
333 |
* ?run main Test4625418 x-windows-50220
|
|
334 |
* ?run main Test4625418 x-windows-50221
|
|
335 |
* @run main Test4625418 x-windows-874
|
|
336 |
* @run main Test4625418 x-windows-949
|
|
337 |
* @run main Test4625418 x-windows-950
|
|
338 |
* ?run main Test4625418 x-windows-iso2022jp
|
|
339 |
*/
|
|
340 |
|
|
341 |
import java.beans.ExceptionListener;
|
|
342 |
import java.beans.XMLDecoder;
|
|
343 |
import java.beans.XMLEncoder;
|
|
344 |
import java.io.File;
|
|
345 |
import java.io.FileInputStream;
|
|
346 |
import java.io.FileNotFoundException;
|
|
347 |
import java.io.FileOutputStream;
|
|
348 |
import java.nio.charset.IllegalCharsetNameException;
|
|
349 |
import java.nio.charset.UnsupportedCharsetException;
|
|
350 |
|
|
351 |
public final class Test4625418 implements ExceptionListener {
|
|
352 |
public static void main(String[] args) {
|
|
353 |
new Test4625418(args[0]).test(createString(0x10000));
|
|
354 |
System.out.println("Test passed: " + args[0]);
|
|
355 |
}
|
|
356 |
|
|
357 |
private static String createString(int length) {
|
|
358 |
StringBuilder sb = new StringBuilder(length);
|
|
359 |
while (0 < length--)
|
|
360 |
sb.append((char) length);
|
|
361 |
|
|
362 |
return sb.toString();
|
|
363 |
}
|
|
364 |
|
|
365 |
private final String encoding;
|
|
366 |
|
|
367 |
private Test4625418(String encoding) {
|
|
368 |
this.encoding = encoding;
|
|
369 |
}
|
|
370 |
|
|
371 |
private void test(String string) {
|
|
372 |
try {
|
|
373 |
File file = new File("4625418." + this.encoding + ".xml");
|
|
374 |
|
|
375 |
FileOutputStream output = new FileOutputStream(file);
|
|
376 |
XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0);
|
|
377 |
encoder.setExceptionListener(this);
|
|
378 |
encoder.writeObject(string);
|
|
379 |
encoder.close();
|
|
380 |
|
|
381 |
FileInputStream input = new FileInputStream(file);
|
|
382 |
XMLDecoder decoder = new XMLDecoder(input);
|
|
383 |
decoder.setExceptionListener(this);
|
|
384 |
Object object = decoder.readObject();
|
|
385 |
decoder.close();
|
|
386 |
|
|
387 |
if (!string.equals(object))
|
|
388 |
throw new Error(this.encoding + " - can't read properly");
|
|
389 |
|
|
390 |
file.delete();
|
|
391 |
}
|
|
392 |
catch (FileNotFoundException exception) {
|
|
393 |
throw new Error(this.encoding + " - file not found", exception);
|
|
394 |
}
|
|
395 |
catch (IllegalCharsetNameException exception) {
|
|
396 |
throw new Error(this.encoding + " - illegal charset name", exception);
|
|
397 |
}
|
|
398 |
catch (UnsupportedCharsetException exception) {
|
|
399 |
throw new Error(this.encoding + " - unsupported charset", exception);
|
|
400 |
}
|
|
401 |
catch (UnsupportedOperationException exception) {
|
|
402 |
throw new Error(this.encoding + " - unsupported encoder", exception);
|
|
403 |
}
|
|
404 |
}
|
|
405 |
|
|
406 |
public void exceptionThrown(Exception exception) {
|
|
407 |
throw new Error(this.encoding + " - internal", exception);
|
|
408 |
}
|
|
409 |
}
|