Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mobile
Path: blob/master/test/jdk/java/beans/XMLEncoder/Test4625418.java
41152 views
1
/*
2
* Copyright (c) 2006, 2020, Oracle and/or its affiliates. All rights reserved.
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
*
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.
22
*/
23
24
/*
25
* @test
26
* @bug 4625418 8239965
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
* @run main/timeout=360 Test4625418
30
*/
31
32
import java.beans.ExceptionListener;
33
import java.beans.XMLDecoder;
34
import java.beans.XMLEncoder;
35
import java.io.ByteArrayInputStream;
36
import java.io.ByteArrayOutputStream;
37
import java.io.InputStream;
38
import java.nio.charset.IllegalCharsetNameException;
39
import java.nio.charset.UnsupportedCharsetException;
40
41
public final class Test4625418 implements ExceptionListener {
42
43
private static final String[] encodings = {
44
"ASCII",
45
"Big5",
46
//"Big5-HKSCS",
47
//"Big5_HKSCS",
48
"Big5_Solaris",
49
//"Cp037",
50
"Cp1006",
51
//"Cp1025",
52
//"Cp1026",
53
"Cp1046",
54
"Cp1047",
55
"Cp1097",
56
"Cp1098",
57
//"Cp1112",
58
//"Cp1122",
59
//"Cp1123",
60
"Cp1124",
61
//"Cp1140",
62
//"Cp1141",
63
//"Cp1142",
64
//"Cp1143",
65
//"Cp1144",
66
//"Cp1145",
67
//"Cp1146",
68
//"Cp1147",
69
//"Cp1148",
70
//"Cp1149",
71
"Cp1250",
72
"Cp1251",
73
"Cp1252",
74
"Cp1253",
75
"Cp1254",
76
"Cp1255",
77
"Cp1256",
78
"Cp1257",
79
"Cp1258",
80
//"Cp1381",
81
//"Cp1383",
82
//"Cp273",
83
//"Cp277",
84
//"Cp278",
85
//"Cp280",
86
//"Cp284",
87
//"Cp285",
88
//"Cp297",
89
//"Cp33722",
90
//"Cp420",
91
//"Cp424",
92
"Cp437",
93
//"Cp500",
94
//"Cp50220",
95
//"Cp50221",
96
"Cp737",
97
"Cp775",
98
//"Cp834",
99
//"Cp838",
100
"Cp850",
101
"Cp852",
102
"Cp855",
103
"Cp856",
104
"Cp857",
105
"Cp858",
106
"Cp860",
107
"Cp861",
108
"Cp862",
109
"Cp863",
110
"Cp864",
111
"Cp865",
112
"Cp866",
113
"Cp868",
114
"Cp869",
115
//"Cp870",
116
//"Cp871",
117
"Cp874",
118
//"Cp875",
119
//"Cp918",
120
"Cp921",
121
"Cp922",
122
//"Cp930",
123
"Cp933",
124
//"Cp935",
125
//"Cp937",
126
//"Cp939",
127
//"Cp942",
128
//"Cp942C",
129
//"Cp943",
130
//"Cp943C",
131
"Cp948",
132
"Cp949",
133
//"Cp949C",
134
"Cp950",
135
"Cp964",
136
//"Cp970",
137
//"EUC-JP",
138
"EUC-KR",
139
"EUC_CN",
140
//"EUC_JP",
141
//"EUC_JP_LINUX",
142
//"EUC_JP_Solaris",
143
"EUC_KR",
144
//"EUC_TW",
145
"GB18030",
146
"GB2312",
147
"GBK",
148
//"IBM-Thai",
149
"IBM00858",
150
//"IBM01140",
151
//"IBM01141",
152
//"IBM01142",
153
//"IBM01143",
154
//"IBM01144",
155
//"IBM01145",
156
//"IBM01146",
157
//"IBM01147",
158
//"IBM01148",
159
//"IBM01149",
160
//"IBM037",
161
//"IBM1026",
162
"IBM1047",
163
//"IBM273",
164
//"IBM277",
165
//"IBM278",
166
//"IBM280",
167
//"IBM284",
168
//"IBM285",
169
//"IBM297",
170
//"IBM420",
171
//"IBM424",
172
"IBM437",
173
//"IBM500",
174
"IBM775",
175
"IBM850",
176
"IBM852",
177
"IBM855",
178
"IBM857",
179
"IBM860",
180
"IBM861",
181
"IBM862",
182
"IBM863",
183
"IBM864",
184
"IBM865",
185
"IBM866",
186
"IBM868",
187
"IBM869",
188
//"IBM870",
189
//"IBM871",
190
//"IBM918",
191
//"ISCII91",
192
//"ISO-2022-CN",
193
"ISO-2022-JP",
194
"ISO-2022-KR",
195
"ISO-8859-1",
196
"ISO-8859-13",
197
"ISO-8859-15",
198
"ISO-8859-2",
199
"ISO-8859-3",
200
"ISO-8859-4",
201
"ISO-8859-5",
202
"ISO-8859-6",
203
"ISO-8859-7",
204
"ISO-8859-8",
205
"ISO-8859-9",
206
//"ISO2022CN",
207
"ISO2022JP",
208
"ISO2022KR",
209
//"ISO2022_CN_CNS",
210
//"ISO2022_CN_GB",
211
"ISO8859_1",
212
"ISO8859_13",
213
"ISO8859_15",
214
"ISO8859_2",
215
"ISO8859_3",
216
"ISO8859_4",
217
"ISO8859_5",
218
"ISO8859_6",
219
"ISO8859_7",
220
"ISO8859_8",
221
"ISO8859_9",
222
//"JISAutoDetect",
223
//"JIS_X0201",
224
//"JIS_X0212-1990",
225
"KOI8-R",
226
"KOI8-U",
227
"KOI8_R",
228
"KOI8_U",
229
"MS874",
230
//"MS932",
231
//"MS936",
232
"MS949",
233
"MS950",
234
//"MS950_HKSCS",
235
"MacArabic",
236
"MacCentralEurope",
237
"MacCroatian",
238
"MacCyrillic",
239
//"MacDingbat",
240
"MacGreek",
241
"MacHebrew",
242
"MacIceland",
243
"MacRoman",
244
"MacRomania",
245
//"MacSymbol",
246
"MacThai",
247
"MacTurkish",
248
"MacUkraine",
249
//"PCK",
250
//"SJIS",
251
//"Shift_JIS",
252
"TIS-620",
253
"TIS620",
254
"US-ASCII",
255
"UTF-16",
256
"UTF-16BE",
257
"UTF-16LE",
258
"UTF-32",
259
"UTF-32BE",
260
"UTF-32LE",
261
"UTF-8",
262
"UTF8",
263
"UTF_32",
264
"UTF_32BE",
265
//"UTF_32BE_BOM",
266
"UTF_32LE",
267
//"UTF_32LE_BOM",
268
"UnicodeBig",
269
"UnicodeBigUnmarked",
270
"UnicodeLittle",
271
"UnicodeLittleUnmarked",
272
"windows-1250",
273
"windows-1251",
274
"windows-1252",
275
"windows-1253",
276
"windows-1254",
277
"windows-1255",
278
"windows-1256",
279
"windows-1257",
280
"windows-1258",
281
//"windows-31j",
282
//"x-Big5_Solaris",
283
//"x-EUC-TW",
284
"x-IBM1006",
285
//"x-IBM1025",
286
"x-IBM1046",
287
"x-IBM1097",
288
"x-IBM1098",
289
//"x-IBM1112",
290
//"x-IBM1122",
291
//"x-IBM1123",
292
"x-IBM1124",
293
//"x-IBM1381",
294
//"x-IBM1383",
295
//"x-IBM33722",
296
"x-IBM737",
297
//"x-IBM834",
298
"x-IBM856",
299
"x-IBM874",
300
//"x-IBM875",
301
"x-IBM921",
302
"x-IBM922",
303
//"x-IBM930",
304
"x-IBM933",
305
//"x-IBM935",
306
//"x-IBM937",
307
//"x-IBM939",
308
//"x-IBM942",
309
//"x-IBM942C",
310
//"x-IBM943",
311
//"x-IBM943C",
312
"x-IBM948",
313
"x-IBM949",
314
//"x-IBM949C",
315
"x-IBM950",
316
"x-IBM964",
317
//"x-IBM970",
318
//"x-ISCII91",
319
//"x-ISO2022-CN-CNS",
320
//"x-ISO2022-CN-GB",
321
//"x-JIS0208",
322
//"x-JISAutoDetect",
323
"x-Johab",
324
//"x-MS950-HKSCS",
325
"x-MacArabic",
326
"x-MacCentralEurope",
327
"x-MacCroatian",
328
"x-MacCyrillic",
329
//"x-MacDingbat",
330
"x-MacGreek",
331
"x-MacHebrew",
332
"x-MacIceland",
333
"x-MacRoman",
334
"x-MacRomania",
335
//"x-MacSymbol",
336
"x-MacThai",
337
"x-MacTurkish",
338
"x-MacUkraine",
339
//"x-PCK",
340
"x-UTF-16LE-BOM",
341
//"x-UTF-32BE-BOM",
342
//"x-UTF-32LE-BOM",
343
//"x-euc-jp-linux",
344
//"x-eucJP-Open",
345
"x-iso-8859-11",
346
"x-mswin-936",
347
//"x-windows-50220",
348
//"x-windows-50221",
349
"x-windows-874",
350
"x-windows-949",
351
"x-windows-950",
352
//"x-windows-iso2022jp",
353
};
354
355
public static void main(final String[] args) {
356
final String string = createString(0x10000);
357
for (String encoding : encodings) {
358
System.out.println("Test encoding: " + encoding);
359
new Test4625418(encoding).test(string);
360
}
361
}
362
363
private static String createString(int length) {
364
StringBuilder sb = new StringBuilder(length);
365
while (0 < length--)
366
sb.append((char) length);
367
368
return sb.toString();
369
}
370
371
private final String encoding;
372
373
private Test4625418(final String encoding) {
374
this.encoding = encoding;
375
}
376
377
private void test(String string) {
378
try {
379
ByteArrayOutputStream output = new ByteArrayOutputStream();
380
XMLEncoder encoder = new XMLEncoder(output, this.encoding, true, 0);
381
encoder.setExceptionListener(this);
382
encoder.writeObject(string);
383
encoder.close();
384
385
InputStream input = new ByteArrayInputStream(output.toByteArray());
386
XMLDecoder decoder = new XMLDecoder(input);
387
decoder.setExceptionListener(this);
388
Object object = decoder.readObject();
389
decoder.close();
390
391
if (!string.equals(object)) {
392
throw new Error(this.encoding + " - can't read properly");
393
}
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
}
410
411