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 2740fe5a55778039ddbebae1175812eea5151c3f
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 18:23:35 2026 +0000

    CAMEL-21196: modernize exception-based assertions in camel-xmlsecurity
    
    Convert fail() calls to assertEquals() with lambda message suppliers in
    XmlSignatureTest.java checkThrownException() method. This modernizes
    the exception validation logic to use JUnit 5 best practices.
    
    - Replace fail() with assertEquals() comparing expected and actual 
exception classes
    - Use lambda message suppliers for lazy evaluation of error messages
    - Remove unused fail() import
---
 .../camel/component/xmlsecurity/XmlSignatureTest.java    | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git 
a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java
 
b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java
index f9d5c39f7c0a..6f2dab85e5c4 100644
--- 
a/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java
+++ 
b/components/camel-xmlsecurity/src/test/java/org/apache/camel/component/xmlsecurity/XmlSignatureTest.java
@@ -108,7 +108,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNotNull;
 import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 public class XmlSignatureTest extends CamelTestSupport {
 
@@ -1341,21 +1340,18 @@ public class XmlSignatureTest extends CamelTestSupport {
             throws Exception {
         Exception e = (Exception) 
mock.getExchanges().get(0).getProperty(Exchange.EXCEPTION_CAUGHT);
         assertNotNull(e, "Expected excpetion " + cl.getName() + " missing");
-        if (e.getClass() != cl) {
-            String stackTrace = ExceptionHelper.stackTraceToString(e);
-            fail("Exception  " + cl.getName() + " excpected, but was " + 
e.getClass().getName() + ": " + stackTrace);
-        }
+        assertEquals(cl, e.getClass(),
+                () -> "Exception  " + cl.getName() + " excpected, but was " + 
e.getClass().getName() + ": "
+                      + ExceptionHelper.stackTraceToString(e));
         if (expectedMessage != null) {
             assertEquals(expectedMessage, e.getMessage());
         }
         if (expectedCauseClass != null) {
             Throwable cause = e.getCause();
             assertNotNull(cause, "Expected cause exception" + 
expectedCauseClass.getName() + " missing");
-            if (expectedCauseClass != cause.getClass()) {
-                fail("Cause exception " + expectedCauseClass.getName() + " 
expected, but was " + cause.getClass().getName()
-                     + ": "
-                     + ExceptionHelper.stackTraceToString(e));
-            }
+            assertEquals(expectedCauseClass, cause.getClass(),
+                    () -> "Cause exception " + expectedCauseClass.getName() + 
" expected, but was "
+                          + cause.getClass().getName() + ": " + 
ExceptionHelper.stackTraceToString(e));
         }
     }
 

Reply via email to