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
commit cb0e601a51ea13e36e68b095abcd89d3d6848838 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Sun Jul 14 10:34:09 2024 -0400 Add MarkShieldInputStreamTest.testCloseHandleIOException() --- .../io/input/MarkShieldInputStreamTest.java | 30 +++++++++++++--------- 1 file changed, 18 insertions(+), 12 deletions(-) diff --git a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java index 5c42a2244..12ff9e689 100644 --- a/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java +++ b/src/test/java/org/apache/commons/io/input/MarkShieldInputStreamTest.java @@ -66,26 +66,19 @@ public class MarkShieldInputStreamTest { assertEquals(0, shadow.available()); } - @SuppressWarnings("resource") @ParameterizedTest @MethodSource(AbstractInputStreamTest.ARRAY_LENGTHS_NAME) - public void testReadAfterClose(final int len) throws Exception { - final InputStream shadow; + public void testAvailableAfterOpen(final int len) throws Exception { try (MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(len, false, false)); final MarkShieldInputStream msis = new MarkShieldInputStream(in)) { assertEquals(len, in.available()); - shadow = in; } - assertEquals(IOUtils.EOF, shadow.read()); } - @ParameterizedTest - @MethodSource(AbstractInputStreamTest.ARRAY_LENGTHS_NAME) - public void testAvailableAfterOpen(final int len) throws Exception { - try (MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(len, false, false)); - final MarkShieldInputStream msis = new MarkShieldInputStream(in)) { - assertEquals(len, in.available()); - } + @SuppressWarnings("resource") + @Test + public void testCloseHandleIOException() throws IOException { + ProxyInputStreamTest.testCloseHandleIOException(new MarkShieldInputStream(new BrokenInputStream((Throwable) new IOException()))); } @Test @@ -130,6 +123,19 @@ public class MarkShieldInputStreamTest { } } + @SuppressWarnings("resource") + @ParameterizedTest + @MethodSource(AbstractInputStreamTest.ARRAY_LENGTHS_NAME) + public void testReadAfterClose(final int len) throws Exception { + final InputStream shadow; + try (MarkTestableInputStream in = new MarkTestableInputStream(new NullInputStream(len, false, false)); + final MarkShieldInputStream msis = new MarkShieldInputStream(in)) { + assertEquals(len, in.available()); + shadow = in; + } + assertEquals(IOUtils.EOF, shadow.read()); + } + @Test public void testResetThrowsExceptionWhenUnderlyingDoesNotSupport() throws IOException { // test wrapping an underlying stream which does NOT support marking