This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-io.git


The following commit(s) were added to refs/heads/master by this push:
     new 61c1b0d  Add StringInputStream.
61c1b0d is described below

commit 61c1b0d16a65a0a8d414b46b470166a7ffb35b28
Author: Gary Gregory <gardgreg...@gmail.com>
AuthorDate: Mon Jul 12 13:55:17 2021 -0400

    Add StringInputStream.
---
 src/changes/changes.xml                            |  3 +
 .../java/org/apache/commons/io/CopyUtilsTest.java  |  3 +-
 .../java/org/apache/commons/io/DemuxTestCase.java  |  3 +-
 .../org/apache/commons/io/IOUtilsTestCase.java     |  4 +-
 .../commons/io/input/BOMInputStreamTest.java       |  5 +-
 .../commons/io/input/BoundedInputStreamTest.java   |  4 +-
 .../commons/io/input/CountingInputStreamTest.java  |  9 +--
 .../MessageDigestCalculatingInputStreamTest.java   |  5 +-
 .../apache/commons/io/input/StringInputStream.java | 78 ++++++++++++++++++++++
 .../commons/io/input/StringInputStreamTest.java    | 47 +++++++++++++
 .../io/input/SwappedDataInputStreamTest.java       |  2 +-
 .../io/input/WindowsLineEndingInputStreamTest.java | 37 +++++-----
 .../commons/io/input/XmlStreamReaderTest.java      | 16 ++---
 .../io/input/XmlStreamReaderUtilitiesTest.java     |  3 +-
 .../buffer/CircularBufferInputStreamTest.java      | 25 +++----
 .../XmlStreamReaderUtilitiesCompatibilityTest.java |  4 +-
 16 files changed, 184 insertions(+), 64 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index eb87396..94de675 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -63,6 +63,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action dev="ggregory" type="add" due-to="Gary Gregory">
         Add UncheckedFilterWriter.
       </action>
+      <action dev="ggregory" type="add" due-to="Gary Gregory">
+        Add StringInputStream.
+      </action>
       <!-- UPDATE -->
       <action dev="ggregory" type="update" due-to="Dependabot">
         Bump Maven Javadoc plugin from 3.2.0 to 3.3.0.
diff --git a/src/test/java/org/apache/commons/io/CopyUtilsTest.java 
b/src/test/java/org/apache/commons/io/CopyUtilsTest.java
index 623bc06..9d1e3a3 100644
--- a/src/test/java/org/apache/commons/io/CopyUtilsTest.java
+++ b/src/test/java/org/apache/commons/io/CopyUtilsTest.java
@@ -27,6 +27,7 @@ import java.io.StringWriter;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 
+import org.apache.commons.io.input.StringInputStream;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.io.test.TestUtils;
 import org.apache.commons.io.test.ThrowOnCloseInputStream;
@@ -136,7 +137,7 @@ public class CopyUtilsTest {
         final String inDataStr = "data";
         final String charsetName = "UTF-8";
         final StringWriter writer = new StringWriter();
-        CopyUtils.copy(new 
ByteArrayInputStream(inDataStr.getBytes(charsetName)), writer, charsetName);
+        CopyUtils.copy(new StringInputStream(inDataStr, charsetName), writer, 
charsetName);
         assertEquals(inDataStr, writer.toString());
     }
 
diff --git a/src/test/java/org/apache/commons/io/DemuxTestCase.java 
b/src/test/java/org/apache/commons/io/DemuxTestCase.java
index 7ab756d..f3a2e01 100644
--- a/src/test/java/org/apache/commons/io/DemuxTestCase.java
+++ b/src/test/java/org/apache/commons/io/DemuxTestCase.java
@@ -27,6 +27,7 @@ import java.util.HashMap;
 import java.util.Random;
 
 import org.apache.commons.io.input.DemuxInputStream;
+import org.apache.commons.io.input.StringInputStream;
 import org.apache.commons.io.output.ByteArrayOutputStream;
 import org.apache.commons.io.output.DemuxOutputStream;
 import org.apache.commons.io.test.TestUtils;
@@ -93,7 +94,7 @@ public class DemuxTestCase {
     private void startReader(final String name,
                              final String data,
                              final DemuxInputStream demux) {
-        final ByteArrayInputStream input = new 
ByteArrayInputStream(data.getBytes());
+        final InputStream input = new StringInputStream(data);
         final ReaderThread thread = new ReaderThread(name, input, demux);
         threadMap.put(name, thread);
     }
diff --git a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java 
b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
index cff295c..1c59ded 100644
--- a/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
+++ b/src/test/java/org/apache/commons/io/IOUtilsTestCase.java
@@ -63,6 +63,7 @@ import java.util.List;
 import org.apache.commons.io.function.IOConsumer;
 import org.apache.commons.io.input.CircularInputStream;
 import org.apache.commons.io.input.NullInputStream;
+import org.apache.commons.io.input.StringInputStream;
 import org.apache.commons.io.output.AppendableWriter;
 import org.apache.commons.io.output.NullOutputStream;
 import org.apache.commons.io.output.StringBuilderWriter;
@@ -976,8 +977,7 @@ public class IOUtilsTestCase {
 
     @Test
     public void testReadFully_InputStream_Offset() throws Exception {
-        final byte[] bytes = "abcd1234".getBytes(StandardCharsets.UTF_8);
-        final ByteArrayInputStream stream = new ByteArrayInputStream(bytes);
+        final StringInputStream stream = new StringInputStream("abcd1234", 
StandardCharsets.UTF_8);
         final byte[] buffer = "wx00000000".getBytes(StandardCharsets.UTF_8);
         IOUtils.readFully(stream, buffer, 2, 8);
         assertEquals("wxabcd1234", new String(buffer, 0, buffer.length, 
StandardCharsets.UTF_8));
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 0241454..cfb096f 100644
--- a/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BOMInputStreamTest.java
@@ -777,10 +777,9 @@ public class BOMInputStreamTest {
     }
 
     private boolean doesSaxSupportCharacterSet(final String charSetName) 
throws ParserConfigurationException, SAXException, IOException {
-        final byte[] data = ("<?xml version=\"1.0\" encoding=\"" + charSetName 
+ "\"?><Z/>").getBytes(charSetName);
         final DocumentBuilder documentBuilder = 
DocumentBuilderFactory.newInstance().newDocumentBuilder();
-        try {
-            final InputSource is = new InputSource(new 
ByteArrayInputStream(data));
+        try (final StringInputStream byteStream = new StringInputStream("<?xml 
version=\"1.0\" encoding=\"" + charSetName + "\"?><Z/>", charSetName)) {
+            final InputSource is = new InputSource(byteStream);
             is.setEncoding(charSetName);
             documentBuilder.parse(is);
         } catch (final SAXParseException e) {
diff --git 
a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
index 8595a7c..f0e6c4e 100644
--- a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
@@ -33,7 +33,7 @@ public class BoundedInputStreamTest {
     public void testReadSingle() throws Exception {
         BoundedInputStream bounded;
         final byte[] helloWorld = "Hello World".getBytes();
-        final byte[] hello      = "Hello".getBytes();
+        final byte[] hello = "Hello".getBytes();
 
         // limit = length
         bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), 
helloWorld.length);
@@ -62,7 +62,7 @@ public class BoundedInputStreamTest {
 
         BoundedInputStream bounded;
         final byte[] helloWorld = "Hello World".getBytes();
-        final byte[] hello      = "Hello".getBytes();
+        final byte[] hello = "Hello".getBytes();
 
         bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld));
         compare("limit = -1", helloWorld, IOUtils.toByteArray(bounded));
diff --git 
a/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
index eb7ab52..4d8f80e 100644
--- a/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/CountingInputStreamTest.java
@@ -21,6 +21,7 @@ import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 
 import org.apache.commons.io.IOUtils;
 import org.junit.jupiter.api.Test;
@@ -34,9 +35,7 @@ public class CountingInputStreamTest {
     @Test
     public void testCounting() throws Exception {
         final String text = "A piece of text";
-        final byte[] bytes = text.getBytes();
-        final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
-        try (final CountingInputStream cis = new CountingInputStream(bais)) {
+        try (final CountingInputStream cis = new CountingInputStream(new 
StringInputStream(text))) {
 
             // have to declare this larger as we're going to read
             // off the end of the stream and input stream seems
@@ -199,9 +198,7 @@ public class CountingInputStreamTest {
     @Test
     public void testSkipping() throws IOException {
         final String text = "Hello World!";
-        final byte[] bytes = text.getBytes();
-        final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
-        try (final CountingInputStream cis = new CountingInputStream(bais)) {
+        try (final CountingInputStream cis = new CountingInputStream(new 
StringInputStream(text))) {
 
             assertEquals(6, cis.skip(6));
             assertEquals(6, cis.getCount());
diff --git 
a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
 
b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
index 2be1ccb..c620e0f 100644
--- 
a/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/MessageDigestCalculatingInputStreamTest.java
@@ -34,12 +34,11 @@ public class MessageDigestCalculatingInputStreamTest {
 
     @Test
     public void test() throws Exception {
-        for (int i = 256;  i < 8192;  i = i*2) {
+        for (int i = 256; i < 8192; i = i * 2) {
             final byte[] buffer = generateRandomByteStream(i);
             final MessageDigest md5Sum = MessageDigest.getInstance("MD5");
             final byte[] expect = md5Sum.digest(buffer);
-            try (final MessageDigestCalculatingInputStream md5InputStream =
-                    new MessageDigestCalculatingInputStream(new 
ByteArrayInputStream(buffer))) {
+            try (final MessageDigestCalculatingInputStream md5InputStream = 
new MessageDigestCalculatingInputStream(new ByteArrayInputStream(buffer))) {
                 md5InputStream.consume();
                 final byte[] got = md5InputStream.getMessageDigest().digest();
                 assertArrayEquals(expect, got);
diff --git a/src/test/java/org/apache/commons/io/input/StringInputStream.java 
b/src/test/java/org/apache/commons/io/input/StringInputStream.java
new file mode 100644
index 0000000..3600b6c
--- /dev/null
+++ b/src/test/java/org/apache/commons/io/input/StringInputStream.java
@@ -0,0 +1,78 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.commons.io.input;
+
+import java.io.InputStream;
+import java.io.StringReader;
+import java.nio.charset.Charset;
+
+/**
+ * An {@link InputStream} on a String.
+ *
+ * @since 2.12.0
+ */
+public class StringInputStream extends ReaderInputStream {
+
+    /**
+     * Creates a new instance on a String.
+     *
+     * @param source The source string, MUST not be null.
+     * @return A new instance.
+     */
+    public static StringInputStream on(final String source) {
+        return new StringInputStream(source);
+    }
+
+    /**
+     * Creates a new instance on the empty String.
+     */
+    public StringInputStream() {
+        this("", Charset.defaultCharset());
+    }
+
+    /**
+     * Creates a new instance on a String.
+     *
+     * @param source The source string, MUST not be null.
+     */
+    public StringInputStream(final String source) {
+        this(source, Charset.defaultCharset());
+    }
+
+    /**
+     * Creates a new instance on a String for a Charset.
+     *
+     * @param source The source string, MUST not be null.
+     * @param charset The source charset, MUST not be null.
+     */
+    public StringInputStream(final String source, final Charset charset) {
+        super(new StringReader(source), charset);
+    }
+
+    /**
+     * Creates a new instance on a String and for a Charset.
+     *
+     * @param source The source string, MUST not be null.
+     * @param charset The source charset, MUST not be null.
+     */
+    public StringInputStream(final String source, final String charset) {
+        super(new StringReader(source), charset);
+    }
+
+}
diff --git 
a/src/test/java/org/apache/commons/io/input/StringInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/StringInputStreamTest.java
new file mode 100644
index 0000000..17f43fb
--- /dev/null
+++ b/src/test/java/org/apache/commons/io/input/StringInputStreamTest.java
@@ -0,0 +1,47 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one or more
+ *  contributor license agreements.  See the NOTICE file distributed with
+ *  this work for additional information regarding copyright ownership.
+ *  The ASF licenses this file to You under the Apache License, Version 2.0
+ *  (the "License"); you may not use this file except in compliance with
+ *  the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ */
+
+package org.apache.commons.io.input;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+import java.io.IOException;
+import java.nio.charset.Charset;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.jupiter.api.Test;
+
+/**
+ * Tests {@link StringInputStream}.
+ */
+public class StringInputStreamTest {
+
+    @Test
+    public void testStrinConstructorString() throws IOException {
+        try (final StringInputStream input = StringInputStream.on("01")) {
+            assertEquals("01", IOUtils.toString(input, 
Charset.defaultCharset()));
+        }
+    }
+
+    @Test
+    public void testStrinConstructorStringCharset() throws IOException {
+        try (final StringInputStream input = new StringInputStream("01", 
Charset.defaultCharset())) {
+            assertEquals("01", IOUtils.toString(input, 
Charset.defaultCharset()));
+        }
+    }
+}
diff --git 
a/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java 
b/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java
index b943ba8..67f73ed 100644
--- a/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/SwappedDataInputStreamTest.java
@@ -53,7 +53,7 @@ public class SwappedDataInputStreamTest {
             0x07,
             0x08
         };
-        final ByteArrayInputStream bais = new ByteArrayInputStream( bytes );
+        final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
         this.sdis = new SwappedDataInputStream( bais );
     }
 
diff --git 
a/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java
 
b/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java
index e7e1255..14d0750 100644
--- 
a/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/WindowsLineEndingInputStreamTest.java
@@ -20,6 +20,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
+import java.io.InputStream;
 import java.nio.charset.StandardCharsets;
 
 import org.junit.jupiter.api.Test;
@@ -27,52 +28,50 @@ import org.junit.jupiter.api.Test;
 public class WindowsLineEndingInputStreamTest {
     @Test
     public void simpleString() throws Exception {
-        assertEquals( "abc\r\n", roundtrip( "abc" ) );
+        assertEquals("abc\r\n", roundtrip("abc"));
     }
 
     @Test
     public void inTheMiddleOfTheLine() throws Exception {
-        assertEquals( "a\r\nbc\r\n", roundtrip( "a\r\nbc" ) );
+        assertEquals("a\r\nbc\r\n", roundtrip("a\r\nbc"));
     }
 
     @Test
     public void multipleBlankLines() throws Exception {
-        assertEquals( "a\r\n\r\nbc\r\n", roundtrip( "a\r\n\r\nbc" ) );
+        assertEquals("a\r\n\r\nbc\r\n", roundtrip("a\r\n\r\nbc"));
     }
 
     @Test
     public void twoLinesAtEnd() throws Exception {
-        assertEquals( "a\r\n\r\n", roundtrip( "a\r\n\r\n" ) );
+        assertEquals("a\r\n\r\n", roundtrip("a\r\n\r\n"));
     }
 
     @Test
     public void linuxLinefeeds() throws Exception {
-        final String roundtrip = roundtrip( "ab\nc", false );
-        assertEquals( "ab\r\nc", roundtrip );
+        final String roundtrip = roundtrip("ab\nc", false);
+        assertEquals("ab\r\nc", roundtrip);
     }
 
-
     @Test
     public void malformed() throws Exception {
-        assertEquals( "a\rbc", roundtrip( "a\rbc", false ) );
+        assertEquals("a\rbc", roundtrip("a\rbc", false));
     }
 
     @Test
     public void retainLineFeed() throws Exception {
-        assertEquals( "a\r\n\r\n", roundtrip( "a\r\n\r\n", false ) );
-        assertEquals( "a", roundtrip( "a", false ) );
+        assertEquals("a\r\n\r\n", roundtrip("a\r\n\r\n", false));
+        assertEquals("a", roundtrip("a", false));
     }
 
-    private String roundtrip( final String msg ) throws IOException {
-        return roundtrip( msg, true );
+    private String roundtrip(final String msg) throws IOException {
+        return roundtrip(msg, true);
     }
 
-    private String roundtrip( final String msg, final boolean ensure ) throws 
IOException {
-        final ByteArrayInputStream baos = new ByteArrayInputStream( 
msg.getBytes(StandardCharsets.UTF_8) );
-        final WindowsLineEndingInputStream lf = new 
WindowsLineEndingInputStream( baos, ensure );
-        final byte[] buf = new byte[100];
-        final int read = lf.read( buf );
-        lf.close();
-        return new String( buf, 0, read, StandardCharsets.UTF_8);
+    private String roundtrip(final String msg, final boolean ensure) throws 
IOException {
+        try (final WindowsLineEndingInputStream lf = new 
WindowsLineEndingInputStream(new StringInputStream(msg, 
StandardCharsets.UTF_8), ensure)) {
+            final byte[] buf = new byte[100];
+            final int read = lf.read(buf);
+            return new String(buf, 0, read, StandardCharsets.UTF_8);
+        }
     }
 }
\ No newline at end of file
diff --git a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java 
b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
index 274542b..9ce760c 100644
--- a/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
+++ b/src/test/java/org/apache/commons/io/input/XmlStreamReaderTest.java
@@ -325,20 +325,20 @@ public class XmlStreamReaderTest {
     public void testRawContent() throws Exception {
         final String encoding = "UTF-8";
         final String xml = getXML("no-bom", XML3, encoding, encoding);
-        final ByteArrayInputStream is = new 
ByteArrayInputStream(xml.getBytes(encoding));
-        final XmlStreamReader xmlReader = new XmlStreamReader(is);
-        assertEquals(xmlReader.getEncoding(), encoding, "Check encoding");
-        assertEquals(xml, IOUtils.toString(xmlReader), "Check content");
+        try (final XmlStreamReader xmlReader = new XmlStreamReader(new 
StringInputStream(xml, encoding))) {
+            assertEquals(xmlReader.getEncoding(), encoding, "Check encoding");
+            assertEquals(xml, IOUtils.toString(xmlReader), "Check content");
+        }
     }
 
     @Test
     public void testHttpContent() throws Exception {
         final String encoding = "UTF-8";
         final String xml = getXML("no-bom", XML3, encoding, encoding);
-        final ByteArrayInputStream is = new 
ByteArrayInputStream(xml.getBytes(encoding));
-        final XmlStreamReader xmlReader = new XmlStreamReader(is, encoding);
-        assertEquals(xmlReader.getEncoding(), encoding, "Check encoding");
-        assertEquals(xml, IOUtils.toString(xmlReader), "Check content");
+        try (final XmlStreamReader xmlReader = new XmlStreamReader(new 
StringInputStream(xml, encoding))) {
+            assertEquals(xmlReader.getEncoding(), encoding, "Check encoding");
+            assertEquals(xml, IOUtils.toString(xmlReader), "Check content");
+        }
     }
 
     public void testAlternateDefaultEncoding(final String cT, final String 
bomEnc,
diff --git 
a/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java 
b/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java
index 8c6de90..b0783b5 100644
--- 
a/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/XmlStreamReaderUtilitiesTest.java
@@ -21,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.fail;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
 import org.junit.jupiter.api.Test;
@@ -324,7 +323,7 @@ public class XmlStreamReaderUtilitiesTest {
     /** Mock {@link XmlStreamReader} implementation */
     private static class MockXmlStreamReader extends XmlStreamReader {
         MockXmlStreamReader(final String defaultEncoding) throws IOException {
-            super(new ByteArrayInputStream("".getBytes()), null, true, 
defaultEncoding);
+            super(new StringInputStream(), null, true, defaultEncoding);
         }
     }
 }
diff --git 
a/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java
 
b/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java
index c713ec0..fa27591 100644
--- 
a/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/buffer/CircularBufferInputStreamTest.java
@@ -79,20 +79,17 @@ public class CircularBufferInputStreamTest {
 
        @Test
   public void testIO683() throws IOException {
-               final byte[] buffer = {0,1,-2,-2,-1,4};
-               try (
-                       final ByteArrayInputStream bais = new 
ByteArrayInputStream(buffer);
-                       final CircularBufferInputStream cbis = new 
CircularBufferInputStream(bais)
-               ){
-                       int b;
-                       int i = 0;
-                       while((b = cbis.read()) != -1) {
-                               assertEquals(buffer[i] & 0xFF,b, "byte at index 
" + i + " should be equal");
-                               i++;
-                       }
-                       assertEquals(buffer.length, i, "Should have read all 
the bytes");
-               }
-       }
+      final byte[] buffer = {0, 1, -2, -2, -1, 4};
+      try (final ByteArrayInputStream bais = new ByteArrayInputStream(buffer); 
final CircularBufferInputStream cbis = new CircularBufferInputStream(bais)) {
+          int b;
+          int i = 0;
+          while ((b = cbis.read()) != -1) {
+              assertEquals(buffer[i] & 0xFF, b, "byte at index " + i + " 
should be equal");
+              i++;
+          }
+          assertEquals(buffer.length, i, "Should have read all the bytes");
+      }
+  }
 
        /**
         * Create a large, but random input buffer.
diff --git 
a/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
 
b/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
index b107107..cc1bc14 100644
--- 
a/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
+++ 
b/src/test/java/org/apache/commons/io/input/compatibility/XmlStreamReaderUtilitiesCompatibilityTest.java
@@ -16,9 +16,9 @@
  */
 package org.apache.commons.io.input.compatibility;
 
-import java.io.ByteArrayInputStream;
 import java.io.IOException;
 
+import org.apache.commons.io.input.StringInputStream;
 import org.apache.commons.io.input.XmlStreamReaderUtilitiesTest;
 
 /**
@@ -47,7 +47,7 @@ public class XmlStreamReaderUtilitiesCompatibilityTest 
extends XmlStreamReaderUt
     /** Mock {@link XmlStreamReader} implementation */
     private static class MockXmlStreamReader extends XmlStreamReader {
         MockXmlStreamReader(final String defaultEncoding) throws IOException {
-            super(new ByteArrayInputStream("".getBytes()), null, true, 
defaultEncoding);
+            super(new StringInputStream(), null, true, defaultEncoding);
         }
     }
 }

Reply via email to