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-compress.git
commit 7a9728f7cbe757a12ee86053d68e5fc7167b680a Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Wed Jan 31 08:07:43 2024 -0500 Add missing test --- .../org/apache/commons/compress/utils/IOUtilsTest.java | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java index d61d4fa30..53a4c020e 100644 --- a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java +++ b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java @@ -19,6 +19,7 @@ package org.apache.commons.compress.utils; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; import java.io.ByteArrayInputStream; @@ -30,6 +31,7 @@ import java.io.InputStream; import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.nio.channels.ReadableByteChannel; +import java.nio.charset.StandardCharsets; import org.junit.jupiter.api.Test; @@ -212,4 +214,18 @@ public class IOUtilsTest { } }); } + + @Test + public void testToByteArray_InputStream() throws Exception { + final byte[] bytes = "ABCB".getBytes(StandardCharsets.UTF_8); + try (InputStream fin = new ByteArrayInputStream(bytes)) { + @SuppressWarnings("deprecation") + final byte[] out = IOUtils.toByteArray(fin); + assertNotNull(out); + assertEquals(0, fin.available()); + assertEquals(4, out.length); + assertArrayEquals(bytes, out); + } + } + }