commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject svn commit: r1371705 - /commons/proper/io/trunk/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
Date Fri, 10 Aug 2012 13:55:35 GMT
Author: ggregory
Date: Fri Aug 10 13:55:35 2012
New Revision: 1371705

URL: http://svn.apache.org/viewvc?rev=1371705&view=rev
Log:
Makes test fixture methods private.

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=1371705&r1=1371704&r2=1371705&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
Fri Aug 10 13:55:35 2012
@@ -25,6 +25,7 @@ import junit.framework.TestCase;
 import org.apache.commons.io.ByteOrderMark;
 import org.apache.commons.io.Charsets;
 import org.junit.Assert;
+import org.junit.Assume;
 
 /**
  * Test case for {@link BOMInputStream}.
@@ -39,7 +40,7 @@ public class BOMInputStreamTest extends 
     /**
      *  Creates the underlying data stream, with or without BOM.
      */
-    public InputStream createUtf8DataStream(byte[] baseData, boolean addBOM) {
+    private InputStream createUtf8DataStream(byte[] baseData, boolean addBOM) {
         byte[] data = baseData;
         if (addBOM) {
             data = new byte[baseData.length + 3];
@@ -54,7 +55,7 @@ public class BOMInputStreamTest extends 
     /**
      *  Creates the underlying data stream, with or without BOM.
      */
-    public InputStream createUtf16BeDataStream(byte[] baseData, boolean addBOM) {
+    private InputStream createUtf16BeDataStream(byte[] baseData, boolean addBOM) {
         byte[] data = baseData;
         if (addBOM) {
             data = new byte[baseData.length + 2];
@@ -68,7 +69,7 @@ public class BOMInputStreamTest extends 
     /**
      *  Creates the underlying data stream, with or without BOM.
      */
-    public InputStream createUtf16LeDataStream(byte[] baseData, boolean addBOM) {
+    private InputStream createUtf16LeDataStream(byte[] baseData, boolean addBOM) {
         byte[] data = baseData;
         if (addBOM) {
             data = new byte[baseData.length + 2];
@@ -218,6 +219,27 @@ public class BOMInputStreamTest extends 
         }
     }
 
+    public void testReadWithBOMUtf32Be() throws Exception {
+        byte[] data = "ABC".getBytes("UTF_32BE");
+        BOMInputStream in = new BOMInputStream(createUtf16BeDataStream(data, true), ByteOrderMark.UTF_32BE);
+        assertEquals(0, in.read());
+        assertEquals('A', in.read());
+        assertEquals(0, in.read());
+        assertEquals('B', in.read());
+        assertEquals(0, in.read());
+        assertEquals('C', in.read());
+        assertEquals(-1, in.read());
+        assertTrue("hasBOM()", in.hasBOM());
+        assertTrue("hasBOM(UTF-32BE)", in.hasBOM(ByteOrderMark.UTF_32BE));
+        assertEquals("getBOM", ByteOrderMark.UTF_32BE, in.getBOM());
+        try {
+            in.hasBOM(ByteOrderMark.UTF_32LE);
+            fail("Expected IllegalArgumentException");
+        } catch (IllegalArgumentException e) {
+            // expected - not configured for UTF-32LE
+        }
+    }
+
     public void testReadWithBOMUtf16Le() throws Exception {
         byte[] data = "ABC".getBytes(Charsets.UTF_16LE);
         BOMInputStream in = new BOMInputStream(createUtf16LeDataStream(data, true), ByteOrderMark.UTF_16LE);
@@ -459,7 +481,7 @@ public class BOMInputStreamTest extends 
         this.readBOMInputStreamTwice("/org/apache/commons/io/testfileBOM.xml");
     }
 
-    public void readBOMInputStreamTwice(String resource) throws Exception {
+    private void readBOMInputStreamTwice(String resource) throws Exception {
         InputStream inputStream = this.getClass().getResourceAsStream(resource);
         Assert.assertNotNull(inputStream);
         BOMInputStream bomInputStream = new BOMInputStream(inputStream);



Mime
View raw message