|
20 | 20 | import static org.junit.Assert.assertEquals; |
21 | 21 | import static org.junit.Assert.assertTrue; |
22 | 22 | import static org.junit.Assert.assertFalse; |
| 23 | +import static org.junit.Assert.fail; |
23 | 24 |
|
24 | 25 | import java.io.IOException; |
25 | 26 | import java.io.InputStream; |
@@ -68,8 +69,8 @@ private void testBufferedRead(final String testString, final String charsetName) |
68 | 69 | } else { |
69 | 70 | assertTrue("Read " + read + " <= " + bufferLength, read <= bufferLength); |
70 | 71 | 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]); |
73 | 74 | offset++; |
74 | 75 | bufferOffset++; |
75 | 76 | read--; |
@@ -426,14 +427,26 @@ public void testAvailable() throws Exception { |
426 | 427 | // at org.apache.commons.io.input.CharSequenceInputStreamTest.testAvailableRead(CharSequenceInputStreamTest.java:412) |
427 | 428 | // at org.apache.commons.io.input.CharSequenceInputStreamTest.testAvailable(CharSequenceInputStreamTest.java:424) |
428 | 429 |
|
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); |
432 | 437 | } |
433 | 438 | } |
434 | 439 | } |
435 | 440 |
|
436 | 441 | 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); |
438 | 451 | } |
439 | 452 | } |
0 commit comments