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 76e93723e6d05374581f1f632f35bd195bb3e617
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 18:45:47 2026 +0000

    CAMEL-21196: modernize exception-based assertions in camel-sjms
---
 .../component/sjms/producer/QueueProducerQoSTest.java      | 14 ++++++--------
 .../sjms/tx/TransactedQueueInOutProducerTest.java          | 10 ++++------
 .../component/sjms/tx/TransactedQueueProducerTest.java     | 10 ++++------
 .../component/sjms/tx/TransactedTopicProducerTest.java     | 10 ++++------
 4 files changed, 18 insertions(+), 26 deletions(-)

diff --git 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
index f951d7205239..493b479301eb 100644
--- 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
+++ 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/producer/QueueProducerQoSTest.java
@@ -35,7 +35,7 @@ import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class QueueProducerQoSTest extends CamelTestSupport {
 
@@ -82,14 +82,12 @@ public class QueueProducerQoSTest extends CamelTestSupport {
         String endpoint = 
String.format("sjms:queue:%s?timeToLive=1000&exchangePattern=InOut&requestTimeout=500",
                 TEST_INOUT_DESTINATION_NAME);
 
-        try {
+        // we are expecting an exception here because there are no consumers 
on this queue,
+        // so we will not be able to do a real InOut/request-response, but 
that's okay
+        // we're just interested in the message becoming expired
+        assertThrows(Exception.class, () -> {
             template.requestBody(endpoint, "test message");
-            fail("we aren't expecting any consumers, so should not succeed");
-        } catch (Exception e) {
-            // we are expecting an exception here because there are no 
consumers on this queue,
-            // so we will not be able to do a real InOut/request-response, but 
that's okay
-            // we're just interested in the message becoming expired
-        }
+        });
 
         MockEndpoint.assertIsSatisfied(context);
 
diff --git 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueInOutProducerTest.java
 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueInOutProducerTest.java
index 603ad4d6b61c..ab37ba3be1ad 100644
--- 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueInOutProducerTest.java
+++ 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueInOutProducerTest.java
@@ -33,7 +33,7 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class TransactedQueueInOutProducerTest extends CamelTestSupport {
 
@@ -48,12 +48,10 @@ public class TransactedQueueInOutProducerTest extends 
CamelTestSupport {
         getMockEndpoint("mock:result").expectedBodiesReceived("Hello World 2");
         getMockEndpoint("mock:result2").expectedBodiesReceived("Changed Hello 
World 2");
 
-        try {
+        // expected
+        assertThrows(Exception.class, () -> {
             template.sendBodyAndHeader("direct:start", "Hello World 1", 
"isfailed", true);
-            fail("Should fail");
-        } catch (Exception e) {
-            // expected
-        }
+        });
         template.sendBodyAndHeader("direct:start", "Hello World 2", 
"isfailed", false);
 
         MockEndpoint.assertIsSatisfied(context);
diff --git 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueProducerTest.java
 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueProducerTest.java
index dada924b4601..968ee05ed600 100644
--- 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueProducerTest.java
+++ 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedQueueProducerTest.java
@@ -32,7 +32,7 @@ import org.apache.camel.test.junit5.CamelTestSupport;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.extension.RegisterExtension;
 
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class TransactedQueueProducerTest extends CamelTestSupport {
 
@@ -47,12 +47,10 @@ public class TransactedQueueProducerTest extends 
CamelTestSupport {
         getMockEndpoint("mock:result").expectedBodiesReceived("Hello World 2");
         getMockEndpoint("mock:result2").expectedBodiesReceived("Hello World 
2");
 
-        try {
+        // expected
+        assertThrows(Exception.class, () -> {
             template.sendBodyAndHeader("direct:start", "Hello World 1", 
"isfailed", true);
-            fail("Should fail");
-        } catch (Exception e) {
-            // expected
-        }
+        });
         template.sendBodyAndHeader("direct:start", "Hello World 2", 
"isfailed", false);
 
         MockEndpoint.assertIsSatisfied(context);
diff --git 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedTopicProducerTest.java
 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedTopicProducerTest.java
index 6a8f7afd0d70..7e4f8ccbc47e 100644
--- 
a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedTopicProducerTest.java
+++ 
b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/tx/TransactedTopicProducerTest.java
@@ -28,7 +28,7 @@ import org.apache.camel.component.sjms.SjmsComponent;
 import org.apache.camel.component.sjms.support.JmsTestSupport;
 import org.junit.jupiter.api.Test;
 
-import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class TransactedTopicProducerTest extends JmsTestSupport {
 
@@ -45,12 +45,10 @@ public class TransactedTopicProducerTest extends 
JmsTestSupport {
         MockEndpoint mock = getMockEndpoint("mock:result");
         mock.expectedBodiesReceived("Hello World 2");
 
-        try {
+        // expected
+        assertThrows(Exception.class, () -> {
             template.sendBodyAndHeader("direct:start", "Hello World 1", 
"isfailed", true);
-            fail("Should throw exception");
-        } catch (Exception e) {
-            // expected
-        }
+        });
         template.sendBodyAndHeader("direct:start", "Hello World 2", 
"isfailed", false);
 
         mock.assertIsSatisfied();

Reply via email to