This is an automated email from the ASF dual-hosted git repository.

ggregory pushed a commit to branch 1.x
in repository https://gitbox.apache.org/repos/asf/commons-fileupload.git

commit c6b52f0caff924eb5dc0deb717695af2ced1a138
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Thu Jun 5 07:47:29 2025 -0400

    Better test assertions
---
 pom.xml                                            |  5 +++++
 .../commons/fileupload/MultipartStreamTest.java    | 26 ++++++----------------
 2 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/pom.xml b/pom.xml
index 189b9c8f..9c343e8b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -88,6 +88,11 @@
       <artifactId>junit-vintage-engine</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-api</artifactId>
+      <scope>test</scope>
+    </dependency>
     <dependency>
       <groupId>javax.servlet</groupId>
       <artifactId>servlet-api</artifactId>
diff --git 
a/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java 
b/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
index 7fc80504..257c55c9 100644
--- a/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
+++ b/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
@@ -17,20 +17,18 @@
 
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
-
-import org.junit.Assert;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
-import org.junit.Test;
-
 import org.apache.commons.fileupload.MultipartStream.MalformedStreamException;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.junit.Test;
 
 /**
  * Tests {@link org.apache.commons.fileupload.MultipartStream}.
@@ -94,12 +92,7 @@ public class MultipartStreamTest {
 
         final MockHttpServletRequest req = new MockHttpServletRequest(
                 request.getBytes("US-ASCII"), Constants.CONTENT_TYPE);
-        try {
-            upload.parseRequest(req);
-            fail("Expected exception.");
-        } catch (final FileUploadBase.IOFileUploadException e) {
-            // Expected
-        }
+        assertThrows(FileUploadBase.IOFileUploadException.class, () -> 
upload.parseRequest(req));
     }
 
     @Test
@@ -122,12 +115,7 @@ public class MultipartStreamTest {
 
         final MockHttpServletRequest req = new MockHttpServletRequest(
                 request.toString().getBytes("US-ASCII"), 
Constants.CONTENT_TYPE);
-        try {
-            upload.parseRequest(req);
-            fail("Expected exception.");
-        } catch (final FileUploadException e) {
-            // Expected
-            Assert.assertTrue(e.getCause() instanceof 
MalformedStreamException);
-        }
+        final FileUploadException e = assertThrows(FileUploadException.class, 
() -> upload.parseRequest(req));
+        assertInstanceOf(MalformedStreamException.class, e.getCause());
     }
 }

Reply via email to