Author: julius Date: Mon Feb 18 19:00:47 2013 New Revision: 1447431 URL: http://svn.apache.org/r1447431 Log: CODEC-167 - Test our decode with pad character in the middle
Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java?rev=1447431&r1=1447430&r2=1447431&view=diff ============================================================================== --- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java (original) +++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64Test.java Mon Feb 18 19:00:47 2013 @@ -100,6 +100,26 @@ public class Base64Test { } /** + * Test our decode with pad character in the middle. + * (Our current implementation: halt decode and return what we've got so far). + * + * The point of this test is not to say "this is the correct way to decode base64." + * The point is simply to keep us aware of the current logic since 1.4 so we + * don't accidentally break it without realizing. + * + * Note for historians. The 1.3 logic would decode to: + * "Hello World\u0000Hello World" -- null in the middle --- + * and 1.4 unwittingly changed it to current logic. + */ + @Test + public void testDecodeWithInnerPad() { + final String content = "SGVsbG8gV29ybGQ=SGVsbG8gV29ybGQ="; + byte[] result = Base64.decodeBase64(content); + byte[] shouldBe = StringUtils.getBytesUtf8("Hello World"); + assertTrue("decode should halt at pad (=)", Arrays.equals(result, shouldBe)); + } + + /** * Tests Base64.encodeBase64(). */ @Test