/** * Tests to make sure Base64's implementation of Base64.encodeBase64() * static method is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testStaticEncode() throws EncoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64, Base64.encodeBase64(binary)); assertTrue("static Base64.encodeBase64() test-" + i, b); } } }
/** * Tests to make sure Base64's implementation of Base64.decodeBase64() * static method is behaving identical to commons-codec-1.3.jar. * * @throws DecoderException problem */ @Test public void testStaticDecode() throws DecoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, Base64.decodeBase64(base64)); assertTrue("static Base64.decodeBase64() test-" + i, b); } } }
/** * Tests to make sure Base64's implementation of Base64.decodeBase64() * static method is behaving identical to commons-codec-1.3.jar when * supplied with chunked input. * * @throws DecoderException problem */ @Test public void testStaticDecodeChunked() throws DecoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, Base64.decodeBase64(base64Chunked)); assertTrue("static Base64.decodeBase64Chunked() test-" + i, b); } } }
/** * Tests to make sure Base64's implementation of the org.apache.commons.codec.BinaryDecoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws DecoderException problem */ @Test public void testBinaryDecoder() throws DecoderException { final BinaryDecoder dec = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, dec.decode(base64)); assertTrue("BinaryDecoder test-" + i, b); } } }
/** * Tests to make sure Base64's implementation of the org.apache.commons.codec.BinaryEncoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testBinaryEncoder() throws EncoderException { final BinaryEncoder enc = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64, enc.encode(binary)); assertTrue("BinaryEncoder test-" + i, b); } } }
/** * Tests to make sure Base64's implementation of the org.apache.commons.codec.Encoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testEncoder() throws EncoderException { final Encoder enc = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64, (byte[]) enc.encode(binary)); assertTrue("Encoder test-" + i, b); } } }
/** * Tests to make sure Base64's implementation of the org.apache.commons.codec.Decoder * interface is behaving identical to commons-codec-1.3.jar. * * @throws DecoderException problem */ @Test public void testDecoder() throws DecoderException { final Decoder dec = new Base64(); for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64 = utf8(STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(binary, (byte[]) dec.decode(base64)); assertTrue("Decoder test-" + i, b); } } }
/** * Tests to make sure Base64's implementation of Base64.encodeBase64Chunked() * static method is behaving identical to commons-codec-1.3.jar. * * @throws EncoderException problem */ @Test public void testStaticEncodeChunked() throws EncoderException { for (int i = 0; i < STRINGS.length; i++) { if (STRINGS[i] != null) { final byte[] base64Chunked = utf8(CHUNKED_STRINGS[i]); final byte[] binary = BYTES[i]; final boolean b = Arrays.equals(base64Chunked, Base64.encodeBase64Chunked(binary)); assertTrue("static Base64.encodeBase64Chunked() test-" + i, b); } } }