Skip to content

Commit d89939d

Browse files
committed
[CODEC-73] In-line comments on odd test results with some charsets on different JREs.
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/codec/trunk@801396 13f79535-47bb-0310-9956-ffa450edef68
1 parent b3607d8 commit d89939d

1 file changed

Lines changed: 42 additions & 7 deletions

File tree

src/test/org/apache/commons/codec/binary/HexTest.java

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
*/
4040
public class HexTest extends TestCase {
4141

42-
private final static boolean LOG = false;
42+
private final static boolean LOG = true;
4343

4444
public HexTest(String name) {
4545
super(name);
@@ -60,6 +60,14 @@ private void checkDecodeHexOddCharacters(char[] data) {
6060
private void log(String s) {
6161
if (LOG) {
6262
System.out.println(s);
63+
System.out.flush();
64+
}
65+
}
66+
67+
private void log(Throwable t) {
68+
if (LOG) {
69+
t.printStackTrace(System.out);
70+
System.out.flush();
6371
}
6472
}
6573

@@ -83,7 +91,6 @@ public void testCustomCharset() throws UnsupportedEncodingException, DecoderExce
8391
*/
8492
private void testCustomCharset(String name, String parent) throws UnsupportedEncodingException, DecoderException {
8593
if (charsetSanityCheck(name) == false) {
86-
log("Interesting Java charset oddity: Charset sanity check failed for " + name);
8794
return;
8895
}
8996
log(parent + "=" + name);
@@ -121,18 +128,46 @@ private boolean charsetSanityCheck(String name) {
121128
try {
122129
byte[] bytes = source.getBytes(name);
123130
String str = new String(bytes, name);
124-
return source.equals(str);
131+
boolean equals = source.equals(str);
132+
if (equals == false) {
133+
// Here with:
134+
//
135+
// Java Sun 1.4.2_19 x86 32-bits on Windows XP
136+
// JIS_X0212-1990
137+
// x-JIS0208
138+
//
139+
// Java Sun 1.5.0_17 x86 32-bits on Windows XP
140+
// JIS_X0212-1990
141+
// x-IBM834
142+
// x-JIS0208
143+
// x-MacDingbat
144+
// x-MacSymbol
145+
//
146+
// Java Sun 1.6.0_14 x86 32-bits
147+
// JIS_X0212-1990
148+
// x-IBM834
149+
// x-JIS0208
150+
// x-MacDingbat
151+
// x-MacSymbol
152+
//
153+
log("FAILED charsetSanityCheck=Interesting Java charset oddity: Roundtrip failed for " + name);
154+
}
155+
return equals;
125156
} catch (UnsupportedEncodingException e) {
126157
// Should NEVER happen since we are getting the name from the Charset class.
127158
if (LOG) {
128-
e.printStackTrace();
159+
log("FAILED charsetSanityCheck=" + name + ", e=" + e);
160+
log(e);
129161
}
130162
return false;
131163
} catch (UnsupportedOperationException e) {
132-
// Happens with:
133-
// x-JIS0208 on Windows XP and Java Sun 1.6.0_14
164+
// Caught here with:
165+
// x-JISAutoDetect on Windows XP and Java Sun 1.4.2_19 x86 32-bits
166+
// x-JISAutoDetect on Windows XP and Java Sun 1.5.0_17 x86 32-bits
167+
// x-JISAutoDetect on Windows XP and Java Sun 1.6.0_14 x86 32-bits
134168
if (LOG) {
135-
e.printStackTrace();
169+
log("FAILED charsetSanityCheck=" + name + ", e=" + e);
170+
log(e);
136171
}
137172
return false;
138173
}

0 commit comments

Comments
 (0)