Test that ebcidic encoding is supported (making sure "%Uxxxx" replacement strings don't use ascii encodings)
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.charset.Charset;
-import org.apache.commons.compress.utils.CharsetNames;
import org.hamcrest.core.IsInstanceOf;
import org.junit.Assert;
import org.junit.Test;
@@ -78,6 +77,13 @@ public void testSimpleCp850Encoding() throws IOException {
}
+ @Test
+ public void testEbcidic() throws IOException {
+
+ doSimpleEncodingTest("IBM1047", null);
+ }
+
+
private void doSimpleEncodingsTest(int n) throws IOException {
doSimpleEncodingTest("Cp" + n, null);
@@ -178,11 +184,10 @@ private void doSimpleEncodingTest(final String name, byte[] testBytes)
assertEquals(testBytes, encoded);
assertFalse(enc.canEncode(UNENC_STRING));
- assertEquals("%U2016".getBytes(CharsetNames.US_ASCII), enc.encode(UNENC_STRING));
+ assertEquals("%U2016".getBytes(name), enc.encode(UNENC_STRING));
assertFalse(enc.canEncode(BAD_STRING));
- byte[] expected = BAD_STRING_ENC.getBytes(CharsetNames.US_ASCII);
- ByteBuffer actual = enc.encode(BAD_STRING);
- assertEquals(expected, actual);
+ assertEquals(BAD_STRING_ENC.getBytes(name), enc.encode(BAD_STRING));
+ assertEquals(BAD_STRING_ENC.getBytes(name), enc.encode(BAD_STRING));
}
}
