commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1301974 - /commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
Date Sat, 17 Mar 2012 18:32:14 GMT
Author: tn
Date: Sat Mar 17 18:32:14 2012
New Revision: 1301974

URL: http://svn.apache.org/viewvc?rev=1301974&view=rev
Log:
Added unit test for CODEC-130.

Modified:
    commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java

Modified: commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java?rev=1301974&r1=1301973&r2=1301974&view=diff
==============================================================================
--- commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
(original)
+++ commons/proper/codec/trunk/src/test/java/org/apache/commons/codec/binary/Base64InputStreamTest.java
Sat Mar 17 18:32:14 2012
@@ -24,13 +24,16 @@ import static org.junit.Assert.assertNot
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
+import java.io.BufferedInputStream;
 import java.io.BufferedReader;
 import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.util.Arrays;
 
+import org.junit.Ignore;
 import org.junit.Test;
 
 /**
@@ -51,6 +54,34 @@ public class Base64InputStreamTest {
     private static final String STRING_FIXTURE = "Hello World";
 
     /**
+     * Tests the problem reported in CODEC-130. Missing / wrong implementation of skip.
+     */
+    @Test
+    @Ignore
+    public void testCodec130() throws IOException {
+        ByteArrayOutputStream bos = new ByteArrayOutputStream();
+        Base64OutputStream base64os = new Base64OutputStream(bos);
+
+        base64os.write("Hello World!".getBytes());
+
+        ByteArrayInputStream bis = new ByteArrayInputStream(bos.toByteArray());
+        Base64InputStream ins = new Base64InputStream(bis);
+
+        // we skip the first character read from the reader
+        ins.skip(1);
+        StringBuffer sb = new StringBuffer();
+        int len = 0;
+        byte[] bytes = new byte[10];
+        while ((len = ins.read(bytes)) != -1) {
+            String s = new String(bytes, 0, len, "iso-8859-1");
+            sb.append(s);
+        }
+        String str = sb.toString();
+
+        assertEquals("ello World!", str);
+    }
+
+    /**
      * Tests the bug reported in CODEC-105. Bad interactions with InputStream when reading
one byte at a time.
      */
     @Test



Mime
View raw message