[IO-302] ArrayIndexOutOfBoundsException in BOMInputStream when reading a file without BOM multiple times. Refactor tests to use both BOM and no-BOM test files.

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1292460 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java b/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
index af1c0f4..99cba27 100644
--- a/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
@@ -362,14 +362,22 @@
     }
     
     public void testReadTwiceWithoutBOM() throws Exception {
-    	InputStream inputStream = this.getClass().getResourceAsStream("/org/apache/commons/io/testfileNoBOM.xml");
-    	Assert.assertNotNull(inputStream);
-    	BOMInputStream bomInputStream = new BOMInputStream(inputStream);
-    	bomInputStream.mark(1000000);
+        this.readBOMInputStreamTwice("/org/apache/commons/io/testfileNoBOM.xml");
+    }
 
-    	this.readFile(bomInputStream);
-    	bomInputStream.reset();
-    	this.readFile(bomInputStream);
+    public void testReadTwiceWithBOM() throws Exception {
+        this.readBOMInputStreamTwice("/org/apache/commons/io/testfileBOM.xml");
+    }
+
+    public void readBOMInputStreamTwice(String resource) throws Exception {
+        InputStream inputStream = this.getClass().getResourceAsStream(resource);
+        Assert.assertNotNull(inputStream);
+        BOMInputStream bomInputStream = new BOMInputStream(inputStream);
+        bomInputStream.mark(1000000);
+
+        this.readFile(bomInputStream);
+        bomInputStream.reset();
+        this.readFile(bomInputStream);
     }
 
     private void readFile(BOMInputStream bomInputStream) throws Exception {