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 dd2d9bd94f43c7bbfa5ccf64e99c720734ecab41
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 18:42:54 2026 +0000

    CAMEL-21196: modernize exception-based assertions in camel-mllp
---
 ...nAndHeaderRequiresClientAuthenticationTest.java |  8 +++----
 .../internal/MllpSocketBufferReadFromTest.java     | 26 +++++++++-------------
 .../mllp/internal/MllpSocketBufferTest.java        | 10 ++++-----
 .../TransactionalClientDataSourceAsyncTest.java    |  2 +-
 ...sactionalClientDataSourceNotTransactedTest.java |  2 +-
 .../TransactionalClientDataSourceTest.java         |  2 +-
 ...ctionalClientDataSourceWithOnExceptionTest.java |  2 +-
 .../TransactionalClientWithRollbackTest.java       |  2 +-
 .../SpringCamelContextStartingFailedEventTest.java |  2 +-
 .../spring/processor/SpringFilterNoChildTest.java  |  2 +-
 10 files changed, 25 insertions(+), 33 deletions(-)

diff --git 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMutualTlsConnectionAndHeaderRequiresClientAuthenticationTest.java
 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMutualTlsConnectionAndHeaderRequiresClientAuthenticationTest.java
index 4a63d482d9c5..de0890a22cee 100644
--- 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMutualTlsConnectionAndHeaderRequiresClientAuthenticationTest.java
+++ 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/MllpMutualTlsConnectionAndHeaderRequiresClientAuthenticationTest.java
@@ -37,12 +37,10 @@ class 
MllpMutualTlsConnectionAndHeaderRequiresClientAuthenticationTest extends M
      */
     @Test
     void 
testSendingTlsWithNoClientCertificateToMllpConsumerWhichRequiresClientAuthentication()
 {
-        try {
+        CamelExecutionException e = 
Assertions.assertThrows(CamelExecutionException.class, () -> {
             template.sendBody(assembleEndpointUri(WITH_ONLY_TRUSTSTORE), 
TEST_PAYLOAD);
-            Assertions.fail("Should not be able to connect without a client 
certificate");
-        } catch (CamelExecutionException e) {
-            Assertions.assertInstanceOf(SSLHandshakeException.class, 
e.getCause().getCause().getCause());
-        }
+        });
+        Assertions.assertInstanceOf(SSLHandshakeException.class, 
e.getCause().getCause().getCause());
     }
 
     /**
diff --git 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java
 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java
index 7ac2c8f4d5dd..e5f07e68b740 100644
--- 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java
+++ 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferReadFromTest.java
@@ -24,7 +24,7 @@ import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertNull;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 /**
  * Tests for the class.
@@ -52,14 +52,12 @@ public class MllpSocketBufferReadFromTest extends 
SocketBufferTestSupport {
         inputStreamStub
                 .addPacket(new SocketTimeoutException("Fake Timeout 
Exception"));
 
-        try {
-            endpoint.setReceiveTimeout(500);
-            endpoint.setReadTimeout(100);
+        endpoint.setReceiveTimeout(500);
+        endpoint.setReadTimeout(100);
+        assertThrows(SocketTimeoutException.class, () -> {
             instance.readFrom(socketStub);
-            fail("Should have thrown and exception");
-        } catch (SocketTimeoutException expectedEx) {
-            assertNull(instance.toByteArray());
-        }
+        });
+        assertNull(instance.toByteArray());
     }
 
     /**
@@ -74,13 +72,11 @@ public class MllpSocketBufferReadFromTest extends 
SocketBufferTestSupport {
                 .addPacket("BAR".getBytes())
                 .addPacket(new SocketTimeoutException("Fake Timeout 
Exception"));
 
-        try {
-            endpoint.setReceiveTimeout(500);
-            endpoint.setReadTimeout(100);
+        endpoint.setReceiveTimeout(500);
+        endpoint.setReadTimeout(100);
+        assertThrows(SocketTimeoutException.class, () -> {
             instance.readFrom(socketStub);
-            fail("Should have thrown and exception");
-        } catch (SocketTimeoutException expectedEx) {
-            assertNull(instance.toByteArray());
-        }
+        });
+        assertNull(instance.toByteArray());
     }
 }
diff --git 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java
 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java
index 52cbeff91d25..5bb3cc012567 100644
--- 
a/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java
+++ 
b/components/camel-mllp/src/test/java/org/apache/camel/component/mllp/internal/MllpSocketBufferTest.java
@@ -23,8 +23,8 @@ import static 
org.junit.jupiter.api.Assertions.assertArrayEquals;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertFalse;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertTrue;
-import static org.junit.jupiter.api.Assertions.fail;
 
 /**
  * Tests for the MllpSocketBuffer class.
@@ -36,12 +36,10 @@ public class MllpSocketBufferTest extends 
SocketBufferTestSupport {
      */
     @Test
     public void testConstructorWithNullEndpoing() {
-        try {
+        IllegalArgumentException expectedEx = 
assertThrows(IllegalArgumentException.class, () -> {
             new MllpSocketBuffer(null);
-            fail("Constructor should have thrown an exception with a null 
Endpoint argument");
-        } catch (IllegalArgumentException expectedEx) {
-            assertEquals("MllpEndpoint cannot be null", 
expectedEx.getMessage());
-        }
+        });
+        assertEquals("MllpEndpoint cannot be null", expectedEx.getMessage());
     }
 
     /**
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceAsyncTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceAsyncTest.java
index caf0de4f4fad..1610bde47064 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceAsyncTest.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceAsyncTest.java
@@ -25,8 +25,8 @@ import org.apache.camel.spring.spi.SpringTransactionPolicy;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Unit test to demonstrate the transactional client pattern.
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceNotTransactedTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceNotTransactedTest.java
index f50acc8d087c..b6ea347702ab 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceNotTransactedTest.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceNotTransactedTest.java
@@ -22,8 +22,8 @@ import org.apache.camel.spring.SpringRouteBuilder;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Same route but not transacted
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
index adc7cfae1825..9549be8edaf1 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceTest.java
@@ -23,8 +23,8 @@ import org.apache.camel.spring.spi.SpringTransactionPolicy;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Unit test to demonstrate the transactional client pattern.
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java
index 93fa621b010a..f25b50f0ec15 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientDataSourceWithOnExceptionTest.java
@@ -24,8 +24,8 @@ import org.apache.camel.spring.spi.SpringTransactionPolicy;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Unit test to demonstrate the transactional client pattern.
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithRollbackTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithRollbackTest.java
index 72af2771fc18..18b2d557d7d1 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithRollbackTest.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/interceptor/TransactionalClientWithRollbackTest.java
@@ -31,8 +31,8 @@ import 
org.springframework.context.support.ClassPathXmlApplicationContext;
 import org.springframework.jdbc.core.JdbcTemplate;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 /**
  * Transactional client test with rollback in the DSL.
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java
index 2bbf66b5d289..67bd8c6c7a67 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/management/SpringCamelContextStartingFailedEventTest.java
@@ -25,8 +25,8 @@ import org.junit.jupiter.api.condition.OS;
 import org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 @DisabledOnOs(OS.AIX)
 public class SpringCamelContextStartingFailedEventTest extends 
SpringTestSupport {
diff --git 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java
 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java
index fdee058d2c9a..16d09cbf4134 100644
--- 
a/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java
+++ 
b/components/camel-spring-parent/camel-spring-xml/src/test/java/org/apache/camel/spring/processor/SpringFilterNoChildTest.java
@@ -24,8 +24,8 @@ import 
org.springframework.context.support.AbstractXmlApplicationContext;
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class SpringFilterNoChildTest extends SpringTestSupport {
 

Reply via email to