You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2025/07/21 08:09:01 UTC

(camel) 03/04: CAMEL-22251: Added unit test

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch vrest
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 64a34f6fcbd45372c7d0bb8d9e8157a55c28b6b3
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jul 21 10:01:53 2025 +0200

    CAMEL-22251: Added unit test
---
 components/camel-jetty/pom.xml                     |  6 +++++
 .../component/jetty/JettyEventNotifierTest.java    | 28 +++++++++++++---------
 2 files changed, 23 insertions(+), 11 deletions(-)

diff --git a/components/camel-jetty/pom.xml b/components/camel-jetty/pom.xml
index 5854e826dac..fc1dc861910 100644
--- a/components/camel-jetty/pom.xml
+++ b/components/camel-jetty/pom.xml
@@ -159,6 +159,12 @@
             <version>${squareup-okhttp-version}</version>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>io.rest-assured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <version>${rest-assured-version}</version>
+            <scope>test</scope>
+        </dependency>
 
         <dependency>
             <groupId>org.junit.jupiter</groupId>
diff --git a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEventNotifierTest.java b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEventNotifierTest.java
index b5f5e9e44f3..eadf3ca5806 100644
--- a/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEventNotifierTest.java
+++ b/components/camel-jetty/src/test/java/org/apache/camel/component/jetty/JettyEventNotifierTest.java
@@ -26,7 +26,8 @@ import org.apache.camel.support.EventNotifierSupport;
 import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 
-import static org.junit.jupiter.api.Assertions.assertEquals;
+import static io.restassured.RestAssured.given;
+import static org.hamcrest.Matchers.is;
 
 public class JettyEventNotifierTest extends BaseJettyTest {
 
@@ -48,9 +49,13 @@ public class JettyEventNotifierTest extends BaseJettyTest {
 
             context.start();
 
-            String out = template.requestBodyAndHeader("http://localhost:{{port}}/camel/ok", "Hello World",
-                    Exchange.HTTP_METHOD, "GET", String.class);
-            assertEquals("Bye World", out);
+            given()
+                    .port(getPort())
+                    .body("Hello World")
+                    .post("/camel/ok")
+                    .then()
+                    .statusCode(200)
+                    .body(is("Bye World"));
 
             Assertions.assertEquals(2, events.size());
             Assertions.assertEquals("ExchangeCreated (failed:false)", events.get(0));
@@ -76,10 +81,13 @@ public class JettyEventNotifierTest extends BaseJettyTest {
 
             context.start();
 
-            String out = template.requestBodyAndHeader("http://localhost:{{port}}/camel/fail?throwExceptionOnFailure=false",
-                    "Hello World",
-                    Exchange.HTTP_METHOD, "GET", String.class);
-            assertEquals("", out);
+            given()
+                    .port(getPort())
+                    .body("Hello World")
+                    .post("/camel/fail")
+                    .then()
+                    .statusCode(500)
+                    .body(is(""));
 
             Assertions.assertEquals(2, events.size());
             Assertions.assertEquals("ExchangeCreated (failed:false)", events.get(0));
@@ -94,9 +102,7 @@ public class JettyEventNotifierTest extends BaseJettyTest {
         public void notify(CamelEvent event) throws Exception {
             if (event.getSource() instanceof Exchange) {
                 Exchange ex = (Exchange) event.getSource();
-                if ("jetty".equals(ex.getFromRouteId())) {
-                    events.add(event.getType().name() + " (failed:" + ex.isFailed() + ")");
-                }
+                events.add(event.getType().name() + " (failed:" + ex.isFailed() + ")");
             }
         }
     }