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 1ddb04e12065ea4d747372c6c74ae0aa294c35df
Author: Otavio R. Piske <[email protected]>
AuthorDate: Sat Jan 24 08:47:23 2026 +0100

    CAMEL-21196: modernize exception-based assertions in camel-http
    
    Signed-off-by: Otavio R. Piske <[email protected]>
---
 .../org/apache/camel/component/http/HeaderFilteringTest.java |  8 ++------
 .../apache/camel/component/http/HttpPollingConsumerTest.java | 12 +++++-------
 2 files changed, 7 insertions(+), 13 deletions(-)

diff --git 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java
 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java
index c0279264aa50..a10d17ef2cd2 100644
--- 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java
+++ 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HeaderFilteringTest.java
@@ -41,7 +41,7 @@ import static 
com.github.dockerjava.zerodep.shaded.org.apache.hc.core5.http.Cont
 import static org.apache.camel.component.http.HttpMethods.POST;
 import static org.apache.hc.core5.http.HttpHeaders.HOST;
 import static org.assertj.core.api.Assertions.assertThat;
-import static org.assertj.core.api.Assertions.fail;
+import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
 
 public class HeaderFilteringTest {
 
@@ -69,11 +69,7 @@ public class HeaderFilteringTest {
         exchange.setIn(in);
 
         producer.start();
-        try {
-            producer.process(exchange);
-        } catch (final HttpOperationFailedException e) {
-            fail(e.getMessage() + "\n%s", e.getResponseBody());
-        }
+        assertDoesNotThrow(() -> producer.process(exchange), "Should not haven 
thrown exception");
         producer.stop();
         context.stop();
     }
diff --git 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
index e2092d6f6fe4..e4467b192673 100644
--- 
a/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
+++ 
b/components/camel-http/src/test/java/org/apache/camel/component/http/HttpPollingConsumerTest.java
@@ -27,7 +27,7 @@ import org.junit.jupiter.api.Test;
 import static org.apache.camel.component.http.HttpMethods.GET;
 import static org.apache.camel.test.junit5.TestSupport.assertIsInstanceOf;
 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 HttpPollingConsumerTest extends BaseHttpTest {
 
@@ -88,11 +88,9 @@ public class HttpPollingConsumerTest extends BaseHttpTest {
 
     @Test
     public void testReceiveTimeoutTriggered() {
-        try {
-            consumer.receiveBody(endpointUrl + "/", 250, String.class);
-            fail("Should have thrown an exception");
-        } catch (RuntimeCamelException e) {
-            assertIsInstanceOf(SocketTimeoutException.class, e.getCause());
-        }
+        RuntimeCamelException ex = assertThrows(RuntimeCamelException.class,
+                () -> consumer.receiveBody(endpointUrl + "/", 250, 
String.class),
+                "Should have thrown exception");
+        assertIsInstanceOf(SocketTimeoutException.class, ex.getCause());
     }
 }

Reply via email to