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 b64a59c08f782e381fc48504f48941457e12bb8a
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 19:21:23 2026 +0000

    CAMEL-21196: modernize exception-based assertions in camel-jpa
    
    Replace try-catch-fail pattern with assertThrows in JpaProducerNoBodyTest.
---
 .../apache/camel/processor/jpa/JpaProducerNoBodyTest.java    | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git 
a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerNoBodyTest.java
 
b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerNoBodyTest.java
index 89c595bacbc4..c8a007177db5 100644
--- 
a/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerNoBodyTest.java
+++ 
b/components/camel-jpa/src/test/java/org/apache/camel/processor/jpa/JpaProducerNoBodyTest.java
@@ -23,19 +23,17 @@ import org.apache.camel.examples.SendEmail;
 import org.junit.jupiter.api.Test;
 
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class JpaProducerNoBodyTest extends AbstractJpaTest {
     protected static final String SELECT_ALL_STRING = "select x from " + 
SendEmail.class.getName() + " x";
 
     @Test
     public void testRouteJpa() {
-        try {
-            template.sendBody("direct:start", null);
-            fail("Should have thrown an exception");
-        } catch (CamelExecutionException e) {
-            assertIsInstanceOf(InvalidPayloadRuntimeException.class, 
e.getCause());
-        }
+        CamelExecutionException e = assertThrows(CamelExecutionException.class,
+                () -> template.sendBody("direct:start", null),
+                "Should have thrown an exception");
+        assertIsInstanceOf(InvalidPayloadRuntimeException.class, e.getCause());
     }
 
     @Override

Reply via email to