You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by al...@apache.org on 2022/03/29 17:33:21 UTC

[camel-quarkus] branch main updated: paho: Add test coverage for file persistence #3680

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

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


The following commit(s) were added to refs/heads/main by this push:
     new 80642ad  paho: Add test coverage for file persistence #3680
80642ad is described below

commit 80642ad479b06f028d1c74e67ee84eb81f6254f9
Author: aldettinger <al...@gmail.com>
AuthorDate: Tue Mar 29 17:00:43 2022 +0200

    paho: Add test coverage for file persistence #3680
---
 .../quarkus/component/paho/deployment/PahoProcessor.java      |  5 +++++
 .../org/apache/camel/quarkus/component/paho/PahoResource.java |  8 ++++++++
 .../org/apache/camel/quarkus/component/paho/it/PahoTest.java  | 11 +++++++++++
 3 files changed, 24 insertions(+)

diff --git a/extensions/paho/deployment/src/main/java/org/apache/camel/quarkus/component/paho/deployment/PahoProcessor.java b/extensions/paho/deployment/src/main/java/org/apache/camel/quarkus/component/paho/deployment/PahoProcessor.java
index 5c9ba8a..5858d66 100644
--- a/extensions/paho/deployment/src/main/java/org/apache/camel/quarkus/component/paho/deployment/PahoProcessor.java
+++ b/extensions/paho/deployment/src/main/java/org/apache/camel/quarkus/component/paho/deployment/PahoProcessor.java
@@ -16,6 +16,8 @@
  */
 package org.apache.camel.quarkus.component.paho.deployment;
 
+import java.nio.channels.FileChannel;
+import java.nio.channels.FileLock;
 import java.util.ResourceBundle;
 
 import io.quarkus.deployment.annotations.BuildProducer;
@@ -41,6 +43,9 @@ class PahoProcessor {
         p.produce(new ReflectiveClassBuildItem(false, false, JSR47Logger.class));
         p.produce(new ReflectiveClassBuildItem(false, false, ResourceBundleCatalog.class));
         p.produce(new ReflectiveClassBuildItem(false, false, ResourceBundle.class));
+        p.produce(new ReflectiveClassBuildItem(false, false, FileLock.class));
+        p.produce(new ReflectiveClassBuildItem(true, false, FileChannel.class));
+        p.produce(new ReflectiveClassBuildItem(true, false, "sun.nio.ch.FileLockImpl"));
     }
 
     @BuildStep
diff --git a/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/PahoResource.java b/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/PahoResource.java
index 74b3ca4..e5e8409 100644
--- a/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/PahoResource.java
+++ b/integration-tests/paho/src/main/java/org/apache/camel/quarkus/component/paho/PahoResource.java
@@ -26,6 +26,7 @@ import javax.ws.rs.POST;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
 
@@ -87,4 +88,11 @@ public class PahoResource {
         return mqex.getMessage();
     }
 
+    @Path("/readThenWriteWithFilePersistenceShouldSucceed")
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    public String readThenWriteWithFilePersistenceShouldSucceed(@QueryParam("message") String message) throws Exception {
+        producerTemplate.requestBody("paho:withFilePersistence?retained=true&cleanSession=false&persistence=FILE", message);
+        return consumerTemplate.receiveBody("paho:withFilePersistence?cleanSession=false&persistence=FILE", 5000, String.class);
+    }
 }
diff --git a/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java b/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java
index 71dd953..096aac3 100644
--- a/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java
+++ b/integration-tests/paho/src/test/java/org/apache/camel/quarkus/component/paho/it/PahoTest.java
@@ -63,4 +63,15 @@ class PahoTest {
                 .statusCode(200)
                 .body(matchesRegex(".+"));
     }
+
+    @Test
+    public void readThenWriteWithFilePersistenceShouldSucceed() {
+        String message = "readThenWriteWithFilePersistenceShouldSucceed message content: 762e6af1-3ec7-40e0-9271-0c98a1001728";
+        RestAssured.given()
+                .queryParam("message", message)
+                .get("/paho/readThenWriteWithFilePersistenceShouldSucceed")
+                .then()
+                .statusCode(200)
+                .body(is(message));
+    }
 }