commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From krosenv...@apache.org
Subject svn commit: r1686532 - /commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
Date Sat, 20 Jun 2015 08:37:10 GMT
Author: krosenvold
Date: Sat Jun 20 08:37:10 2015
New Revision: 1686532

URL: http://svn.apache.org/r1686532
Log:
Cleaned up testcase logic, removed duplication

Modified:
    commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java

Modified: commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
URL: http://svn.apache.org/viewvc/commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java?rev=1686532&r1=1686531&r2=1686532&view=diff
==============================================================================
--- commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
(original)
+++ commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
Sat Jun 20 08:37:10 2015
@@ -381,28 +381,7 @@ public class BOMInputStreamTest {
         }
     }
 
-    private static InputStream createInputStream(boolean addBOM) {
-        ByteBuffer bb = ByteBuffer.allocate(64);
-        if (addBOM) {
-            // UTF-8 BOM
-            bb.put(new byte[]{(byte) 0xEF, (byte) 0xBB, (byte) 0xBF});
-        }
-        bb.put((byte) 0x31);
-        bb.put((byte) 0x32);
-        bb.put((byte) 0x33);
-        return new ByteArrayInputStream(bb.array());
-    }
 
-    @Test
-    public void lengthWithNoBOM() throws IOException {
-        BOMInputStream is1 = new BOMInputStream(createInputStream(true));
-        assertEquals(2, is1.skip(2));
-        assertEquals((byte) 0x33, is1.read());
-
-        BOMInputStream is2 = new BOMInputStream(createInputStream(false));
-        assertEquals(2, is2.skip(2)); // fails here - skip returns 0
-        assertEquals((byte) 0x33, is2.read());
-    }
 
 
 
@@ -713,6 +692,23 @@ public class BOMInputStreamTest {
         in.close();
     }
 
+
+    @Test
+    public void skipReturnValueWithBom() throws IOException {
+        byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33};
+        BOMInputStream is1 = new BOMInputStream(createUtf8DataStream(baseData, true));
+        assertEquals(2, is1.skip(2));
+        assertEquals((byte) 0x33, is1.read());
+    }
+
+    @Test
+    public void skipReturnValueWithoutBom() throws IOException {
+        byte[] baseData = new byte[]{(byte) 0x31, (byte) 0x32, (byte) 0x33};
+        BOMInputStream is2 = new BOMInputStream(createUtf8DataStream(baseData, false));
+        assertEquals(2, is2.skip(2)); // IO-428
+        assertEquals((byte) 0x33, is2.read());
+    }
+
     @Test
     public void testSmallBufferWithBOM() throws Exception {
         final byte[] data = new byte[] { 'A', 'B', 'C' };



Mime
View raw message