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

orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit d08757e3220c9137933d2f77f470e7504e869777
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 19:44:51 2026 +0000

    CAMEL-21196: modernize exception-based assertions in camel-jt400
    
    Replace try-catch-fail patterns with assertThrows in test classes to use
    modern JUnit 5 exception testing approach, improving code clarity and 
consistency.
---
 .../jt400/Jt400ComponentDefaultConnectionPoolTest.java     | 14 +++++---------
 .../Jt400ComponentDefaultSecureConnectionPoolTest.java     | 14 +++++---------
 .../apache/camel/component/jt400/Jt400ComponentTest.java   | 10 +++-------
 3 files changed, 13 insertions(+), 25 deletions(-)

diff --git 
a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultConnectionPoolTest.java
 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultConnectionPoolTest.java
index f87b76aeb1df..7cfd47d331b0 100644
--- 
a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultConnectionPoolTest.java
+++ 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultConnectionPoolTest.java
@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class Jt400ComponentDefaultConnectionPoolTest extends Jt400TestSupport {
     private Jt400Component component;
@@ -30,14 +30,10 @@ public class Jt400ComponentDefaultConnectionPoolTest 
extends Jt400TestSupport {
     public void doPostSetup() {
         component = new Jt400Component();
         component.setCamelContext(context);
-        try {
-            // Use an invalid object type so that endpoints are never created
-            // and actual connections are never requested
-            
component.createEndpoint("jt400://user:password@host/qsys.lib/library.lib/program.xxx");
-            fail("Should have thrown exception");
-        } catch (Exception e) {
-            /* Expected */
-        }
+        // Use an invalid object type so that endpoints are never created
+        // and actual connections are never requested
+        assertThrows(Exception.class,
+                () -> 
component.createEndpoint("jt400://user:password@host/qsys.lib/library.lib/program.xxx"));
     }
 
     @Override
diff --git 
a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java
 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java
index 6390df1d601a..6816f2ab10a9 100644
--- 
a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java
+++ 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentDefaultSecureConnectionPoolTest.java
@@ -21,7 +21,7 @@ import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class Jt400ComponentDefaultSecureConnectionPoolTest extends 
Jt400TestSupport {
     private Jt400Component component;
@@ -30,14 +30,10 @@ public class Jt400ComponentDefaultSecureConnectionPoolTest 
extends Jt400TestSupp
     public void doPostSetup() {
         component = new Jt400Component();
         component.setCamelContext(context);
-        try {
-            // Use an invalid object type so that endpoints are never created
-            // and actual connections are never requested
-            
component.createEndpoint("jt400://user:password@host/qsys.lib/library.lib/program.xxx?secured=true");
-            fail("Should have thrown exception");
-        } catch (Exception e) {
-            /* Expected */
-        }
+        // Use an invalid object type so that endpoints are never created
+        // and actual connections are never requested
+        assertThrows(Exception.class,
+                () -> 
component.createEndpoint("jt400://user:password@host/qsys.lib/library.lib/program.xxx?secured=true"));
     }
 
     @Override
diff --git 
a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
index a05128fd4ee3..c67d437bf7a7 100644
--- 
a/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
+++ 
b/components/camel-jt400/src/test/java/org/apache/camel/component/jt400/Jt400ComponentTest.java
@@ -20,8 +20,8 @@ import org.apache.camel.Endpoint;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Test case for {@link Jt400Component}
@@ -63,12 +63,8 @@ public class Jt400ComponentTest extends Jt400TestSupport {
      */
     @Test
     public void testCreateEndpointForOtherObjectType() {
-        try {
-            
component.createEndpoint("jt400://user:password@host/qsys.lib/library.lib/program.xxx");
-            fail("Exception should been thrown when trying to create an 
endpoint for an unsupported object type");
-        } catch (Exception e) {
-            // this is just what we expected
-        }
+        assertThrows(Exception.class,
+                () -> 
component.createEndpoint("jt400://user:password@host/qsys.lib/library.lib/program.xxx"));
     }
 
     /**

Reply via email to