Skip to content

Commit fdfbd85

Browse files
committed
Added exclude for legacy charcsets that do not support french characters (relevant on IBM JDK)
git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1720890 13f79535-47bb-0310-9956-ffa450edef68
1 parent eb162b8 commit fdfbd85

1 file changed

Lines changed: 19 additions & 6 deletions

File tree

src/test/java/org/apache/commons/io/input/CharSequenceInputStreamTest.java

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import static org.junit.Assert.assertEquals;
2121
import static org.junit.Assert.assertTrue;
2222
import static org.junit.Assert.assertFalse;
23+
import static org.junit.Assert.fail;
2324

2425
import java.io.IOException;
2526
import java.io.InputStream;
@@ -68,8 +69,8 @@ private void testBufferedRead(final String testString, final String charsetName)
6869
} else {
6970
assertTrue("Read " + read + " <= " + bufferLength, read <= bufferLength);
7071
while (read > 0) {
71-
assertTrue("offset " + offset + " < " + expected.length, offset < expected.length);
72-
assertEquals("bytes should agree", expected[offset], buffer[bufferOffset]);
72+
assertTrue("offset for " + charsetName +" " + offset + " < " + expected.length, offset < expected.length);
73+
assertEquals("bytes should agree for " + charsetName, expected[offset], buffer[bufferOffset]);
7374
offset++;
7475
bufferOffset++;
7576
read--;
@@ -426,14 +427,26 @@ public void testAvailable() throws Exception {
426427
// at org.apache.commons.io.input.CharSequenceInputStreamTest.testAvailableRead(CharSequenceInputStreamTest.java:412)
427428
// at org.apache.commons.io.input.CharSequenceInputStreamTest.testAvailable(CharSequenceInputStreamTest.java:424)
428429

429-
if (isAvailabilityTestableForCharset(csName)) {
430-
testAvailableSkip(csName);
431-
testAvailableRead(csName);
430+
try {
431+
if (isAvailabilityTestableForCharset(csName)) {
432+
testAvailableSkip(csName);
433+
testAvailableRead(csName);
434+
}
435+
} catch (UnsupportedOperationException e){
436+
fail("Operation not supported for " + csName);
432437
}
433438
}
434439
}
435440

436441
private boolean isAvailabilityTestableForCharset(final String csName) {
437-
return Charset.forName(csName).canEncode() && ! "COMPOUND_TEXT".equalsIgnoreCase(csName) && ! "x-COMPOUND_TEXT".equalsIgnoreCase(csName);
442+
return Charset.forName(csName).canEncode()
443+
&& !"COMPOUND_TEXT".equalsIgnoreCase(csName) && !"x-COMPOUND_TEXT".equalsIgnoreCase(csName)
444+
&& !isOddBallLegacyCharsetThatDoesNotSupportFrenchCharacters(csName);
445+
}
446+
447+
private boolean isOddBallLegacyCharsetThatDoesNotSupportFrenchCharacters(String csName) {
448+
return "x-IBM1388".equalsIgnoreCase(csName) ||
449+
"ISO-2022-CN".equalsIgnoreCase(csName) ||
450+
"ISO-2022-JP".equalsIgnoreCase(csName);
438451
}
439452
}

0 commit comments

Comments
 (0)