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/27 22:31:57 UTC

(commons-io) 03/03: org.apache.commons.io.input.BoundedInputStreamTest.testBuilderGet()

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 f376f3b613136f751961341d1114ce4b6d04e168
Author: Gary Gregory <ga...@gmail.com>
AuthorDate: Sat Jan 27 17:31:49 2024 -0500

    org.apache.commons.io.input.BoundedInputStreamTest.testBuilderGet()
---
 .../org/apache/commons/io/input/BoundedInputStreamTest.java    | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

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 79214544..5ae071f2 100644
--- a/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
+++ b/src/test/java/org/apache/commons/io/input/BoundedInputStreamTest.java
@@ -18,6 +18,7 @@ package org.apache.commons.io.input;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import java.io.ByteArrayInputStream;
@@ -39,16 +40,21 @@ public class BoundedInputStreamTest {
         }
     }
 
+    @Test
+    public void testBuilderGet() {
+        // java.lang.IllegalStateException: origin == null
+        assertThrows(IllegalStateException.class, () -> BoundedInputStream.builder().get());
+    }
+
     @SuppressWarnings("deprecation")
     @Test
     public void testOnMaxLength() throws Exception {
-        BoundedInputStream bounded;
         final byte[] helloWorld = "Hello World".getBytes(StandardCharsets.UTF_8);
         final byte[] hello = "Hello".getBytes(StandardCharsets.UTF_8);
         final AtomicBoolean boolRef = new AtomicBoolean();
 
         // limit = length
-        bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length) {
+        BoundedInputStream bounded = new BoundedInputStream(new ByteArrayInputStream(helloWorld), helloWorld.length) {
             @Override
             protected void onMaxLength(final long max, final long readCount) {
                 boolRef.set(true);