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:46 UTC

[camel-quarkus] branch main updated (aba774d -> 8522d9f)

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

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


    from aba774d  Updated CHANGELOG.md
     new 9c99a0a  Test resequence() and batch() EIP DSL methods #2628
     new 782f824  Test claimCheck() EIP DSL method #2628
     new d60a444  Test dynamicRouter() EIP DSL method #2628
     new c82222d  Test enrich() EIP DSL method #2628
     new 5bacca3  Test failover() EIP DSL method #2628
     new 2add5cf  Test faultToleranceConfiguration() EIP DSL method #2628
     new 7c72830  Test loop() EIP DSL method #2628
     new 45ae17d  Test multicast() EIP DSL method #2628
     new ff910bf  Generalize Seda test
     new 9bf5ca0  Test pollEnrich() EIP DSL method #2628
     new 6c47431  Test recipientList() EIP DSL method #2628
     new 32fcc21  Test removeHeader() and removeHeaders() EIP DSL methods #2628
     new 8522d9f  Test removeProperty() and removeProperties() EIP DSL methods #2628

The 13 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../quarkus/component/bean/eip/EipResource.java    |  36 ++-
 .../quarkus/component/bean/eip/EipRoutes.java      |  96 ++++++++
 .../component/bean/{ClassIT.java => EipIT.java}    |   3 +-
 .../camel/quarkus/component/bean/EipTest.java      |  89 +++++++
 .../foundation/{browse => eip}/pom.xml             |  16 +-
 .../apache/camel/quarkus/eip/it/EipResource.java   |  91 ++++++++
 .../org/apache/camel/quarkus/eip/it/EipRoutes.java |  87 +++++++
 .../org/apache/camel/quarkus/eip/it/EipIT.java     |   4 +-
 .../org/apache/camel/quarkus/eip/it/EipTest.java   | 258 +++++++++++++++++++++
 integration-test-groups/foundation/pom.xml         |   1 +
 .../quarkus/component/seda/it/SedaResource.java    |  13 +-
 .../camel/quarkus/component/seda/it/SedaTest.java  |   6 +-
 integration-tests/file/pom.xml                     |  17 ++
 .../quarkus/component/file/it/FileResource.java    |   8 +
 .../quarkus/component/file/it/FileRoutes.java      |   4 +
 .../camel/quarkus/component/file/it/FileTest.java  |  17 ++
 .../component/messaging/it/JmsResource.java        |  15 ++
 .../quarkus/component/messaging/it/JmsRoutes.java  |   8 +
 .../quarkus/component/messaging/it/JmsTest.java    |  24 ++
 .../MicroProfileFaultToleranceRoutes.java          |  15 ++
 .../MicroprofileFaultToleranceResource.java        |  10 +-
 .../MicroprofileFaultToleranceTest.java            |  25 +-
 22 files changed, 798 insertions(+), 45 deletions(-)
 copy integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyResource.java => integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipResource.java (62%)
 create mode 100644 integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipRoutes.java
 copy integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/{ClassIT.java => EipIT.java} (95%)
 create mode 100644 integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/EipTest.java
 copy integration-test-groups/foundation/{browse => eip}/pom.xml (88%)
 create mode 100644 integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipResource.java
 create mode 100644 integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java
 copy integration-tests/as2/src/test/java/org/apache/camel/quarkus/component/as2/it/As2IT.java => integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipIT.java (91%)
 create mode 100644 integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java

[camel-quarkus] 11/13: Test recipientList() EIP DSL method #2628

Posted by pp...@apache.org.
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 6c47431ab17183ca5186797758a23c98099a7a46
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Fri Jul 9 18:47:15 2021 +0200

    Test recipientList() EIP DSL method #2628
---
 .../org/apache/camel/quarkus/eip/it/EipRoutes.java |  2 ++
 .../org/apache/camel/quarkus/eip/it/EipTest.java   | 30 ++++++++++++++++++++++
 2 files changed, 32 insertions(+)

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 43945d0..32b78fc 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
@@ -62,6 +62,8 @@ public class EipRoutes extends RouteBuilder {
 
         from("direct:multicast").multicast().parallelProcessing().to("mock:multicast1", "mock:multicast2", "mock:multicast3");
 
+        from("direct:recipientList").recipientList(constant("mock:recipientList1,mock:recipientList2,mock:recipientList3"));
+
     }
 
     @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 52de0ee..8abf644 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
@@ -137,4 +137,34 @@ class EipTest {
                 .body(Matchers.is("a,b,c,d"));
 
     }
+
+    @Test
+    public void recipientList() {
+        final List<String> messages = Arrays.asList("a", "b", "c", "d");
+        for (String msg : messages) {
+            RestAssured.given()
+                    .contentType(ContentType.TEXT)
+                    .body(msg)
+                    .post("/eip/route/recipientList")
+                    .then()
+                    .statusCode(200);
+        }
+
+        RestAssured.get("/eip/mock/recipientList1/4/5000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("a,b,c,d"));
+
+        RestAssured.get("/eip/mock/recipientList2/4/5000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("a,b,c,d"));
+
+        RestAssured.get("/eip/mock/recipientList3/4/5000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("a,b,c,d"));
+
+    }
+
 }

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

Posted by pp...@apache.org.
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"))));
+
+    }
+
 }

[camel-quarkus] 09/13: Generalize Seda test

Posted by pp...@apache.org.
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 ff910bf0bfafec379f4c98719a1ea1fea966d4d8
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu May 20 23:52:52 2021 +0200

    Generalize Seda test
---
 .../camel/quarkus/component/seda/it/SedaResource.java       | 13 +++++++------
 .../apache/camel/quarkus/component/seda/it/SedaTest.java    |  6 +++---
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/integration-test-groups/foundation/seda/src/main/java/org/apache/camel/quarkus/component/seda/it/SedaResource.java b/integration-test-groups/foundation/seda/src/main/java/org/apache/camel/quarkus/component/seda/it/SedaResource.java
index 1d75786..d937055 100644
--- a/integration-test-groups/foundation/seda/src/main/java/org/apache/camel/quarkus/component/seda/it/SedaResource.java
+++ b/integration-test-groups/foundation/seda/src/main/java/org/apache/camel/quarkus/component/seda/it/SedaResource.java
@@ -24,6 +24,7 @@ import javax.ws.rs.Consumes;
 import javax.ws.rs.GET;
 import javax.ws.rs.POST;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -44,22 +45,22 @@ public class SedaResource {
     @Inject
     ConsumerTemplate consumerTemplate;
 
-    @Path("/get")
+    @Path("/{name}")
     @GET
     @Produces(MediaType.TEXT_PLAIN)
-    public String get() throws Exception {
-        final String message = consumerTemplate.receiveBodyNoWait("seda:foo", String.class);
+    public String get(@PathParam("name") String name) throws Exception {
+        final String message = consumerTemplate.receiveBodyNoWait("seda:" + name, String.class);
         LOG.infof("Received from seda: %s", message);
         return message;
     }
 
-    @Path("/post")
+    @Path("/{name}")
     @POST
     @Consumes(MediaType.TEXT_PLAIN)
     @Produces(MediaType.TEXT_PLAIN)
-    public Response post(String message) throws Exception {
+    public Response post(String message, @PathParam("name") String name) throws Exception {
         LOG.infof("Sending to seda: %s", message);
-        producerTemplate.sendBody("seda:foo", message);
+        producerTemplate.sendBody("seda:" + name, message);
         return Response
                 .created(new URI("https://camel.apache.org/"))
                 .build();
diff --git a/integration-test-groups/foundation/seda/src/test/java/org/apache/camel/quarkus/component/seda/it/SedaTest.java b/integration-test-groups/foundation/seda/src/test/java/org/apache/camel/quarkus/component/seda/it/SedaTest.java
index 23b3a30..9f4904b 100644
--- a/integration-test-groups/foundation/seda/src/test/java/org/apache/camel/quarkus/component/seda/it/SedaTest.java
+++ b/integration-test-groups/foundation/seda/src/test/java/org/apache/camel/quarkus/component/seda/it/SedaTest.java
@@ -27,12 +27,12 @@ import static org.hamcrest.Matchers.equalTo;
 class SedaTest {
 
     @Test
-    public void testSeda() {
+    public void seda() {
         RestAssured.given()
-                .contentType(ContentType.TEXT).body("Hello World").post("/seda/post")
+                .contentType(ContentType.TEXT).body("Hello World").post("/seda/foo")
                 .then().statusCode(201);
 
-        RestAssured.get("/seda/get").then().body(equalTo("Hello World")).statusCode(200);
+        RestAssured.get("/seda/foo").then().body(equalTo("Hello World")).statusCode(200);
     }
 
 }

[camel-quarkus] 07/13: Test loop() EIP DSL method #2628

Posted by pp...@apache.org.
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 7c728301007efa7a804c3c5864fa95fb2427c4e9
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu May 20 17:54:09 2021 +0200

    Test loop() EIP DSL method #2628
---
 .../java/org/apache/camel/quarkus/eip/it/EipRoutes.java   |  3 +++
 .../java/org/apache/camel/quarkus/eip/it/EipTest.java     | 15 +++++++++++++++
 2 files changed, 18 insertions(+)

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 63edf83..8bdc21c 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
@@ -56,6 +56,9 @@ public class EipRoutes extends RouteBuilder {
         from("direct:failover1").throwException(new MyException());
         from("direct:failover2").setBody(body().prepend("Hello from failover2 "));
 
+        from("direct:loop")
+                .loop(3)
+                .to("mock:loop");
 
     }
 
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 22df695..3ece310 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
@@ -93,4 +93,19 @@ class EipTest {
 
     }
 
+    @Test
+    public void loop() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("foo")
+                .post("/eip/route/loop")
+                .then()
+                .statusCode(200);
+
+        RestAssured.get("/eip/mock/loop/3/5000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("foo,foo,foo"));
+
+    }
 }

[camel-quarkus] 12/13: Test removeHeader() and removeHeaders() EIP DSL methods #2628

Posted by pp...@apache.org.
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 32fcc21c93be783087630e4dade205fde3ea28eb
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Fri Jul 9 19:25:43 2021 +0200

    Test removeHeader() and removeHeaders() EIP DSL methods #2628
---
 .../apache/camel/quarkus/eip/it/EipResource.java   | 18 +++++-
 .../org/apache/camel/quarkus/eip/it/EipRoutes.java |  4 ++
 .../org/apache/camel/quarkus/eip/it/EipTest.java   | 64 ++++++++++++++++++----
 3 files changed, 73 insertions(+), 13 deletions(-)

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 ce54bca..3db977e 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
@@ -58,10 +58,11 @@ public class EipResource {
         return producerTemplate.requestBodyAndHeaders("direct:" + route, statement, headers, String.class);
     }
 
-    @Path("/mock/{name}/{count}/{timeout}")
+    @Path("/mock/{name}/{count}/{timeout}/{part}")
     @Produces(MediaType.TEXT_PLAIN)
     @GET
-    public String mock(@PathParam("name") String name, @PathParam("count") int count, @PathParam("timeout") int timeout) {
+    public String mockHeader(@PathParam("name") String name, @PathParam("count") int count, @PathParam("timeout") int timeout,
+            @PathParam("part") String part) {
         MockEndpoint mock = context.getEndpoint("mock:" + name, MockEndpoint.class);
         mock.setExpectedMessageCount(count);
         try {
@@ -69,6 +70,17 @@ public class EipResource {
         } catch (InterruptedException e1) {
             Thread.currentThread().interrupt();
         }
-        return mock.getExchanges().stream().map(e -> e.getMessage().getBody(String.class)).collect(Collectors.joining(","));
+        switch (part) {
+        case "body":
+            return mock.getExchanges().stream().map(e -> e.getMessage().getBody(String.class)).collect(Collectors.joining(","));
+        case "header":
+            return mock.getExchanges().stream()
+                    .flatMap(e -> e.getMessage().getHeaders().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 32b78fc..755ce35 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
@@ -64,6 +64,10 @@ public class EipRoutes extends RouteBuilder {
 
         from("direct:recipientList").recipientList(constant("mock:recipientList1,mock:recipientList2,mock:recipientList3"));
 
+        from("direct:removeHeader").removeHeader("headerToRemove").to("mock:removeHeader");
+
+        from("direct:removeHeaders").removeHeaders("headerToRemove.*").to("mock:removeHeaders");
+
     }
 
     @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 8abf644..e1fdc81 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
@@ -38,7 +38,7 @@ class EipTest {
                 .then()
                 .statusCode(200);
 
-        RestAssured.get("/eip/mock/claimCheckByHeader/4/10000")
+        RestAssured.get("/eip/mock/claimCheckByHeader/4/10000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("Bye World,Secret,Hi World,Secret"));
@@ -57,12 +57,12 @@ class EipTest {
                     .statusCode(200);
         }
 
-        RestAssured.get("/eip/mock/customLoadBalancer1/2/10000")
+        RestAssured.get("/eip/mock/customLoadBalancer1/2/10000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("a,c"));
 
-        RestAssured.get("/eip/mock/customLoadBalancer2/2/10000")
+        RestAssured.get("/eip/mock/customLoadBalancer2/2/10000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("b,d"));
@@ -102,7 +102,7 @@ class EipTest {
                 .then()
                 .statusCode(200);
 
-        RestAssured.get("/eip/mock/loop/3/5000")
+        RestAssured.get("/eip/mock/loop/3/5000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("foo,foo,foo"));
@@ -121,17 +121,17 @@ class EipTest {
                     .statusCode(200);
         }
 
-        RestAssured.get("/eip/mock/multicast1/4/5000")
+        RestAssured.get("/eip/mock/multicast1/4/5000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("a,b,c,d"));
 
-        RestAssured.get("/eip/mock/multicast2/4/5000")
+        RestAssured.get("/eip/mock/multicast2/4/5000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("a,b,c,d"));
 
-        RestAssured.get("/eip/mock/multicast3/4/5000")
+        RestAssured.get("/eip/mock/multicast3/4/5000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("a,b,c,d"));
@@ -150,21 +150,65 @@ class EipTest {
                     .statusCode(200);
         }
 
-        RestAssured.get("/eip/mock/recipientList1/4/5000")
+        RestAssured.get("/eip/mock/recipientList1/4/5000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("a,b,c,d"));
 
-        RestAssured.get("/eip/mock/recipientList2/4/5000")
+        RestAssured.get("/eip/mock/recipientList2/4/5000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("a,b,c,d"));
 
-        RestAssured.get("/eip/mock/recipientList3/4/5000")
+        RestAssured.get("/eip/mock/recipientList3/4/5000/body")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is("a,b,c,d"));
 
     }
 
+    @Test
+    public void removeHeader() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("baz")
+                .queryParam("headerToKeep", "foo")
+                .queryParam("headerToRemove", "bar")
+                .post("/eip/route/removeHeader")
+                .then()
+                .statusCode(200);
+
+        RestAssured.get("/eip/mock/removeHeader/1/5000/header")
+                .then()
+                .statusCode(200)
+                .body(
+                        Matchers.allOf(
+                                Matchers.containsString("headerToKeep=foo"),
+                                Matchers.not(Matchers.containsString("headerToRemove"))));
+
+    }
+
+    @Test
+    public void removeHeaders() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("baz")
+                .queryParam("headerToKeep", "keepFoo")
+                .queryParam("headerToRemove1", "bar1")
+                .queryParam("headerToRemove2", "bar2")
+                .post("/eip/route/removeHeaders")
+                .then()
+                .statusCode(200);
+
+        RestAssured.get("/eip/mock/removeHeaders/1/5000/header")
+                .then()
+                .statusCode(200)
+                .body(
+                        Matchers.allOf(
+                                Matchers.containsString("headerToKeep=keepFoo"),
+                                Matchers.not(Matchers.containsString("headerToRemove1")),
+                                Matchers.not(Matchers.containsString("headerToRemove2"))));
+
+    }
+
 }

[camel-quarkus] 03/13: Test dynamicRouter() EIP DSL method #2628

Posted by pp...@apache.org.
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 d60a4440b23efb852b5506424e652019b636a4f4
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Wed May 19 22:18:23 2021 +0200

    Test dynamicRouter() EIP DSL method #2628
---
 .../quarkus/component/bean/eip/EipResource.java    | 60 ++++++++++++++
 .../quarkus/component/bean/eip/EipRoutes.java      | 96 ++++++++++++++++++++++
 .../camel/quarkus/component/bean/EipIT.java}       | 29 +------
 .../camel/quarkus/component/bean/EipTest.java      | 89 ++++++++++++++++++++
 .../org/apache/camel/quarkus/eip/it/EipRoutes.java | 16 ++++
 .../org/apache/camel/quarkus/eip/it/EipTest.java   | 27 ++++++
 6 files changed, 292 insertions(+), 25 deletions(-)

diff --git a/integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipResource.java b/integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipResource.java
new file mode 100644
index 0000000..c9ae9ad
--- /dev/null
+++ b/integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipResource.java
@@ -0,0 +1,60 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.bean.eip;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+
+@Path("/bean/eip")
+@ApplicationScoped
+public class EipResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    CamelContext context;
+
+    @Path("/route/{route}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String route(String body, @PathParam("route") String route) {
+        return producerTemplate.requestBody("direct:" + route, body, String.class);
+    }
+
+    @Path("/result/{name}")
+    @Produces(MediaType.TEXT_PLAIN)
+    @GET
+    public String mock(@PathParam("name") String name, @PathParam("count") int count, @PathParam("timeout") int timeout) {
+        List<String> results = context.getRegistry().lookupByNameAndType(name, List.class);
+        return results.stream().collect(Collectors.joining(","));
+    }
+}
diff --git a/integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipRoutes.java b/integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipRoutes.java
new file mode 100644
index 0000000..f27e872
--- /dev/null
+++ b/integration-test-groups/foundation/bean/src/main/java/org/apache/camel/quarkus/component/bean/eip/EipRoutes.java
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.bean.eip;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
+import io.quarkus.runtime.annotations.RegisterForReflection;
+import org.apache.camel.Consume;
+import org.apache.camel.builder.RouteBuilder;
+
+public class EipRoutes extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:dynamicRouter")
+                .dynamicRouter(method("myDynamicRouter", "route"));
+
+    }
+
+    @Produces
+    @Singleton
+    @Named("dynamicRouterResult0")
+    List<String> dynamicRouterResult0() {
+        return new ArrayList<>();
+    }
+
+    @Produces
+    @Singleton
+    @Named("dynamicRouterResult1")
+    List<String> dynamicRouterResult1() {
+        return new ArrayList<>();
+    }
+
+    @Singleton
+    @Named("myDynamicRouter")
+    @RegisterForReflection
+    static class CustomDynamicRouter {
+        public String route(String body) {
+            try {
+                int val = Integer.parseInt(body);
+                return "bean:dynamicRouterResult" + (val % 2) + "?method=add";
+            } catch (NumberFormatException e) {
+                return null;
+            }
+        }
+    }
+
+    @RegisterForReflection(targets = ArrayList.class) // for dynamicRouterAnnotationResult
+    static class DynamicRouterWithAnnotation {
+
+        @Consume("direct:dynamicRouterAnnotation")
+        @org.apache.camel.DynamicRouter
+        public String route(String body) {
+            try {
+                int val = Integer.parseInt(body);
+                return "bean:dynamicRouterAnnotationResult" + (val % 2) + "?method=add";
+            } catch (NumberFormatException e) {
+                return null;
+            }
+        }
+    }
+
+    @Produces
+    @Singleton
+    @Named("dynamicRouterAnnotationResult0")
+    List<String> dynamicRouterResult2() {
+        return new ArrayList<>();
+    }
+
+    @Produces
+    @Singleton
+    @Named("dynamicRouterAnnotationResult1")
+    List<String> dynamicRouterResult3() {
+        return new ArrayList<>();
+    }
+
+}
diff --git a/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java b/integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/EipIT.java
similarity index 51%
copy from integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java
copy to integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/EipIT.java
index bfa129c..85cbc75 100644
--- a/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java
+++ b/integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/EipIT.java
@@ -14,32 +14,11 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-package org.apache.camel.quarkus.eip.it;
+package org.apache.camel.quarkus.component.bean;
 
-import io.quarkus.test.junit.QuarkusTest;
-import io.restassured.RestAssured;
-import io.restassured.http.ContentType;
-import org.hamcrest.Matchers;
-import org.junit.jupiter.api.Test;
+import io.quarkus.test.junit.NativeImageTest;
 
-@QuarkusTest
-class EipTest {
-
-    @Test
-    public void claimCheckByHeader() {
-        RestAssured.given()
-                .contentType(ContentType.TEXT)
-                .body("Secret")
-                .queryParam("claimCheckId", "foo")
-                .post("/eip/route/claimCheckByHeader")
-                .then()
-                .statusCode(200);
-
-        RestAssured.get("/eip/mock/claimCheckByHeader/4/10000")
-                .then()
-                .statusCode(200)
-                .body(Matchers.is("Bye World,Secret,Hi World,Secret"));
-
-    }
+@NativeImageTest
+class EipIT extends EipTest {
 
 }
diff --git a/integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/EipTest.java b/integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/EipTest.java
new file mode 100644
index 0000000..ec7c863
--- /dev/null
+++ b/integration-test-groups/foundation/bean/src/test/java/org/apache/camel/quarkus/component/bean/EipTest.java
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.bean;
+
+import java.util.concurrent.TimeUnit;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.awaitility.Awaitility;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+class EipTest {
+
+    @Test
+    public void dynamicRouter() {
+        for (int i = 0; i < 4; i++) {
+            RestAssured.given()
+                    .contentType(ContentType.TEXT)
+                    .body(String.valueOf(i))
+                    .post("/bean/eip/route/dynamicRouter")
+                    .then()
+                    .statusCode(200);
+        }
+
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS)
+                .until(
+                        () -> RestAssured.get("/bean/eip/result/dynamicRouterResult0")
+                                .then()
+                                .statusCode(200)
+                                .extract().body().asString(),
+                        Matchers.is("0,2"));
+
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS)
+                .until(
+                        () -> RestAssured.get("/bean/eip/result/dynamicRouterResult1")
+                                .then()
+                                .statusCode(200)
+                                .extract().body().asString(),
+                        Matchers.is("1,3"));
+
+    }
+
+    @Test
+    public void dynamicRouterAnnotation() {
+        for (int i = 4; i < 8; i++) {
+            RestAssured.given()
+                    .contentType(ContentType.TEXT)
+                    .body(String.valueOf(i))
+                    .post("/bean/eip/route/dynamicRouterAnnotation")
+                    .then()
+                    .statusCode(200);
+        }
+
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS)
+                .until(
+                        () -> RestAssured.get("/bean/eip/result/dynamicRouterAnnotationResult0")
+                                .then()
+                                .statusCode(200)
+                                .extract().body().asString(),
+                        Matchers.is("4,6"));
+
+        Awaitility.await().pollInterval(50, TimeUnit.MILLISECONDS).atMost(30, TimeUnit.SECONDS)
+                .until(
+                        () -> RestAssured.get("/bean/eip/result/dynamicRouterAnnotationResult1")
+                                .then()
+                                .statusCode(200)
+                                .extract().body().asString(),
+                        Matchers.is("5,7"));
+
+    }
+
+}
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 7c1b078..0e2a6b0 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
@@ -16,8 +16,13 @@
  */
 package org.apache.camel.quarkus.eip.it;
 
+import javax.enterprise.inject.Produces;
+import javax.inject.Named;
+import javax.inject.Singleton;
+
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.model.ClaimCheckOperation;
+import org.apache.camel.processor.loadbalancer.RoundRobinLoadBalancer;
 
 public class EipRoutes extends RouteBuilder {
 
@@ -33,5 +38,16 @@ public class EipRoutes extends RouteBuilder {
                 .to("mock:claimCheckByHeader")
                 .claimCheck(ClaimCheckOperation.Get, "${header.claimCheckId}")
                 .to("mock:claimCheckByHeader");
+
+        from("direct:customLoadBalancer")
+                .loadBalance().custom("roundRobin")
+                .to("mock:customLoadBalancer1", "mock:customLoadBalancer2");
+    }
+
+    @Produces
+    @Singleton
+    @Named("roundRobin")
+    RoundRobinLoadBalancer roundRobinLoadBalancer() {
+        return new RoundRobinLoadBalancer();
     }
 }
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 bfa129c..6c94d4d 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
@@ -16,6 +16,9 @@
  */
 package org.apache.camel.quarkus.eip.it;
 
+import java.util.Arrays;
+import java.util.List;
+
 import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
@@ -42,4 +45,28 @@ class EipTest {
 
     }
 
+    @Test
+    public void customLoadBalancer() {
+        final List<String> messages = Arrays.asList("a", "b", "c", "d");
+        for (String msg : messages) {
+            RestAssured.given()
+                    .contentType(ContentType.TEXT)
+                    .body(msg)
+                    .post("/eip/route/customLoadBalancer")
+                    .then()
+                    .statusCode(200);
+        }
+
+        RestAssured.get("/eip/mock/customLoadBalancer1/2/10000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("a,c"));
+
+        RestAssured.get("/eip/mock/customLoadBalancer2/2/10000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("b,d"));
+
+    }
+
 }

[camel-quarkus] 05/13: Test failover() EIP DSL method #2628

Posted by pp...@apache.org.
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 5bacca356d9827a81cc9c80b5e04c39cf1021823
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu May 20 14:30:12 2021 +0200

    Test failover() EIP DSL method #2628
---
 .../java/org/apache/camel/quarkus/eip/it/EipRoutes.java     | 12 ++++++++++++
 .../test/java/org/apache/camel/quarkus/eip/it/EipTest.java  | 13 +++++++++++++
 2 files changed, 25 insertions(+)

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 4912fb5..63edf83 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
@@ -49,6 +49,14 @@ public class EipRoutes extends RouteBuilder {
         from("direct:prepend-hello")
                 .setBody(body().prepend("Hello "));
 
+        from("direct:failover")
+                .loadBalance()
+                .failover(MyException.class)
+                .to("direct:failover1", "direct:failover2");
+        from("direct:failover1").throwException(new MyException());
+        from("direct:failover2").setBody(body().prepend("Hello from failover2 "));
+
+
     }
 
     @Produces
@@ -57,4 +65,8 @@ public class EipRoutes extends RouteBuilder {
     RoundRobinLoadBalancer roundRobinLoadBalancer() {
         return new RoundRobinLoadBalancer();
     }
+
+    public static class MyException extends RuntimeException {
+
+    }
 }
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 a49a695..22df695 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
@@ -80,4 +80,17 @@ class EipTest {
                 .body(Matchers.is("Hello Franz"));
 
     }
+
+    @Test
+    public void failover() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("Arthur")
+                .post("/eip/route/failover")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("Hello from failover2 Arthur"));
+
+    }
+
 }

[camel-quarkus] 08/13: Test multicast() EIP DSL method #2628

Posted by pp...@apache.org.
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 45ae17d6be66ecaa341062fdb43bf59eacc10c7e
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu May 20 17:58:24 2021 +0200

    Test multicast() EIP DSL method #2628
---
 .../org/apache/camel/quarkus/eip/it/EipRoutes.java |  1 +
 .../org/apache/camel/quarkus/eip/it/EipTest.java   | 29 ++++++++++++++++++++++
 2 files changed, 30 insertions(+)

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 8bdc21c..04b884f 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
@@ -60,6 +60,7 @@ public class EipRoutes extends RouteBuilder {
                 .loop(3)
                 .to("mock:loop");
 
+        from("direct:multicast").multicast().parallelProcessing().to("mock:multicast1", "mock:multicast2", "mock:multicast3");
     }
 
     @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 3ece310..52de0ee 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
@@ -108,4 +108,33 @@ class EipTest {
                 .body(Matchers.is("foo,foo,foo"));
 
     }
+
+    @Test
+    public void multicast() {
+        final List<String> messages = Arrays.asList("a", "b", "c", "d");
+        for (String msg : messages) {
+            RestAssured.given()
+                    .contentType(ContentType.TEXT)
+                    .body(msg)
+                    .post("/eip/route/multicast")
+                    .then()
+                    .statusCode(200);
+        }
+
+        RestAssured.get("/eip/mock/multicast1/4/5000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("a,b,c,d"));
+
+        RestAssured.get("/eip/mock/multicast2/4/5000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("a,b,c,d"));
+
+        RestAssured.get("/eip/mock/multicast3/4/5000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("a,b,c,d"));
+
+    }
 }

[camel-quarkus] 06/13: Test faultToleranceConfiguration() EIP DSL method #2628

Posted by pp...@apache.org.
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 2add5cf4a390849535bd4700ad024a8b1bc6ba9a
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu May 20 15:24:04 2021 +0200

    Test faultToleranceConfiguration() EIP DSL method #2628
---
 .../MicroProfileFaultToleranceRoutes.java          | 15 +++++++++++++
 .../MicroprofileFaultToleranceResource.java        | 10 +++++----
 .../MicroprofileFaultToleranceTest.java            | 25 ++++++++++++++++++++--
 3 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroProfileFaultToleranceRoutes.java b/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroProfileFaultToleranceRoutes.java
index 271daab..3dca95a 100644
--- a/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroProfileFaultToleranceRoutes.java
+++ b/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroProfileFaultToleranceRoutes.java
@@ -25,6 +25,7 @@ public class MicroProfileFaultToleranceRoutes extends RouteBuilder {
     public static final String FALLBACK_RESULT = "Fallback response";
     public static final String RESULT = "Hello Camel Quarkus MicroProfile Fault Tolerance";
     private static final AtomicInteger COUNTER = new AtomicInteger();
+    private static final AtomicInteger TIMEOUT_COUNTER = new AtomicInteger();
 
     @Override
     public void configure() throws Exception {
@@ -39,5 +40,19 @@ public class MicroProfileFaultToleranceRoutes extends RouteBuilder {
                 .onFallback()
                 .setBody().constant(FALLBACK_RESULT)
                 .end();
+
+        from("direct:faultToleranceWithTimeout")
+                .circuitBreaker()
+                .faultToleranceConfiguration().timeoutEnabled(true).timeoutDuration(500).end()
+                .process(exchange -> {
+                    if (TIMEOUT_COUNTER.incrementAndGet() == 1) {
+                        Thread.sleep(1000);
+                    }
+                    exchange.getMessage().setBody("Regular hi " + exchange.getMessage().getBody(String.class));
+                })
+                .onFallback()
+                .setBody().simple("Sorry ${body}, had to fallback!")
+                .end();
+
     }
 }
diff --git a/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceResource.java b/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceResource.java
index 2e2214f..348a870 100644
--- a/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceResource.java
+++ b/integration-tests/microprofile/src/main/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceResource.java
@@ -17,8 +17,9 @@
 package org.apache.camel.quarkus.component.microprofile.it.faulttolerance;
 
 import javax.inject.Inject;
-import javax.ws.rs.GET;
+import javax.ws.rs.POST;
 import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 
@@ -30,9 +31,10 @@ public class MicroprofileFaultToleranceResource {
     @Inject
     ProducerTemplate producerTemplate;
 
-    @GET
+    @Path("/route/{route}")
+    @POST
     @Produces(MediaType.TEXT_PLAIN)
-    public String triggerFaultToleranceRoute() {
-        return producerTemplate.requestBody("direct:faultTolerance", null, String.class);
+    public String triggerFaultToleranceRoute(String body, @PathParam("route") String route) {
+        return producerTemplate.requestBody("direct:" + route, body, String.class);
     }
 }
diff --git a/integration-tests/microprofile/src/test/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceTest.java b/integration-tests/microprofile/src/test/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceTest.java
index d5bd0c5..ff610c2 100644
--- a/integration-tests/microprofile/src/test/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceTest.java
+++ b/integration-tests/microprofile/src/test/java/org/apache/camel/quarkus/component/microprofile/it/faulttolerance/MicroprofileFaultToleranceTest.java
@@ -28,15 +28,36 @@ class MicroprofileFaultToleranceTest {
     public void testCamelMicroProfileFaultToleranceFallback() {
 
         // First request should trigger the fallback response
-        RestAssured.get("/microprofile-fault-tolerance")
+        RestAssured.post("/microprofile-fault-tolerance/route/faultTolerance")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is(MicroProfileFaultToleranceRoutes.FALLBACK_RESULT));
 
         // Next request(s) should trigger the expected response
-        RestAssured.get("/microprofile-fault-tolerance")
+        RestAssured.post("/microprofile-fault-tolerance/route/faultTolerance")
                 .then()
                 .statusCode(200)
                 .body(Matchers.is(MicroProfileFaultToleranceRoutes.RESULT));
     }
+
+    @Test
+    public void testCamelMicroProfileFaultToleranceFallbackWithTimeout() {
+
+        // First request should trigger the fallback response
+        RestAssured.given()
+                .body("Joe")
+                .post("/microprofile-fault-tolerance/route/faultToleranceWithTimeout")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("Sorry Joe, had to fallback!"));
+
+        // Next request(s) should trigger the expected response
+        RestAssured.given()
+                .body("Mary")
+                .post("/microprofile-fault-tolerance/route/faultToleranceWithTimeout")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("Regular hi Mary"));
+    }
+
 }

[camel-quarkus] 02/13: Test claimCheck() EIP DSL method #2628

Posted by pp...@apache.org.
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 782f8240a7c7ef4f0a27f85a704d74d31513ba34
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Wed May 19 17:42:57 2021 +0200

    Test claimCheck() EIP DSL method #2628
---
 integration-test-groups/foundation/eip/pom.xml     | 132 +++++++++++++++++++++
 .../apache/camel/quarkus/eip/it/EipResource.java   |  74 ++++++++++++
 .../org/apache/camel/quarkus/eip/it/EipRoutes.java |  37 ++++++
 .../org/apache/camel/quarkus/eip/it/EipIT.java     |  24 ++++
 .../org/apache/camel/quarkus/eip/it/EipTest.java   |  45 +++++++
 integration-test-groups/foundation/pom.xml         |   1 +
 6 files changed, 313 insertions(+)

diff --git a/integration-test-groups/foundation/eip/pom.xml b/integration-test-groups/foundation/eip/pom.xml
new file mode 100644
index 0000000..431c324
--- /dev/null
+++ b/integration-test-groups/foundation/eip/pom.xml
@@ -0,0 +1,132 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    Licensed to the Apache Software Foundation (ASF) under one or more
+    contributor license agreements.  See the NOTICE file distributed with
+    this work for additional information regarding copyright ownership.
+    The ASF licenses this file to You under the Apache License, Version 2.0
+    (the "License"); you may not use this file except in compliance with
+    the License.  You may obtain a copy of the License at
+
+         http://www.apache.org/licenses/LICENSE-2.0
+
+    Unless required by applicable law or agreed to in writing, software
+    distributed under the License is distributed on an "AS IS" BASIS,
+    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+    See the License for the specific language governing permissions and
+    limitations under the License.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.camel.quarkus</groupId>
+        <artifactId>camel-quarkus-integration-tests-foundation</artifactId>
+        <version>2.1.0-SNAPSHOT</version>
+        <relativePath>../pom.xml</relativePath>
+    </parent>
+
+    <artifactId>camel-quarkus-integration-test-eip</artifactId>
+    <name>Camel Quarkus :: Integration Tests :: EIP</name>
+    <description>Integration tests for Camel Enterprise Integration Patterns</description>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.camel.quarkus</groupId>
+                <artifactId>camel-quarkus-bom-test</artifactId>
+                <version>${project.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-mock</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-resteasy</artifactId>
+        </dependency>
+
+        <!-- test dependencies -->
+        <dependency>
+            <groupId>io.quarkus</groupId>
+            <artifactId>quarkus-junit5</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>io.rest-assured</groupId>
+            <artifactId>rest-assured</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-mock-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <profile>
+            <id>native</id>
+            <activation>
+                <property>
+                    <name>native</name>
+                </property>
+            </activation>
+            <properties>
+                <quarkus.package.type>native</quarkus.package.type>
+            </properties>
+            <build>
+                <plugins>
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+                </plugins>
+            </build>
+        </profile>
+    </profiles>
+
+</project>
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
new file mode 100644
index 0000000..ce54bca
--- /dev/null
+++ b/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipResource.java
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.eip.it;
+
+import java.util.AbstractMap;
+import java.util.Map;
+import java.util.Map.Entry;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.POST;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.Context;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.UriInfo;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+
+@Path("/eip")
+@ApplicationScoped
+public class EipResource {
+
+    @Inject
+    ProducerTemplate producerTemplate;
+
+    @Inject
+    CamelContext context;
+
+    @Path("/route/{route}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    @Produces(MediaType.TEXT_PLAIN)
+    public String route(String statement, @PathParam("route") String route, @Context UriInfo uriInfo) {
+        final Map<String, Object> headers = uriInfo.getQueryParameters().entrySet().stream()
+                .map(e -> new AbstractMap.SimpleImmutableEntry<String, Object>(e.getKey(), e.getValue().get(0)))
+                .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
+        return producerTemplate.requestBodyAndHeaders("direct:" + route, statement, headers, String.class);
+    }
+
+    @Path("/mock/{name}/{count}/{timeout}")
+    @Produces(MediaType.TEXT_PLAIN)
+    @GET
+    public String mock(@PathParam("name") String name, @PathParam("count") int count, @PathParam("timeout") int timeout) {
+        MockEndpoint mock = context.getEndpoint("mock:" + name, MockEndpoint.class);
+        mock.setExpectedMessageCount(count);
+        try {
+            mock.assertIsSatisfied(timeout);
+        } catch (InterruptedException e1) {
+            Thread.currentThread().interrupt();
+        }
+        return mock.getExchanges().stream().map(e -> e.getMessage().getBody(String.class)).collect(Collectors.joining(","));
+    }
+}
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
new file mode 100644
index 0000000..7c1b078
--- /dev/null
+++ b/integration-test-groups/foundation/eip/src/main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.eip.it;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.ClaimCheckOperation;
+
+public class EipRoutes extends RouteBuilder {
+
+    @Override
+    public void configure() {
+        from("direct:claimCheckByHeader")
+                .claimCheck(ClaimCheckOperation.Set, "${header.claimCheckId}")
+                .transform().constant("Bye World")
+                .to("mock:claimCheckByHeader")
+                .claimCheck(ClaimCheckOperation.Get, "${header.claimCheckId}")
+                .to("mock:claimCheckByHeader")
+                .transform().constant("Hi World")
+                .to("mock:claimCheckByHeader")
+                .claimCheck(ClaimCheckOperation.Get, "${header.claimCheckId}")
+                .to("mock:claimCheckByHeader");
+    }
+}
diff --git a/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipIT.java b/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipIT.java
new file mode 100644
index 0000000..9a8956e
--- /dev/null
+++ b/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipIT.java
@@ -0,0 +1,24 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.eip.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+class EipIT extends EipTest {
+
+}
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
new file mode 100644
index 0000000..bfa129c
--- /dev/null
+++ b/integration-test-groups/foundation/eip/src/test/java/org/apache/camel/quarkus/eip/it/EipTest.java
@@ -0,0 +1,45 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.eip.it;
+
+import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
+import io.restassured.http.ContentType;
+import org.hamcrest.Matchers;
+import org.junit.jupiter.api.Test;
+
+@QuarkusTest
+class EipTest {
+
+    @Test
+    public void claimCheckByHeader() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("Secret")
+                .queryParam("claimCheckId", "foo")
+                .post("/eip/route/claimCheckByHeader")
+                .then()
+                .statusCode(200);
+
+        RestAssured.get("/eip/mock/claimCheckByHeader/4/10000")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("Bye World,Secret,Hi World,Secret"));
+
+    }
+
+}
diff --git a/integration-test-groups/foundation/pom.xml b/integration-test-groups/foundation/pom.xml
index 6d9c895..74b97fe 100644
--- a/integration-test-groups/foundation/pom.xml
+++ b/integration-test-groups/foundation/pom.xml
@@ -43,6 +43,7 @@
         <module>core-thread-pools</module>
         <module>customized-log-component</module>
         <module>direct</module>
+        <module>eip</module>
         <module>log</module>
         <module>mock</module>
         <module>ref</module>

[camel-quarkus] 01/13: Test resequence() and batch() EIP DSL methods #2628

Posted by pp...@apache.org.
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 9c99a0a1e3d67f71403f51e036fb7b3fbf7c5e70
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Wed May 19 17:05:34 2021 +0200

    Test resequence() and batch() EIP DSL methods #2628
---
 .../component/messaging/it/JmsResource.java        | 15 ++++++++++++++
 .../quarkus/component/messaging/it/JmsRoutes.java  |  8 ++++++++
 .../quarkus/component/messaging/it/JmsTest.java    | 24 ++++++++++++++++++++++
 3 files changed, 47 insertions(+)

diff --git a/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsResource.java b/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsResource.java
index 22ec50f..55415ed 100644
--- a/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsResource.java
+++ b/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsResource.java
@@ -23,6 +23,7 @@ import java.util.Enumeration;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import javax.inject.Inject;
 import javax.jms.BytesMessage;
@@ -284,6 +285,20 @@ public class JmsResource {
         topicResultB.assertIsSatisfied(5000);
     }
 
+    @Path("/jms/mock/{name}/{count}/{timeout}")
+    @Produces(MediaType.APPLICATION_JSON)
+    @GET
+    public List<String> mock(@PathParam("name") String name, @PathParam("count") int count, @PathParam("timeout") int timeout) {
+        MockEndpoint mock = context.getEndpoint("mock:" + name, MockEndpoint.class);
+        mock.setExpectedMessageCount(count);
+        try {
+            mock.assertIsSatisfied(timeout);
+        } catch (InterruptedException e1) {
+            Thread.currentThread().interrupt();
+        }
+        return mock.getExchanges().stream().map(e -> e.getMessage().getBody(String.class)).collect(Collectors.toList());
+    }
+
     // *****************************
     //
     // camel-paho
diff --git a/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsRoutes.java b/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsRoutes.java
index 50cf70d..86c153b 100644
--- a/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsRoutes.java
+++ b/integration-tests/messaging/src/main/java/org/apache/camel/quarkus/component/messaging/it/JmsRoutes.java
@@ -70,6 +70,14 @@ public class JmsRoutes extends RouteBuilder {
 
         from("jms:topic:test?clientId=456&durableSubscriptionName=camel-quarkus")
                 .to("mock:topicResultB");
+
+        from("jms:queue:resequence")
+                // sort by body by allowing duplicates (message can have same JMSPriority)
+                // and use reverse ordering so 9 is first output (most important), and 0 is last
+                // use batch mode and fire every 3rd second
+                .resequence(body()).batch().timeout(10000).allowDuplicates().reverse()
+                .to("mock:resequence");
+
     }
 
     private ErrorHandlerBuilder setUpJtaErrorHandler() {
diff --git a/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java b/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java
index 58be3ab..b65502c 100644
--- a/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java
+++ b/integration-tests/messaging/src/test/java/org/apache/camel/quarkus/component/messaging/it/JmsTest.java
@@ -16,7 +16,10 @@
  */
 package org.apache.camel.quarkus.component.messaging.it;
 
+import java.util.Arrays;
+import java.util.Collections;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import io.quarkus.test.common.QuarkusTestResource;
@@ -26,6 +29,7 @@ import io.quarkus.test.junit.QuarkusTest;
 import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import org.apache.camel.quarkus.test.support.activemq.ActiveMQTestResource;
+import org.junit.jupiter.api.Assertions;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.params.ParameterizedTest;
 import org.junit.jupiter.params.provider.ValueSource;
@@ -179,4 +183,24 @@ class JmsTest {
                 .statusCode(200)
                 .body(is("JMS Transaction Success"));
     }
+
+    @Test
+    public void testResequence() {
+        final List<String> messages = Arrays.asList("a", "b", "c", "c", "d");
+        for (String msg : messages) {
+            RestAssured.given()
+                    .body(msg)
+                    .post("/messaging/jms/resequence")
+                    .then()
+                    .statusCode(201);
+        }
+        Collections.reverse(messages);
+        final List<String> actual = RestAssured.given()
+                .get("/messaging/jms/mock/resequence/5/10000")
+                .then()
+                .statusCode(200)
+                .extract().body().jsonPath().getList(".", String.class);
+        Assertions.assertEquals(messages, actual);
+    }
+
 }

[camel-quarkus] 10/13: Test pollEnrich() EIP DSL method #2628

Posted by pp...@apache.org.
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 9bf5ca08b56044239827736aa11449ad0a42c0f7
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu May 20 23:53:18 2021 +0200

    Test pollEnrich() EIP DSL method #2628
---
 .../java/org/apache/camel/quarkus/eip/it/EipRoutes.java |  1 +
 integration-tests/file/pom.xml                          | 17 +++++++++++++++++
 .../camel/quarkus/component/file/it/FileResource.java   |  8 ++++++++
 .../camel/quarkus/component/file/it/FileRoutes.java     |  4 ++++
 .../camel/quarkus/component/file/it/FileTest.java       | 17 +++++++++++++++++
 5 files changed, 47 insertions(+)

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 04b884f..43945d0 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
@@ -61,6 +61,7 @@ public class EipRoutes extends RouteBuilder {
                 .to("mock:loop");
 
         from("direct:multicast").multicast().parallelProcessing().to("mock:multicast1", "mock:multicast2", "mock:multicast3");
+
     }
 
     @Produces
diff --git a/integration-tests/file/pom.xml b/integration-tests/file/pom.xml
index a56b38b..e31d57c 100644
--- a/integration-tests/file/pom.xml
+++ b/integration-tests/file/pom.xml
@@ -44,6 +44,10 @@
         </dependency>
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-mock</artifactId>
         </dependency>
         <dependency>
@@ -81,6 +85,19 @@
         <!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
         <dependency>
             <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-direct-deployment</artifactId>
+            <version>${project.version}</version>
+            <type>pom</type>
+            <scope>test</scope>
+            <exclusions>
+                <exclusion>
+                    <groupId>*</groupId>
+                    <artifactId>*</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
             <artifactId>camel-quarkus-file-deployment</artifactId>
             <version>${project.version}</version>
             <type>pom</type>
diff --git a/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileResource.java b/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileResource.java
index 9768b6c..3695917 100644
--- a/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileResource.java
+++ b/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileResource.java
@@ -125,4 +125,12 @@ public class FileResource {
                 .entity(response.getMessage().getHeader(Exchange.FILE_NAME_PRODUCED))
                 .build();
     }
+
+    @Path("/route/{route}")
+    @POST
+    @Consumes(MediaType.TEXT_PLAIN)
+    public String pollEnrich(String body, @PathParam("route") String route) throws Exception {
+        return producerTemplate.requestBody("direct:" + route, body, String.class);
+    }
+
 }
diff --git a/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileRoutes.java b/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileRoutes.java
index 27c70ac..891339c 100644
--- a/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileRoutes.java
+++ b/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileRoutes.java
@@ -74,6 +74,10 @@ public class FileRoutes extends RouteBuilder {
                 .id(SORT_BY)
                 .noAutoStartup()
                 .convertBodyTo(String.class).to("mock:" + SORT_BY);
+
+        from("direct:pollEnrich")
+                .pollEnrich("file://target/pollEnrich?fileName=pollEnrich.txt");
+
     }
 
     public class MyFileFilter<T> implements GenericFileFilter<T> {
diff --git a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java
index 77e444c..bef5896 100644
--- a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java
+++ b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/FileTest.java
@@ -33,6 +33,7 @@ import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import io.restassured.path.json.JsonPath;
 import io.restassured.response.ValidatableResponse;
+import org.hamcrest.Matchers;
 import org.junit.jupiter.api.AfterEach;
 import org.junit.jupiter.api.Test;
 
@@ -310,4 +311,20 @@ class FileTest {
                     }
                 });
     }
+
+    @Test
+    public void pollEnrich() throws IOException {
+        final Path file = Paths.get("target/pollEnrich/pollEnrich.txt");
+        Files.createDirectories(file.getParent());
+        final String body = "Hi from pollEnrich.txt";
+        Files.write(file, body.getBytes(StandardCharsets.UTF_8));
+
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .post("/file/route/pollEnrich")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is(body));
+    }
+
 }

[camel-quarkus] 04/13: Test enrich() EIP DSL method #2628

Posted by pp...@apache.org.
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 c82222d07d546d3cfb02838ff6fbb48ec4dd7c12
Author: Peter Palaga <pp...@redhat.com>
AuthorDate: Thu May 20 14:19:19 2021 +0200

    Test enrich() EIP DSL method #2628
---
 .../main/java/org/apache/camel/quarkus/eip/it/EipRoutes.java  |  7 +++++++
 .../test/java/org/apache/camel/quarkus/eip/it/EipTest.java    | 11 +++++++++++
 2 files changed, 18 insertions(+)

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 0e2a6b0..4912fb5 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
@@ -42,6 +42,13 @@ public class EipRoutes extends RouteBuilder {
         from("direct:customLoadBalancer")
                 .loadBalance().custom("roundRobin")
                 .to("mock:customLoadBalancer1", "mock:customLoadBalancer2");
+
+        from("direct:enrich")
+                .enrich("direct:prepend-hello");
+
+        from("direct:prepend-hello")
+                .setBody(body().prepend("Hello "));
+
     }
 
     @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 6c94d4d..a49a695 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
@@ -69,4 +69,15 @@ class EipTest {
 
     }
 
+    @Test
+    public void enrich() {
+        RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body("Franz")
+                .post("/eip/route/enrich")
+                .then()
+                .statusCode(200)
+                .body(Matchers.is("Hello Franz"));
+
+    }
 }