You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2024/01/31 13:54:46 UTC
(commons-compress) 01/05: Add missing tests
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 64b61741b5e69c35100e65eba9a163fd07736336
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Wed Jan 31 08:40:41 2024 -0500
Add missing tests
---
.../apache/commons/compress/utils/IOUtilsTest.java | 26 ++++++++++++++++++++++
1 file changed, 26 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 53a4c020e..c5a94340b 100644
--- a/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
+++ b/src/test/java/org/apache/commons/compress/utils/IOUtilsTest.java
@@ -28,11 +28,14 @@ import java.io.EOFException;
import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.io.OutputStream;
import java.lang.reflect.Field;
import java.nio.ByteBuffer;
import java.nio.channels.ReadableByteChannel;
import java.nio.charset.StandardCharsets;
+import org.apache.commons.io.input.NullInputStream;
+import org.apache.commons.io.output.NullOutputStream;
import org.junit.jupiter.api.Test;
public class IOUtilsTest {
@@ -55,6 +58,29 @@ public class IOUtilsTest {
}
}
+ @Test
+ public void testCopy_inputStreamToOutputStream_IO84() throws Exception {
+ final long size = (long) Integer.MAX_VALUE + (long) 1;
+ final InputStream in = new NullInputStream(size);
+ final OutputStream out = NullOutputStream.INSTANCE;
+ // Test copy() method
+ assertEquals(-1, IOUtils.copy(in, out));
+ // reset the input
+ in.close();
+ }
+
+ @Test
+ public void testCopy_inputStreamToOutputStream_nullIn() {
+ final OutputStream out = new ByteArrayOutputStream();
+ assertThrows(NullPointerException.class, () -> IOUtils.copy((InputStream) null, out));
+ }
+
+ @Test
+ public void testCopy_inputStreamToOutputStream_nullOut() {
+ final InputStream in = new ByteArrayInputStream(new byte[] { 1, 2, 3, 4 });
+ assertThrows(NullPointerException.class, () -> IOUtils.copy(in, (OutputStream) null));
+ }
+
@Test
public void testCopyRangeDoesntCopyMoreThanAskedFor() throws IOException {
try (ByteArrayInputStream in = new ByteArrayInputStream(new byte[] { 1, 2, 3, 4, 5 });