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

garydgregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-codec.git

commit b3b6220424ea5b72594a1fc18eda5870bd782de1
Author: Gary Gregory <[email protected]>
AuthorDate: Thu Sep 24 09:10:12 2026 +0000

    Refactor RFC1522CodecTest as a @ParameterizedTest
---
 .../apache/commons/codec/net/RFC1522CodecTest.java | 48 ++++++++++++----------
 1 file changed, 27 insertions(+), 21 deletions(-)

diff --git a/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java 
b/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java
index 82137a23..349bf4b0 100644
--- a/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java
+++ b/src/test/java/org/apache/commons/codec/net/RFC1522CodecTest.java
@@ -25,6 +25,8 @@ import java.nio.charset.StandardCharsets;
 import org.apache.commons.codec.CharEncoding;
 import org.apache.commons.codec.DecoderException;
 import org.junit.jupiter.api.Test;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.ValueSource;
 
 /**
  * RFC 1522 compliant codec test cases
@@ -51,30 +53,35 @@ class RFC1522CodecTest {
         protected String getEncoding() {
             return "T";
         }
-
     }
 
-    private void assertExpectedDecoderException(final String s) {
-        assertThrows(DecoderException.class, () -> new 
RFC1522TestCodec().decodeText(s));
+    static void assertExpectedDecoderException(final String text) {
+        assertThrows(DecoderException.class, () -> new 
RFC1522TestCodec().decodeText(text));
     }
 
-    @Test
-    void testDecodeInvalid() throws Exception {
-        assertExpectedDecoderException("whatever");
-        assertExpectedDecoderException("=?");
-        assertExpectedDecoderException("?=");
-        assertExpectedDecoderException("==");
-        assertExpectedDecoderException("=??=");
-        assertExpectedDecoderException("=?stuff?=");
-        assertExpectedDecoderException("=?UTF-8??=");
-        assertExpectedDecoderException("=?UTF-8?stuff?=");
-        assertExpectedDecoderException("=?UTF-8?T?stuff");
-        assertExpectedDecoderException("=??T?stuff?=");
-        assertExpectedDecoderException("=?UTF-8??stuff?=");
-        assertExpectedDecoderException("=?UTF-8?W?stuff?=");
-        assertExpectedDecoderException("=?UTF-8?T?stuff?more?=");
-        assertExpectedDecoderException("=?UTF-8?T?stuff??=");
-        assertExpectedDecoderException("=?UTF-8?T???=");
+    @ParameterizedTest
+    // @formatter:off
+    @ValueSource(strings = {
+        "whatever",
+        "=?",
+        "?=",
+        "==",
+        "=?=",
+        "=??=",
+        "=?stuff?=",
+        "=?UTF-8??=",
+        "=?UTF-8?stuff?=",
+        "=?UTF-8?T?stuff",
+        "=??T?stuff?=",
+        "=?UTF-8??stuff?=",
+        "=?UTF-8?W?stuff?=",
+        "=?UTF-8?T?stuff?more?=",
+        "=?UTF-8?T?stuff??=",
+        "=?UTF-8?T???="
+    })
+    // @formatter:on
+    void testDecodeInvalid(final String text) throws Exception {
+        assertExpectedDecoderException(text);
     }
 
     @Test
@@ -83,5 +90,4 @@ class RFC1522CodecTest {
         assertNull(testCodec.decodeText(null));
         assertNull(testCodec.encodeText(null, CharEncoding.UTF_8));
     }
-
 }

Reply via email to