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


The following commit(s) were added to refs/heads/master by this push:
     new 6c2b3ef6 Let the test internal method propagate exceptions
6c2b3ef6 is described below

commit 6c2b3ef6090b9f69ee6330d169ec0a908f6ec63e
Author: Gary Gregory <garydgreg...@gmail.com>
AuthorDate: Fri Apr 28 17:03:54 2023 -0400

    Let the test internal method propagate exceptions
---
 .../io/output/DeferredFileOutputStreamTest.java    | 32 ++++++++--------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git 
a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java 
b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
index 8b2f27c0..d1e44b53 100644
--- 
a/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
+++ 
b/src/test/java/org/apache/commons/io/output/DeferredFileOutputStreamTest.java
@@ -23,10 +23,8 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 import java.io.File;
-import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
 import java.nio.file.Files;
@@ -408,26 +406,20 @@ public class DeferredFileOutputStreamTest {
      *
      * @param testFile The file containing the test output.
      */
-    private void verifyResultFile(final File testFile) {
+    private void verifyResultFile(final File testFile) throws IOException {
+        final InputStream fis = Files.newInputStream(testFile.toPath());
+        assertEquals(testBytes.length, fis.available());
+
+        final byte[] resultBytes = new byte[testBytes.length];
+        assertEquals(testBytes.length, fis.read(resultBytes));
+
+        assertArrayEquals(resultBytes, testBytes);
+        assertEquals(-1, fis.read(resultBytes));
+
         try {
-            final InputStream fis = Files.newInputStream(testFile.toPath());
-            assertEquals(testBytes.length, fis.available());
-
-            final byte[] resultBytes = new byte[testBytes.length];
-            assertEquals(testBytes.length, fis.read(resultBytes));
-
-            assertArrayEquals(resultBytes, testBytes);
-            assertEquals(-1, fis.read(resultBytes));
-
-            try {
-                fis.close();
-            } catch (final IOException e) {
-                // Ignore an exception on close
-            }
-        } catch (final FileNotFoundException e) {
-            fail("Unexpected FileNotFoundException");
+            fis.close();
         } catch (final IOException e) {
-            fail("Unexpected IOException");
+            // Ignore an exception on close
         }
     }
 }

Reply via email to