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 049b6270019f6b320821368c776f021843afcc24
Author: Otavio Rodolfo Piske <[email protected]>
AuthorDate: Sat Jan 24 19:56:02 2026 +0000

    CAMEL-21196: modernize exception-based assertions in 
camel-platform-http-vertx
    
    Replace try-catch-fail patterns with JUnit 5 assertThrows for modernized 
exception testing.
---
 ...PlatformHttpRestOpenApiConsumerRestDslTest.java | 31 +++++++++-----------
 .../vertx/PlatformHttpRestOpenApiConsumerTest.java | 33 ++++++++++------------
 2 files changed, 29 insertions(+), 35 deletions(-)

diff --git 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
index a242fca8ed36..e320de9ed0f2 100644
--- 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
+++ 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerRestDslTest.java
@@ -21,13 +21,13 @@ import java.io.FileInputStream;
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.util.IOHelper;
-import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 import static io.restassured.RestAssured.given;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.equalToCompressingWhiteSpace;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class PlatformHttpRestOpenApiConsumerRestDslTest {
 
@@ -134,22 +134,19 @@ public class PlatformHttpRestOpenApiConsumerRestDslTest {
         final CamelContext context = 
VertxPlatformHttpEngineTest.createCamelContext();
 
         try {
-            context.addRoutes(new RouteBuilder() {
-                @Override
-                public void configure() {
-                    rest().openApi("openapi-v3.json");
-
-                    from("direct:getPetById")
-                            .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
-                }
-            });
-
-            context.start();
-            fail();
-        } catch (Exception e) {
-            Assertions.assertTrue(
-                    e.getCause().getMessage()
-                            .startsWith("OpenAPI specification has 18 unmapped 
operations to corresponding routes"));
+            assertThrows(Exception.class, () -> {
+                context.addRoutes(new RouteBuilder() {
+                    @Override
+                    public void configure() {
+                        rest().openApi("openapi-v3.json");
+
+                        from("direct:getPetById")
+                                .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
+                    }
+                });
+
+                context.start();
+            }, "OpenAPI specification has 18 unmapped operations to 
corresponding routes");
         } finally {
             context.stop();
         }
diff --git 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
index 8bf85c8d23a1..e494ff86b058 100644
--- 
a/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
+++ 
b/components/camel-platform-http-vertx/src/test/java/org/apache/camel/component/platform/http/vertx/PlatformHttpRestOpenApiConsumerTest.java
@@ -19,12 +19,12 @@ package org.apache.camel.component.platform.http.vertx;
 import org.apache.camel.CamelContext;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
-import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
 import static io.restassured.RestAssured.given;
 import static org.hamcrest.Matchers.equalTo;
 import static org.hamcrest.Matchers.equalToCompressingWhiteSpace;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
 public class PlatformHttpRestOpenApiConsumerTest {
 
@@ -136,23 +136,20 @@ public class PlatformHttpRestOpenApiConsumerTest {
         final CamelContext context = 
VertxPlatformHttpEngineTest.createCamelContext();
 
         try {
-            context.addRoutes(new RouteBuilder() {
-                @Override
-                public void configure() {
-                    
from("rest-openapi:classpath:openapi-v3.json?missingOperation=fail")
-                            .log("dummy");
-
-                    from("direct:getPetById")
-                            .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
-                }
-            });
-
-            context.start();
-            fail();
-        } catch (Exception e) {
-            Assertions.assertTrue(
-                    e.getCause().getMessage()
-                            .startsWith("OpenAPI specification has 18 unmapped 
operations to corresponding routes"));
+            assertThrows(Exception.class, () -> {
+                context.addRoutes(new RouteBuilder() {
+                    @Override
+                    public void configure() {
+                        
from("rest-openapi:classpath:openapi-v3.json?missingOperation=fail")
+                                .log("dummy");
+
+                        from("direct:getPetById")
+                                .setBody().constant("{\"pet\": \"tony the 
tiger\"}");
+                    }
+                });
+
+                context.start();
+            }, "OpenAPI specification has 18 unmapped operations to 
corresponding routes");
         } finally {
             context.stop();
         }

Reply via email to