You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2021/07/14 14:55:59 UTC

[camel-quarkus] 13/13: Test removeProperty() and removeProperties() EIP DSL methods #2628

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

ppalaga pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit 8522d9fb64c7a967938615825050b5969dd41213
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Fri Jul 9 21:52:56 2021 +0200

    Test removeProperty() and removeProperties() EIP DSL methods #2628
---
 .../apache/camel/quarkus/eip/it/EipResource.java   |  5 +++
 .../org/apache/camel/quarkus/eip/it/EipRoutes.java |  4 ++
 .../org/apache/camel/quarkus/eip/it/EipTest.java   | 44 ++++++++++++++++++++++
 3 files changed, 53 insertions(+)

diff --git a/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipResource.java b/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipResource.java
index 3db977e..fd0940f 100644
--- a/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipResource.java
+++ b/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipResource.java
@@ -78,6 +78,11 @@ public class EipResource {
                     .flatMap(e -> e.getMessage().getHeaders().entrySet().stream()
                             .map(entry -> entry.getKey() + "=" + entry.getValue()))
                     .collect(Collectors.joining(","));
+        case "property":
+            return mock.getExchanges().stream()
+                    .flatMap(e -> e.getProperties().entrySet().stream()
+                            .map(entry -> entry.getKey() + "=" + entry.getValue()))
+                    .collect(Collectors.joining(","));
         default:
             throw new IllegalStateException("Unexpected part " + part);
         }
diff --git a/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java b/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java
index 755ce35..52229d1 100644
--- a/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java
+++ b/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java
@@ -68,6 +68,10 @@ public class EipRoutes extends RouteBuilder {
 
         from("direct:removeHeaders").removeHeaders("headerToRemove.*").to("mock:removeHeaders");
 
+        from("direct:removeProperty").removeHeader("propertyToRemove").to("mock:removeProperty");
+
+        from("direct:removeProperties").removeHeaders("propertyToRemove.*").to("mock:removeProperties");
+
     }
 
     @Produces
diff --git a/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java b/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java
index e1fdc81..18e78cc 100644
--- a/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java
+++ b/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java
@@ -211,4 +211,48 @@ class EipTest {
 
     }
 
+    @Test
+    public void removeProperty() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("baz")
+                .queryParam("propertyToKeep", "keep")
+                .queryParam("propertyToRemove", "bar")
+                .post("/eip/route/removeProperty")
+                .then()
+                .statusCode(200);
+
+        RestAssured.get("/eip/mock/removeProperty/1/5000/header")
+                .then()
+                .statusCode(200)
+                .body(
+                        Matchers.allOf(
+                                Matchers.containsString("propertyToKeep=keep"),
+                                Matchers.not(Matchers.containsString("propertyToRemove"))));
+
+    }
+
+    @Test
+    public void removeProperties() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("baz")
+                .queryParam("propertyToKeep", "keepProp")
+                .queryParam("propertyToRemove1", "bar1")
+                .queryParam("propertyToRemove2", "bar2")
+                .post("/eip/route/removeProperties")
+                .then()
+                .statusCode(200);
+
+        RestAssured.get("/eip/mock/removeProperties/1/5000/header")
+                .then()
+                .statusCode(200)
+                .body(
+                        Matchers.allOf(
+                                Matchers.containsString("propertyToKeep=keepProp"),
+                                Matchers.not(Matchers.containsString("propertyToRemove1")),
+                                Matchers.not(Matchers.containsString("propertyToRemove2"))));
+
+    }
+
 }