diff options
Diffstat (limited to 'src/testcases/org/apache/poi/util/TestIOUtils.java')
-rw-r--r-- | src/testcases/org/apache/poi/util/TestIOUtils.java | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/testcases/org/apache/poi/util/TestIOUtils.java b/src/testcases/org/apache/poi/util/TestIOUtils.java index efda717796..b3ebeac4ff 100644 --- a/src/testcases/org/apache/poi/util/TestIOUtils.java +++ b/src/testcases/org/apache/poi/util/TestIOUtils.java @@ -172,6 +172,29 @@ public final class TestIOUtils { } } + @Test(expected = RecordFormatException.class) + public void testMaxLengthTooLong() throws IOException { + try (InputStream is = new FileInputStream(TMP)) { + IOUtils.toByteArray(is, Integer.MAX_VALUE, 100); + } + } + + @Test + public void testMaxLengthIgnored() throws IOException { + try (InputStream is = new FileInputStream(TMP)) { + IOUtils.toByteArray(is, 90, Integer.MAX_VALUE); + IOUtils.toByteArray(is, 90, 100); + IOUtils.toByteArray(is, Integer.MAX_VALUE, Integer.MAX_VALUE); + } + } + + @Test(expected = RecordFormatException.class) + public void testMaxLengthInvalid() throws IOException { + try (InputStream is = new FileInputStream(TMP)) { + IOUtils.toByteArray(is, 90, 80); + } + } + @Test public void testWonkyInputStream() throws IOException { long skipped = IOUtils.skipFully(new WonkyInputStream(), 10000); |