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


The following commit(s) were added to refs/heads/1.x by this push:
     new 99c1ab56 Port to JUnit 5
99c1ab56 is described below

commit 99c1ab560699bc4297463d84b6c0c27a8ecd41cf
Author: Gary Gregory <[email protected]>
AuthorDate: Fri Jan 2 09:15:58 2026 -0500

    Port to JUnit 5
---
 pom.xml                                            |  9 +++-
 src/changes/changes.xml                            |  1 +
 .../commons/fileupload/DefaultFileItemTest.java    |  8 +--
 .../fileupload/DiskFileItemSerializeTest.java      | 40 +++++++--------
 .../commons/fileupload/DiskFileUploadTest.java     | 11 ++--
 .../commons/fileupload/FileItemHeadersTest.java    |  7 +--
 .../apache/commons/fileupload/FileUploadTest.java  | 58 ++++++++++------------
 .../commons/fileupload/MultipartStreamTest.java    |  7 ++-
 .../commons/fileupload/ParameterParserTest.java    |  5 +-
 .../commons/fileupload/ProgressListenerTest.java   |  6 +--
 .../commons/fileupload/RFC2231UtilityTestCase.java | 10 ++--
 .../org/apache/commons/fileupload/SizesTest.java   |  9 +---
 .../apache/commons/fileupload/StreamingTest.java   |  7 +--
 .../fileupload/portlet/PortletFileUploadTest.java  |  9 ++--
 .../fileupload/servlet/ServletFileUploadTest.java  |  7 ++-
 .../fileupload/util/mime/MimeUtilityTestCase.java  |  8 +--
 .../util/mime/QuotedPrintableDecoderTestCase.java  | 12 ++---
 17 files changed, 92 insertions(+), 122 deletions(-)

diff --git a/pom.xml b/pom.xml
index 2b964771..fb6c1648 100644
--- a/pom.xml
+++ b/pom.xml
@@ -89,8 +89,13 @@
   </properties>
   <dependencies>
     <dependency>
-      <groupId>org.junit.vintage</groupId>
-      <artifactId>junit-vintage-engine</artifactId>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-engine</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.junit.jupiter</groupId>
+      <artifactId>junit-jupiter-params</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 58970eb0..ab2414ff 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -45,6 +45,7 @@ The <action> type attribute can be add,update,fix,remove.
       <!-- FIX -->
       <action type="fix" dev="markt" due-to="Coverity Scan">Better exception 
type and message if a multipart/mixed part is presented without a boundary 
defined</action>
       <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Apache RAT 
plugin console warnings.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Port to JUnit 
5.</action>
       <!-- ADD -->
       <!-- UPDATE -->
       <action type="update" dev="ggregory" due-to="Gary Gregory">Bump 
org.apache.commons:commons-parent from 84 to 93.</action>
diff --git 
a/src/test/java/org/apache/commons/fileupload/DefaultFileItemTest.java 
b/src/test/java/org/apache/commons/fileupload/DefaultFileItemTest.java
index 08e593e7..74ccb445 100644
--- a/src/test/java/org/apache/commons/fileupload/DefaultFileItemTest.java
+++ b/src/test/java/org/apache/commons/fileupload/DefaultFileItemTest.java
@@ -17,11 +17,7 @@
 
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.File;
 import java.io.IOException;
@@ -31,7 +27,7 @@ import java.util.Arrays;
 
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.SystemProperties;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link org.apache.commons.fileupload.DefaultFileItem}.
diff --git 
a/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java 
b/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java
index c6764b89..c6ff2b8f 100644
--- a/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java
+++ b/src/test/java/org/apache/commons/fileupload/DiskFileItemSerializeTest.java
@@ -17,10 +17,7 @@
 
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -34,9 +31,9 @@ import java.nio.file.InvalidPathException;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang3.SystemProperties;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Serialization Unit tests for {@link 
org.apache.commons.fileupload.disk.DiskFileItem}.
@@ -60,11 +57,11 @@ public class DiskFileItemSerializeTest {
      * Compare content bytes.
      */
     private void compareBytes(final String text, final byte[] origBytes, final 
byte[] newBytes) {
-        assertNotNull("origBytes must not be null", origBytes);
-        assertNotNull("newBytes must not be null", newBytes);
-        assertEquals(text + " byte[] length", origBytes.length, 
newBytes.length);
+        assertNotNull(origBytes, "origBytes must not be null");
+        assertNotNull(newBytes, "newBytes must not be null");
+        assertEquals(origBytes.length, newBytes.length, text + " byte[] 
length");
         for (int i = 0; i < origBytes.length; i++) {
-            assertEquals(text + " byte[" + i + "]", origBytes[i], newBytes[i]);
+            assertEquals(origBytes[i], newBytes[i], text + " byte[" + i + "]");
         }
     }
 
@@ -132,7 +129,7 @@ public class DiskFileItemSerializeTest {
         return baos;
     }
 
-    @Before
+    @BeforeEach
     public void setUp() throws Exception {
         if (REPO.exists()) {
             FileUtils.deleteDirectory(REPO);
@@ -140,7 +137,7 @@ public class DiskFileItemSerializeTest {
         FileUtils.forceMkdir(REPO);
     }
 
-    @After
+    @AfterEach
     public void tearDown() throws IOException {
         for (final File file : FileUtils.listFiles(REPO, null, true)) {
             System.out.println("Found leftover file " + file);
@@ -159,8 +156,8 @@ public class DiskFileItemSerializeTest {
         final byte[] testFieldValueBytes = createContentBytes(THRESHOLD + 1);
         final FileItem item = createFileItem(testFieldValueBytes);
         // Check state is as expected
-        assertFalse("Initial: in memory", item.isInMemory());
-        assertEquals("Initial: size", item.getSize(), 
testFieldValueBytes.length);
+        assertFalse(item.isInMemory(), "Initial: in memory");
+        assertEquals(testFieldValueBytes.length, item.getSize(), "Initial: 
size");
         compareBytes("Initial", item.get(), testFieldValueBytes);
         item.delete();
     }
@@ -194,8 +191,8 @@ public class DiskFileItemSerializeTest {
     private void testInMemoryObject(final byte[] testFieldValueBytes, final 
File repository) throws IOException {
         final FileItem item = createFileItem(testFieldValueBytes, repository);
         // Check state is as expected
-        assertTrue("Initial: in memory", item.isInMemory());
-        assertEquals("Initial: size", item.getSize(), 
testFieldValueBytes.length);
+        assertTrue(item.isInMemory(), "Initial: in memory");
+        assertEquals(testFieldValueBytes.length, item.getSize(), "Initial: 
size");
         compareBytes("Initial", item.get(), testFieldValueBytes);
         item.delete();
     }
@@ -203,25 +200,24 @@ public class DiskFileItemSerializeTest {
     /**
      * Test deserialization fails when repository is not valid.
      */
-    @Test(expected = IOException.class)
+    @Test
     public void testInvalidRepository() throws Exception {
         // Create the FileItem
         final byte[] testFieldValueBytes = createContentBytes(THRESHOLD);
         final File repository = new File(SystemProperties.getJavaIoTmpdir(), 
"file");
         final FileItem item = createFileItem(testFieldValueBytes, repository);
-        deserialize(serialize(item));
+        assertThrows(IOException.class, () -> deserialize(serialize(item)));
     }
 
     /**
      * Test deserialization fails when repository contains a null character.
      */
-    @Test(expected = InvalidPathException.class)
+    @Test
     public void testInvalidRepositoryWithNullChar() throws Exception {
         // Create the FileItem
         final byte[] testFieldValueBytes = createContentBytes(THRESHOLD);
         final File repository = new File(SystemProperties.getJavaIoTmpdir(), 
"\0");
-        final FileItem item = createFileItem(testFieldValueBytes, repository);
-        deserialize(serialize(item));
+        assertThrows(InvalidPathException.class, () -> 
createFileItem(testFieldValueBytes, repository));
     }
 
     /**
diff --git 
a/src/test/java/org/apache/commons/fileupload/DiskFileUploadTest.java 
b/src/test/java/org/apache/commons/fileupload/DiskFileUploadTest.java
index 9a4369b2..17c1638f 100644
--- a/src/test/java/org/apache/commons/fileupload/DiskFileUploadTest.java
+++ b/src/test/java/org/apache/commons/fileupload/DiskFileUploadTest.java
@@ -16,10 +16,7 @@
  */
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.jupiter.api.Assertions.assertThrows;
-import static org.junit.jupiter.api.Assertions.assertThrowsExactly;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.File;
 import java.util.List;
@@ -27,8 +24,8 @@ import java.util.List;
 import javax.servlet.http.HttpServletRequest;
 
 import org.apache.commons.fileupload.disk.DiskFileItem;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for {@link DiskFileUpload}. Remove when deprecated class is removed.
@@ -40,7 +37,7 @@ public class DiskFileUploadTest {
 
     private DiskFileUpload upload;
 
-    @Before
+    @BeforeEach
     public void setUp() {
         upload = new DiskFileUpload();
     }
diff --git 
a/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java 
b/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
index ea911a27..b881c429 100644
--- a/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
+++ b/src/test/java/org/apache/commons/fileupload/FileItemHeadersTest.java
@@ -16,15 +16,12 @@
  */
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Iterator;
 
 import org.apache.commons.fileupload.util.FileItemHeadersImpl;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests {@link FileItemHeaders} and
diff --git a/src/test/java/org/apache/commons/fileupload/FileUploadTest.java 
b/src/test/java/org/apache/commons/fileupload/FileUploadTest.java
index b205d184..803eb424 100644
--- a/src/test/java/org/apache/commons/fileupload/FileUploadTest.java
+++ b/src/test/java/org/apache/commons/fileupload/FileUploadTest.java
@@ -16,11 +16,7 @@
  */
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -28,18 +24,17 @@ import java.io.InputStream;
 import java.io.UnsupportedEncodingException;
 import java.nio.charset.StandardCharsets;
 import java.util.List;
+import java.util.stream.Stream;
 
 import org.apache.commons.fileupload.MultipartStream.IllegalBoundaryException;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.apache.commons.fileupload.portlet.PortletFileUploadTest;
+import org.apache.commons.fileupload.portlet.PortletFileUpload;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.fileupload.servlet.ServletFileUploadTest;
 import org.apache.commons.fileupload.util.Streams;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.MethodSource;
 
 /**
  * Common tests for implementations of {@link FileUpload}. This is a 
parameterized test.
@@ -50,23 +45,19 @@ import org.junit.runners.Parameterized.Parameters;
  * @see PortletFileUploadTest
  * @since 1.4
  */
-@RunWith(Parameterized.class)
 public class FileUploadTest {
 
+    private FileUpload upload = new ServletFileUpload(new 
DiskFileItemFactory());
+
     /**
      * @return {@link FileUpload} classes under test.
      */
-    @Parameters(name = "{0}")
-    public static Iterable<? extends Object> data() {
-        return Util.fileUploadImplementations();
+    public static Stream<FileUpload> data() {
+        return Stream.of(
+                new ServletFileUpload(new DiskFileItemFactory()),
+                new PortletFileUpload(new DiskFileItemFactory()));
     }
 
-    /**
-     * Current parameterized FileUpload.
-     */
-    @Parameter
-    public FileUpload upload;
-
     private void assertHeaders(final String[] headerNames, final String[] 
headerValues, final FileItem item, final int index) {
         for (int i = 0; i < headerNames.length; i++) {
             final String value = item.getHeaders().getHeader(headerNames[i]);
@@ -81,8 +72,9 @@ public class FileUploadTest {
     /**
      * Test for <a 
href="https://issues.apache.org/jira/browse/FILEUPLOAD-239";>FILEUPLOAD-239</a>.
      */
-    @Test
-    public void testContentTypeAttachment()
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testContentTypeAttachment(FileUpload upload)
             throws IOException, FileUploadException {
         final List<FileItem> fileItems = Util.parseUpload(upload,
                 "-----1234\r\n" +
@@ -118,8 +110,9 @@ public class FileUploadTest {
     /**
      * This is what the browser does if you submit the form without choosing a 
file.
      */
-    @Test
-    public void testEmptyFile()
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testEmptyFile(FileUpload upload)
             throws UnsupportedEncodingException, FileUploadException {
         final List<FileItem> fileItems = Util.parseUpload (upload,
                                                 "-----1234\r\n" +
@@ -135,8 +128,9 @@ public class FileUploadTest {
         assertEquals("", file.getName());
     }
 
-    @Test
-    public void testFilenameCaseSensitivity()
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testFilenameCaseSensitivity(FileUpload upload)
             throws IOException, FileUploadException {
         final List<FileItem> fileItems = Util.parseUpload(upload,
                                                "-----1234\r\n" +
@@ -153,8 +147,9 @@ public class FileUploadTest {
         assertEquals("FOO.tab", file.getName());
     }
 
-    @Test
-    public void testFileUpload()
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testFileUpload(FileUpload upload)
             throws IOException, FileUploadException {
         final List<FileItem> fileItems = Util.parseUpload(upload,
                                                "-----1234\r\n" +
@@ -204,8 +199,9 @@ public class FileUploadTest {
     /**
      * Tests <a 
href="https://issues.apache.org/jira/browse/FILEUPLOAD-130";>FILEUPLOAD-130</a>.
      */
-    @Test
-    public void testFileUpload130()
+    @ParameterizedTest
+    @MethodSource("data")
+    public void testFileUpload130(FileUpload upload)
             throws Exception {
         final String[] headerNames = {
             "SomeHeader", "OtherHeader", "YetAnotherHeader", "WhatAHeader"
diff --git 
a/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java 
b/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
index 0f164c79..b09a5b3e 100644
--- a/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
+++ b/src/test/java/org/apache/commons/fileupload/MultipartStreamTest.java
@@ -28,7 +28,7 @@ import java.io.InputStream;
 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;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests {@link org.apache.commons.fileupload.MultipartStream}.
@@ -87,15 +87,14 @@ public class MultipartStreamTest {
         assertInstanceOf(MalformedStreamException.class, e.getCause());
     }
 
-    @Test(expected = IllegalArgumentException.class)
+    @Test
     public void testSmallBuffer() throws Exception {
         final String strData = "foobar";
         final byte[] contents = strData.getBytes();
         final InputStream input = new ByteArrayInputStream(contents);
         final byte[] boundary = BOUNDARY_TEXT.getBytes();
         final int iBufSize = 1;
-        @SuppressWarnings("unused")
-        final MultipartStream unused = new MultipartStream(input, boundary, 
iBufSize, new MultipartStream.ProgressNotifier(null, contents.length));
+        assertThrows(IllegalArgumentException.class, () -> new 
MultipartStream(input, boundary, iBufSize, new 
MultipartStream.ProgressNotifier(null, contents.length)));
     }
 
     @Test
diff --git 
a/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java 
b/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java
index 09648aec..2ce308a3 100644
--- a/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java
+++ b/src/test/java/org/apache/commons/fileupload/ParameterParserTest.java
@@ -16,12 +16,11 @@
  */
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.Map;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests for {@link ParameterParser}.
diff --git 
a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java 
b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
index f2f526b9..0412f498 100644
--- a/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
+++ b/src/test/java/org/apache/commons/fileupload/ProgressListenerTest.java
@@ -17,16 +17,14 @@
 
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests the {@link ProgressListener}.
diff --git 
a/src/test/java/org/apache/commons/fileupload/RFC2231UtilityTestCase.java 
b/src/test/java/org/apache/commons/fileupload/RFC2231UtilityTestCase.java
index 47a442aa..3bb33c9b 100644
--- a/src/test/java/org/apache/commons/fileupload/RFC2231UtilityTestCase.java
+++ b/src/test/java/org/apache/commons/fileupload/RFC2231UtilityTestCase.java
@@ -16,13 +16,11 @@
  */
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.UnsupportedEncodingException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Tests {@link RFC2231Utility}.
@@ -37,9 +35,9 @@ public final class RFC2231UtilityTestCase {
         assertEquals(expected, RFC2231Utility.decodeText(encoded));
     }
 
-    @Test(expected = UnsupportedEncodingException.class)
+    @Test
     public void decodeInvalidEncoding() throws Exception {
-        RFC2231Utility.decodeText("abc'en'hello");
+        assertThrows(UnsupportedEncodingException.class, () -> 
RFC2231Utility.decodeText("abc'en'hello"));
     }
 
     @Test
diff --git a/src/test/java/org/apache/commons/fileupload/SizesTest.java 
b/src/test/java/org/apache/commons/fileupload/SizesTest.java
index 2303cff2..875fe1da 100644
--- a/src/test/java/org/apache/commons/fileupload/SizesTest.java
+++ b/src/test/java/org/apache/commons/fileupload/SizesTest.java
@@ -16,12 +16,7 @@
  */
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
@@ -36,7 +31,7 @@ import 
org.apache.commons.fileupload.MultipartStream.MalformedStreamException;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.fileupload.util.Streams;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for items with varying sizes.
diff --git a/src/test/java/org/apache/commons/fileupload/StreamingTest.java 
b/src/test/java/org/apache/commons/fileupload/StreamingTest.java
index fe88b8f1..e260abaa 100644
--- a/src/test/java/org/apache/commons/fileupload/StreamingTest.java
+++ b/src/test/java/org/apache/commons/fileupload/StreamingTest.java
@@ -16,10 +16,7 @@
  */
 package org.apache.commons.fileupload;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertInstanceOf;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -36,7 +33,7 @@ import 
org.apache.commons.fileupload.FileUploadBase.IOFileUploadException;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
 import org.apache.commons.fileupload.servlet.ServletFileUpload;
 import org.apache.commons.fileupload.servlet.ServletRequestContext;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Unit test for items with varying sizes.
diff --git 
a/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
 
b/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
index 760751b7..5bb6693c 100644
--- 
a/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
+++ 
b/src/test/java/org/apache/commons/fileupload/portlet/PortletFileUploadTest.java
@@ -17,8 +17,7 @@
 
 package org.apache.commons.fileupload.portlet;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
 import java.util.Map;
@@ -29,8 +28,8 @@ import org.apache.commons.fileupload.Constants;
 import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileUploadTest;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for {@link PortletFileUpload}.
@@ -76,7 +75,7 @@ public class PortletFileUploadTest {
         assertEquals(2, mappedParameters.get("multi").size());
     }
 
-    @Before
+    @BeforeEach
     public void setUp() {
         upload = new PortletFileUpload(new DiskFileItemFactory());
     }
diff --git 
a/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
 
b/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
index 01e76564..f4b4c7e4 100644
--- 
a/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
+++ 
b/src/test/java/org/apache/commons/fileupload/servlet/ServletFileUploadTest.java
@@ -16,8 +16,7 @@
  */
 package org.apache.commons.fileupload.servlet;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.util.List;
 import java.util.Map;
@@ -29,7 +28,7 @@ import org.apache.commons.fileupload.FileItem;
 import org.apache.commons.fileupload.FileUploadTest;
 import org.apache.commons.fileupload.MockHttpServletRequest;
 import org.apache.commons.fileupload.disk.DiskFileItemFactory;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Test for {@link ServletFileUpload}.
@@ -57,7 +56,7 @@ public class ServletFileUploadTest {
         final ServletFileUpload upload = new 
ServletFileUpload(fileItemFactory);
         final List<FileItem> fileItems = upload.parseRequest(request);
         final FileItem fileItem = fileItems.get(0);
-        assertTrue(fileItem.getString(), 
fileItem.getString().contains("co�te�t"));
+        assertTrue(fileItem.getString().contains("co�te�t"), 
fileItem.getString());
     }
 
 
diff --git 
a/src/test/java/org/apache/commons/fileupload/util/mime/MimeUtilityTestCase.java
 
b/src/test/java/org/apache/commons/fileupload/util/mime/MimeUtilityTestCase.java
index c19b859b..6521a39f 100644
--- 
a/src/test/java/org/apache/commons/fileupload/util/mime/MimeUtilityTestCase.java
+++ 
b/src/test/java/org/apache/commons/fileupload/util/mime/MimeUtilityTestCase.java
@@ -17,11 +17,11 @@
 
 package org.apache.commons.fileupload.util.mime;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.UnsupportedEncodingException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * Use the online <a 
href="https://dogmamix.com/MimeHeadersDecoder/";>MimeHeadersDecoder</a> to 
validate expected values.
@@ -34,9 +34,9 @@ public final class MimeUtilityTestCase {
         assertEquals(expected, MimeUtility.decodeText(encoded));
     }
 
-    @Test(expected = UnsupportedEncodingException.class)
+    @Test
     public void decodeInvalidEncoding() throws Exception {
-        MimeUtility.decodeText("=?invalid?B?xyz-?=");
+        assertThrows(UnsupportedEncodingException.class, () -> 
MimeUtility.decodeText("=?invalid?B?xyz-?="));
     }
 
     @Test
diff --git 
a/src/test/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoderTestCase.java
 
b/src/test/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoderTestCase.java
index 69e685d3..0fb072b6 100644
--- 
a/src/test/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoderTestCase.java
+++ 
b/src/test/java/org/apache/commons/fileupload/util/mime/QuotedPrintableDecoderTestCase.java
@@ -16,15 +16,13 @@
  */
 package org.apache.commons.fileupload.util.mime;
 
-import static org.junit.Assert.assertArrayEquals;
-import static org.junit.Assert.assertTrue;
-import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.*;
 
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 
 /**
  * @since 1.3
@@ -49,7 +47,7 @@ public final class QuotedPrintableDecoderTestCase {
         final byte[] encodedData = encoded.getBytes(US_ASCII_CHARSET);
         final IOException e = assertThrows(IOException.class, () -> 
QuotedPrintableDecoder.decode(encodedData, out));
         final String em = e.getMessage();
-        assertTrue("Expected to find " + messageText + " in '" + em + "'", 
em.contains(messageText));
+        assertTrue(em.contains(messageText), "Expected to find " + messageText 
+ " in '" + em + "'");
     }
 
     @Test
@@ -62,9 +60,9 @@ public final class QuotedPrintableDecoderTestCase {
         assertEncoded("", "");
     }
 
-    @Test(expected = IOException.class)
+    @Test
     public void invalidCharDecode() throws Exception {
-        assertEncoded("=\r\n", "=3D=XD=XA");
+        assertIOException("not a valid hex digit", "=3D=XD=XA");
     }
 
     @Test

Reply via email to