You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2011/08/25 02:35:32 UTC
svn commit: r1161343 [2/2] - in /commons/proper/codec/branches/generics/src:
java/org/apache/commons/codec/language/bm/
java/org/apache/commons/codec/net/ test/org/apache/commons/codec/binary/
test/org/apache/commons/codec/net/
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/BinaryCharCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/BinaryCharCodecTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/BinaryCharCodecTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/BinaryCharCodecTest.java Thu Aug 25 00:35:31 2011
@@ -157,7 +157,7 @@ public class BinaryCharCodecTest {
*/
void assertDecodeObject(byte[] bits, String encodeMe) throws DecoderException, UnsupportedEncodingException {
byte[] decoded;
- decoded = (byte[]) instance.decode(encodeMe);
+ decoded = instance.decode(encodeMe);
assertEquals(new String(bits), new String(decoded));
if (encodeMe == null) {
decoded = instance.decode((byte[]) null);
@@ -365,90 +365,90 @@ public class BinaryCharCodecTest {
*/
@Test
public void testFromAsciiCharArray() {
- assertEquals(0, BinaryCharCodec.fromAscii((char[]) null).length);
- assertEquals(0, BinaryCharCodec.fromAscii(new char[0]).length);
+ assertEquals(0, BinaryCodec.fromAscii((char[]) null).length);
+ assertEquals(0, BinaryCodec.fromAscii(new char[0]).length);
// With a single raw binary
byte[] bits = new byte[1];
- byte[] decoded = BinaryCharCodec.fromAscii("00000000".toCharArray());
+ byte[] decoded = BinaryCodec.fromAscii("00000000".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0;
- decoded = BinaryCharCodec.fromAscii("00000001".toCharArray());
+ decoded = BinaryCodec.fromAscii("00000001".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1;
- decoded = BinaryCharCodec.fromAscii("00000011".toCharArray());
+ decoded = BinaryCodec.fromAscii("00000011".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- decoded = BinaryCharCodec.fromAscii("00000111".toCharArray());
+ decoded = BinaryCodec.fromAscii("00000111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- decoded = BinaryCharCodec.fromAscii("00001111".toCharArray());
+ decoded = BinaryCodec.fromAscii("00001111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- decoded = BinaryCharCodec.fromAscii("00011111".toCharArray());
+ decoded = BinaryCodec.fromAscii("00011111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- decoded = BinaryCharCodec.fromAscii("00111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("00111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- decoded = BinaryCharCodec.fromAscii("01111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("01111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("11111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("11111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
// With a two raw binaries
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000000011111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0000000011111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000000111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0000000111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000001111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0000001111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000011111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0000011111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000111111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0000111111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0001111111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0001111111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0011111111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0011111111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0111111111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("0111111111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("1111111111111111".toCharArray());
+ decoded = BinaryCodec.fromAscii("1111111111111111".toCharArray());
assertEquals(new String(bits), new String(decoded));
- assertEquals(0, BinaryCharCodec.fromAscii((char[]) null).length);
+ assertEquals(0, BinaryCodec.fromAscii((char[]) null).length);
}
// ------------------------------------------------------------------------
@@ -461,90 +461,90 @@ public class BinaryCharCodecTest {
*/
@Test
public void testFromAsciiByteArray() throws UnsupportedEncodingException {
- assertEquals(0, BinaryCharCodec.fromAscii((byte[]) null).length);
- assertEquals(0, BinaryCharCodec.fromAscii(new byte[0]).length);
+ assertEquals(0, BinaryCodec.fromAscii((byte[]) null).length);
+ assertEquals(0, BinaryCodec.fromAscii(new byte[0]).length);
// With a single raw binary
byte[] bits = new byte[1];
- byte[] decoded = BinaryCharCodec.fromAscii("00000000".getBytes("UTF-8"));
+ byte[] decoded = BinaryCodec.fromAscii("00000000".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0;
- decoded = BinaryCharCodec.fromAscii("00000001".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("00000001".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1;
- decoded = BinaryCharCodec.fromAscii("00000011".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("00000011".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- decoded = BinaryCharCodec.fromAscii("00000111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("00000111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- decoded = BinaryCharCodec.fromAscii("00001111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("00001111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- decoded = BinaryCharCodec.fromAscii("00011111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("00011111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- decoded = BinaryCharCodec.fromAscii("00111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("00111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- decoded = BinaryCharCodec.fromAscii("01111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("01111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[1];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("11111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("11111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
// With a two raw binaries
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000000011111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0000000011111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000000111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0000000111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000001111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0000001111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000011111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0000011111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0000111111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0000111111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0001111111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0001111111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0011111111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0011111111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("0111111111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("0111111111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
bits = new byte[2];
bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- decoded = BinaryCharCodec.fromAscii("1111111111111111".getBytes("UTF-8"));
+ decoded = BinaryCodec.fromAscii("1111111111111111".getBytes("UTF-8"));
assertEquals(new String(bits), new String(decoded));
- assertEquals(0, BinaryCharCodec.fromAscii((byte[]) null).length);
+ assertEquals(0, BinaryCodec.fromAscii((byte[]) null).length);
}
// ------------------------------------------------------------------------
@@ -682,118 +682,118 @@ public class BinaryCharCodecTest {
public void testToAsciiBytes() {
// With a single raw binary
byte[] bits = new byte[1];
- String l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ String l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("00000000", l_encoded);
bits = new byte[1];
bits[0] = BIT_0;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("00000001", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("00000011", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("00000111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("00001111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("00011111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("00111111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("01111111", l_encoded);
bits = new byte[1];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("11111111", l_encoded);
// With a two raw binaries
bits = new byte[2];
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000000000000", l_encoded);
bits = new byte[2];
bits[0] = BIT_0;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000000000001", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000000000011", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000000000111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000000001111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000000011111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000000111111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000001111111", l_encoded);
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000011111111", l_encoded);
// work on the other byte now
bits = new byte[2];
bits[1] = BIT_0;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000000111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000001111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000011111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0000111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0001111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0011111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("0111111111111111", l_encoded);
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiBytes(bits));
+ l_encoded = new String(BinaryCodec.toAsciiBytes(bits));
assertEquals("1111111111111111", l_encoded);
- assertEquals(0, BinaryCharCodec.toAsciiBytes((byte[]) null).length);
+ assertEquals(0, BinaryCodec.toAsciiBytes((byte[]) null).length);
}
// ------------------------------------------------------------------------
@@ -805,118 +805,118 @@ public class BinaryCharCodecTest {
public void testToAsciiChars() {
// With a single raw binary
byte[] bits = new byte[1];
- String l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ String l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("00000000", l_encoded);
bits = new byte[1];
bits[0] = BIT_0;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("00000001", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("00000011", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("00000111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("00001111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("00011111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("00111111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("01111111", l_encoded);
bits = new byte[1];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("11111111", l_encoded);
// With a two raw binaries
bits = new byte[2];
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000000000000", l_encoded);
bits = new byte[2];
bits[0] = BIT_0;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000000000001", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000000000011", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000000000111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000000001111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000000011111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000000111111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000001111111", l_encoded);
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000011111111", l_encoded);
// work on the other byte now
bits = new byte[2];
bits[1] = BIT_0;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000000111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000001111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000011111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0000111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0001111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0011111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("0111111111111111", l_encoded);
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = new String(BinaryCharCodec.toAsciiChars(bits));
+ l_encoded = new String(BinaryCodec.toAsciiChars(bits));
assertEquals("1111111111111111", l_encoded);
- assertEquals(0, BinaryCharCodec.toAsciiChars((byte[]) null).length);
+ assertEquals(0, BinaryCodec.toAsciiChars((byte[]) null).length);
}
// ------------------------------------------------------------------------
@@ -931,116 +931,116 @@ public class BinaryCharCodecTest {
public void testToAsciiString() {
// With a single raw binary
byte[] bits = new byte[1];
- String l_encoded = BinaryCharCodec.toAsciiString(bits);
+ String l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("00000000", l_encoded);
bits = new byte[1];
bits[0] = BIT_0;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("00000001", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("00000011", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("00000111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("00001111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("00011111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("00111111", l_encoded);
bits = new byte[1];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("01111111", l_encoded);
bits = new byte[1];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("11111111", l_encoded);
// With a two raw binaries
bits = new byte[2];
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000000000000", l_encoded);
bits = new byte[2];
bits[0] = BIT_0;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000000000001", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000000000011", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000000000111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000000001111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000000011111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000000111111", l_encoded);
bits = new byte[2];
bits[0] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000001111111", l_encoded);
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000011111111", l_encoded);
// work on the other byte now
bits = new byte[2];
bits[1] = BIT_0;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000000111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000001111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000011111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0000111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0001111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0011111111111111", l_encoded);
bits = new byte[2];
bits[1] = BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6;
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("0111111111111111", l_encoded);
bits = new byte[2];
bits[0] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
bits[1] = (byte) (BIT_0 | BIT_1 | BIT_2 | BIT_3 | BIT_4 | BIT_5 | BIT_6 | BIT_7);
- l_encoded = BinaryCharCodec.toAsciiString(bits);
+ l_encoded = BinaryCodec.toAsciiString(bits);
assertEquals("1111111111111111", l_encoded);
}
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexByteTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexByteTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexByteTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexByteTest.java Thu Aug 25 00:35:31 2011
@@ -100,7 +100,7 @@ public class HexByteTest {
*/
private void checkDecodeHexOddCharacters(char[] data) {
try {
- HexByteCodec.decodeHex(data);
+ Hex.decodeHex(data);
fail("An exception wasn't thrown when trying to decode an odd number of characters");
} catch (DecoderException e) {
// Expected exception
@@ -148,7 +148,7 @@ public class HexByteTest {
// encode source to hex string to bytes with charset
byte[] actualEncodedBytes = customCodec.encode(sourceBytes);
// encode source to hex string...
- String expectedHexString = HexByteCodec.encodeHexString(sourceBytes);
+ String expectedHexString = Hex.encodeHexString(sourceBytes);
// ... and get the bytes in the expected charset
byte[] expectedHexStringBytes = expectedHexString.getBytes(name);
Assert.assertTrue(Arrays.equals(expectedHexStringBytes, actualEncodedBytes));
@@ -159,7 +159,7 @@ public class HexByteTest {
// second test:
HexByteCodec utf8Codec = new HexByteCodec();
expectedHexString = "48656c6c6f20576f726c64";
- byte[] decodedUtf8Bytes = (byte[]) utf8Codec.decode(expectedHexString);
+ byte[] decodedUtf8Bytes = utf8Codec.decode(expectedHexString);
actualStringFromBytes = new String(decodedUtf8Bytes, utf8Codec.getCharsetName());
// sanity check:
assertEquals(name, sourceString, actualStringFromBytes);
@@ -201,7 +201,7 @@ public class HexByteTest {
@Test
public void testCustomCharsetToString() {
- assertTrue(new HexByteCodec().toString().indexOf(HexByteCodec.DEFAULT_CHARSET_NAME) >= 0);
+ assertTrue(new HexByteCodec().toString().indexOf(Hex.DEFAULT_CHARSET_NAME) >= 0);
}
@Test
@@ -261,9 +261,9 @@ public class HexByteTest {
@Test
public void testDencodeEmpty() throws DecoderException {
- assertTrue(Arrays.equals(new byte[0], HexByteCodec.decodeHex(new char[0])));
+ assertTrue(Arrays.equals(new byte[0], Hex.decodeHex(new char[0])));
assertTrue(Arrays.equals(new byte[0], new HexByteCodec().decode(new byte[0])));
- assertTrue(Arrays.equals(new byte[0], (byte[]) new HexByteCodec().decode("")));
+ assertTrue(Arrays.equals(new byte[0], new HexByteCodec().decode("")));
}
@Test
@@ -276,8 +276,8 @@ public class HexByteTest {
random.nextBytes(data);
// static API
- char[] encodedChars = HexByteCodec.encodeHex(data);
- byte[] decodedBytes = HexByteCodec.decodeHex(encodedChars);
+ char[] encodedChars = Hex.encodeHex(data);
+ byte[] decodedBytes = Hex.decodeHex(encodedChars);
assertTrue(Arrays.equals(data, decodedBytes));
// instance API with array parameter
@@ -287,28 +287,28 @@ public class HexByteTest {
// instance API with char[] (Object) parameter
String dataString = new String(encodedChars);
- char[] encodedStringChars = (char[]) hex.encode(dataString);
- decodedBytes = (byte[]) hex.decode(encodedStringChars);
+ char[] encodedStringChars = hex.encode(dataString);
+ decodedBytes = hex.decode(encodedStringChars);
assertTrue(Arrays.equals(StringUtils.getBytesUtf8(dataString), decodedBytes));
// instance API with String (Object) parameter
dataString = new String(encodedChars);
- encodedStringChars = (char[]) hex.encode(dataString);
- decodedBytes = (byte[]) hex.decode(new String(encodedStringChars));
+ encodedStringChars = hex.encode(dataString);
+ decodedBytes = hex.decode(new String(encodedStringChars));
assertTrue(Arrays.equals(StringUtils.getBytesUtf8(dataString), decodedBytes));
}
}
@Test
public void testEncodeEmpty() throws EncoderException {
- assertTrue(Arrays.equals(new char[0], HexByteCodec.encodeHex(new byte[0])));
+ assertTrue(Arrays.equals(new char[0], Hex.encodeHex(new byte[0])));
assertTrue(Arrays.equals(new byte[0], new HexByteCodec().encode(new byte[0])));
- assertTrue(Arrays.equals(new char[0], (char[]) new HexByteCodec().encode("")));
+ assertTrue(Arrays.equals(new char[0], new HexByteCodec().encode("")));
}
@Test
public void testEncodeZeroes() {
- char[] c = HexByteCodec.encodeHex(new byte[36]);
+ char[] c = Hex.encodeHex(new byte[36]);
assertEquals("000000000000000000000000000000000000000000000000000000000000000000000000", new String(c));
}
@@ -317,11 +317,11 @@ public class HexByteTest {
byte[] b = StringUtils.getBytesUtf8("Hello World");
final String expected = "48656c6c6f20576f726c64";
char[] actual;
- actual = HexByteCodec.encodeHex(b);
+ actual = Hex.encodeHex(b);
assertTrue(expected.equals(new String(actual)));
- actual = HexByteCodec.encodeHex(b, true);
+ actual = Hex.encodeHex(b, true);
assertTrue(expected.equals(new String(actual)));
- actual = HexByteCodec.encodeHex(b, false);
+ actual = Hex.encodeHex(b, false);
assertFalse(expected.equals(new String(actual)));
}
@@ -330,11 +330,11 @@ public class HexByteTest {
byte[] b = StringUtils.getBytesUtf8("Hello World");
final String expected = "48656C6C6F20576F726C64";
char[] actual;
- actual = HexByteCodec.encodeHex(b);
+ actual = Hex.encodeHex(b);
assertFalse(expected.equals(new String(actual)));
- actual = HexByteCodec.encodeHex(b, true);
+ actual = Hex.encodeHex(b, true);
assertFalse(expected.equals(new String(actual)));
- actual = HexByteCodec.encodeHex(b, false);
+ actual = Hex.encodeHex(b, false);
assertTrue(expected.equals(new String(actual)));
}
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexCharTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexCharTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexCharTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/binary/HexCharTest.java Thu Aug 25 00:35:31 2011
@@ -99,7 +99,7 @@ public class HexCharTest {
*/
private void checkDecodeHexOddCharacters(char[] data) {
try {
- HexCharCodec.decodeHex(data);
+ Hex.decodeHex(data);
fail("An exception wasn't thrown when trying to decode an odd number of characters");
} catch (DecoderException e) {
// Expected exception
@@ -149,7 +149,7 @@ public class HexCharTest {
// encode source to hex string to bytes with charset
char[] actualEncodedChars = customCodec.encode(sourceString);
// encode source to hex string...
- String expectedHexString = HexCharCodec.encodeHexString(sourceBytes);
+ String expectedHexString = Hex.encodeHexString(sourceBytes);
// ... and get the bytes in the expected charset
char[] expectedHexStringChars = expectedHexString.toCharArray();
assertArrayEquals(expectedHexStringChars, actualEncodedChars);
@@ -198,7 +198,7 @@ public class HexCharTest {
@Test
public void testCustomCharsetToString() {
- assertTrue(new HexCharCodec().toString().indexOf(HexCharCodec.DEFAULT_CHARSET_NAME) >= 0);
+ assertTrue(new HexCharCodec().toString().indexOf(Hex.DEFAULT_CHARSET_NAME) >= 0);
}
@Test
@@ -258,9 +258,9 @@ public class HexCharTest {
@Test
public void testDencodeEmpty() throws DecoderException {
- assertTrue(Arrays.equals(new byte[0], HexCharCodec.decodeHex(new char[0])));
+ assertTrue(Arrays.equals(new byte[0], Hex.decodeHex(new char[0])));
assertTrue(Arrays.equals(new byte[0], new HexCharCodec().decode(new byte[0])));
- assertTrue(Arrays.equals(new byte[0], (byte[]) new HexCharCodec().decode("")));
+ assertTrue(Arrays.equals(new byte[0], new HexCharCodec().decode("")));
}
@Test
@@ -273,8 +273,8 @@ public class HexCharTest {
random.nextBytes(data);
// static API
- char[] encodedChars = HexCharCodec.encodeHex(data);
- byte[] decodedBytes = HexCharCodec.decodeHex(encodedChars);
+ char[] encodedChars = Hex.encodeHex(data);
+ byte[] decodedBytes = Hex.decodeHex(encodedChars);
assertTrue(Arrays.equals(data, decodedBytes));
// instance API with array parameter
@@ -284,28 +284,28 @@ public class HexCharTest {
// instance API with char[] (Object) parameter
String dataString = new String(encodedChars);
- char[] encodedStringChars = (char[]) hex.encode(dataString);
- decodedBytes = (byte[]) hex.decode(encodedStringChars);
+ char[] encodedStringChars = hex.encode(dataString);
+ decodedBytes = hex.decode(encodedStringChars);
assertTrue(Arrays.equals(StringUtils.getBytesUtf8(dataString), decodedBytes));
// instance API with String (Object) parameter
dataString = new String(encodedChars);
- encodedStringChars = (char[]) hex.encode(dataString);
- decodedBytes = (byte[]) hex.decode(new String(encodedStringChars));
+ encodedStringChars = hex.encode(dataString);
+ decodedBytes = hex.decode(new String(encodedStringChars));
assertTrue(Arrays.equals(StringUtils.getBytesUtf8(dataString), decodedBytes));
}
}
@Test
public void testEncodeEmpty() throws EncoderException {
- assertTrue(Arrays.equals(new char[0], HexCharCodec.encodeHex(new byte[0])));
+ assertTrue(Arrays.equals(new char[0], Hex.encodeHex(new byte[0])));
assertTrue(Arrays.equals(new char[0], new HexCharCodec().encode(new byte[0])));
- assertTrue(Arrays.equals(new char[0], (char[]) new HexCharCodec().encode("")));
+ assertTrue(Arrays.equals(new char[0], new HexCharCodec().encode("")));
}
@Test
public void testEncodeZeroes() {
- char[] c = HexCharCodec.encodeHex(new byte[36]);
+ char[] c = Hex.encodeHex(new byte[36]);
assertEquals("000000000000000000000000000000000000000000000000000000000000000000000000", new String(c));
}
@@ -314,11 +314,11 @@ public class HexCharTest {
byte[] b = StringUtils.getBytesUtf8("Hello World");
final String expected = "48656c6c6f20576f726c64";
char[] actual;
- actual = HexCharCodec.encodeHex(b);
+ actual = Hex.encodeHex(b);
assertTrue(expected.equals(new String(actual)));
- actual = HexCharCodec.encodeHex(b, true);
+ actual = Hex.encodeHex(b, true);
assertTrue(expected.equals(new String(actual)));
- actual = HexCharCodec.encodeHex(b, false);
+ actual = Hex.encodeHex(b, false);
assertFalse(expected.equals(new String(actual)));
}
@@ -327,11 +327,11 @@ public class HexCharTest {
byte[] b = StringUtils.getBytesUtf8("Hello World");
final String expected = "48656C6C6F20576F726C64";
char[] actual;
- actual = HexCharCodec.encodeHex(b);
+ actual = Hex.encodeHex(b);
assertFalse(expected.equals(new String(actual)));
- actual = HexCharCodec.encodeHex(b, true);
+ actual = Hex.encodeHex(b, true);
assertFalse(expected.equals(new String(actual)));
- actual = HexCharCodec.encodeHex(b, false);
+ actual = Hex.encodeHex(b, false);
assertTrue(expected.equals(new String(actual)));
}
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/BCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/BCodecTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/BCodecTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/BCodecTest.java Thu Aug 25 00:35:31 2011
@@ -137,7 +137,7 @@ public class BCodecTest {
public void testDecodeStrings() throws Exception {
BCodec bcodec = new BCodec();
String decoded = "=?UTF-8?B?d2hhdCBub3Q=?=";
- String plain = (String) bcodec.decode(decoded);
+ String plain = bcodec.decode(decoded);
assertEquals("Basic B decoding test", "what not", plain);
Object result = bcodec.decode(null);
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QCodecTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QCodecTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QCodecTest.java Thu Aug 25 00:35:31 2011
@@ -164,7 +164,7 @@ public class QCodecTest {
public void testDecodeStrings() throws Exception {
QCodec qcodec = new QCodec();
String decoded = "=?UTF-8?Q?1+1 =3D 2?=";
- String plain = (String) qcodec.decode(decoded);
+ String plain = qcodec.decode(decoded);
assertEquals("Basic Q decoding test",
"1+1 = 2", plain);
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableBinaryCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableBinaryCodecTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableBinaryCodecTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableBinaryCodecTest.java Thu Aug 25 00:35:31 2011
@@ -68,7 +68,7 @@ public class QuotedPrintableBinaryCodecT
@Test
public void testDecodeWithNullArray() throws Exception {
byte[] plain = null;
- byte[] result = QuotedPrintableBinaryCodec.decodeQuotedPrintable( plain );
+ byte[] result = QuotedPrintableCodec.decodeQuotedPrintable( plain );
assertEquals("Result should be null", null, result);
}
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableStringCodecTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableStringCodecTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableStringCodecTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/QuotedPrintableStringCodecTest.java Thu Aug 25 00:35:31 2011
@@ -152,7 +152,7 @@ public class QuotedPrintableStringCodecT
public void testEncodeUrlWithNullBitSet() throws Exception {
QuotedPrintableStringCodec qpcodec = new QuotedPrintableStringCodec();
String plain = "1+1 = 2";
- String encoded = new String(QuotedPrintableStringCodec.
+ String encoded = new String(QuotedPrintableCodec.
encodeQuotedPrintable(null, plain.getBytes("UTF-8")));
assertEquals("Basic quoted-printable encoding test",
"1+1 =3D 2", encoded);
@@ -164,7 +164,7 @@ public class QuotedPrintableStringCodecT
@Test
public void testDecodeWithNullArray() throws Exception {
byte[] plain = null;
- byte[] result = QuotedPrintableStringCodec.decodeQuotedPrintable( plain );
+ byte[] result = QuotedPrintableCodec.decodeQuotedPrintable( plain );
assertEquals("Result should be null", null, result);
}
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecBinaryTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecBinaryTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecBinaryTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecBinaryTest.java Thu Aug 25 00:35:31 2011
@@ -90,7 +90,7 @@ public class URLCodecBinaryTest {
@Test
public void testDecodeWithNullArray() throws Exception {
byte[] plain = null;
- byte[] result = URLBinaryCodec.decodeUrl( plain );
+ byte[] result = URLCodec.decodeUrl( plain );
assertEquals("Result should be null", null, result);
}
@@ -117,7 +117,7 @@ public class URLCodecBinaryTest {
String plain = "Hello+there%21";
byte[] plainBA = plain.getBytes("UTF-8");
- byte[] decodedBA = (byte[]) urlCodec.decode(plainBA);
+ byte[] decodedBA = urlCodec.decode(plainBA);
String decoded = new String(decodedBA);
assertEquals("Basic URL decoding test",
"Hello there!", decoded);
Modified: commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecStringTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecStringTest.java?rev=1161343&r1=1161342&r2=1161343&view=diff
==============================================================================
--- commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecStringTest.java (original)
+++ commons/proper/codec/branches/generics/src/test/org/apache/commons/codec/net/URLCodecStringTest.java Thu Aug 25 00:35:31 2011
@@ -188,7 +188,7 @@ public class URLCodecStringTest {
public void testEncodeUrlWithNullBitSet() throws Exception {
URLStringCodec urlCodec = new URLStringCodec();
String plain = "Hello there!";
- String encoded = new String( URLStringCodec.encodeUrl(null, plain.getBytes("UTF-8")));
+ String encoded = new String( URLCodec.encodeUrl(null, plain.getBytes("UTF-8")));
assertEquals("Basic URL encoding test",
"Hello+there%21", encoded);
assertEquals("Basic URL decoding test",
@@ -199,7 +199,7 @@ public class URLCodecStringTest {
@Test
public void testDecodeWithNullArray() throws Exception {
byte[] plain = null;
- byte[] result = URLStringCodec.decodeUrl( plain );
+ byte[] result = URLCodec.decodeUrl( plain );
assertEquals("Result should be null", null, result);
}
@@ -228,7 +228,7 @@ public class URLCodecStringTest {
"Hello+there%21", encoded);
byte[] plainBA = plain.getBytes("UTF-8");
- byte[] encodedBA = (byte[]) urlCodec.encode(plainBA);
+ byte[] encodedBA = urlCodec.encode(plainBA);
encoded = new String(encodedBA);
assertEquals("Basic URL encoding test",
"Hello+there%21", encoded);