You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/09/01 11:25:34 UTC

[camel-quarkus] branch master updated: Register missing Camel quartz job classes for reflection

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

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


The following commit(s) were added to refs/heads/master by this push:
     new 23950a1  Register missing Camel quartz job classes for reflection
23950a1 is described below

commit 23950a14434985b03fb5c09de1e76a0442892d59
Author: James Netherton <ja...@gmail.com>
AuthorDate: Tue Sep 1 11:07:13 2020 +0100

    Register missing Camel quartz job classes for reflection
    
    Fixes #1663
---
 .../quartz/deployment/QuartzProcessor.java         |  7 +++++-
 integration-tests/file/pom.xml                     |  6 ++++-
 .../quarkus/component/file/it/FileRoutes.java      |  2 ++
 .../camel/quarkus/component/file/it/FileTest.java  | 28 ++++++++++++++++++++--
 4 files changed, 39 insertions(+), 4 deletions(-)

diff --git a/extensions/quartz/deployment/src/main/java/org/apache/camel/quarkus/component/quartz/deployment/QuartzProcessor.java b/extensions/quartz/deployment/src/main/java/org/apache/camel/quarkus/component/quartz/deployment/QuartzProcessor.java
index e12d8c8..0174322 100644
--- a/extensions/quartz/deployment/src/main/java/org/apache/camel/quarkus/component/quartz/deployment/QuartzProcessor.java
+++ b/extensions/quartz/deployment/src/main/java/org/apache/camel/quarkus/component/quartz/deployment/QuartzProcessor.java
@@ -24,6 +24,11 @@ import io.quarkus.deployment.builditem.nativeimage.ReflectiveClassBuildItem;
 class QuartzProcessor {
 
     private static final String FEATURE = "camel-quartz";
+    private static final String[] QUARTZ_JOB_CLASSES = new String[] {
+            "org.apache.camel.component.quartz.CamelJob",
+            "org.apache.camel.component.quartz.StatefulCamelJob",
+            "org.apache.camel.pollconsumer.quartz.QuartzScheduledPollConsumerJob"
+    };
 
     @BuildStep
     FeatureBuildItem feature() {
@@ -37,6 +42,6 @@ class QuartzProcessor {
 
     @BuildStep
     ReflectiveClassBuildItem registerForReflection() {
-        return new ReflectiveClassBuildItem(false, false, "org.apache.camel.component.quartz.CamelJob");
+        return new ReflectiveClassBuildItem(false, false, QUARTZ_JOB_CLASSES);
     }
 }
diff --git a/integration-tests/file/pom.xml b/integration-tests/file/pom.xml
index 8e7c8a7..884b69f 100644
--- a/integration-tests/file/pom.xml
+++ b/integration-tests/file/pom.xml
@@ -36,7 +36,7 @@
         <!-- explicit dependencies of this module in the Maven sense, although they are required by the Quarkus Maven plugin. -->
         <!-- Please update the rule whenever you change the dependencies of this module by running -->
         <!--     mvn process-resources -Pformat    from the root directory -->
-        <mvnd.builder.rule>camel-quarkus-file-deployment,camel-quarkus-file-watch-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
+        <mvnd.builder.rule>camel-quarkus-file-deployment,camel-quarkus-file-watch-deployment,camel-quarkus-quartz-deployment,camel-quarkus-support-policy-deployment</mvnd.builder.rule>
     </properties>
 
     <dependencies>
@@ -49,6 +49,10 @@
             <artifactId>camel-quarkus-file-watch</artifactId>
         </dependency>
         <dependency>
+            <groupId>org.apache.camel.quarkus</groupId>
+            <artifactId>camel-quarkus-quartz</artifactId>
+        </dependency>
+        <dependency>
             <groupId>io.quarkus</groupId>
             <artifactId>quarkus-resteasy</artifactId>
         </dependency>
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 a19ae83..3fb2a6c 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
@@ -40,5 +40,7 @@ public class FileRoutes extends RouteBuilder {
                 + "readLockTimeout=5000")
                         .to("file://target/" + READ_LOCK_OUT);
 
+        from("file://target/quartz?scheduler=quartz&scheduler.cron=0/1+*+*+*+*+?&repeatCount=0")
+                .to("file://target/quartz/out");
     }
 }
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 c7c3675..ae88f9f 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
@@ -28,9 +28,9 @@ import io.restassured.RestAssured;
 import io.restassured.http.ContentType;
 import io.restassured.path.json.JsonPath;
 import io.restassured.response.ValidatableResponse;
-import org.awaitility.Awaitility;
 import org.junit.jupiter.api.Test;
 
+import static org.awaitility.Awaitility.await;
 import static org.hamcrest.core.IsEqual.equalTo;
 
 @QuarkusTest
@@ -105,8 +105,32 @@ class FileTest {
                 .statusCode(204);
     }
 
+    @Test
+    public void quartzSchedulerFilePollingConsumer() throws InterruptedException {
+        String fileName = RestAssured.given()
+                .contentType(ContentType.TEXT)
+                .body(FILE_BODY)
+                .post("/file/create/quartz")
+                .then()
+                .statusCode(201)
+                .extract()
+                .body()
+                .asString();
+
+        String targetFileName = Paths.get(fileName).toFile().getName();
+        await().atMost(10, TimeUnit.SECONDS).until(() -> {
+            return Files.exists(Paths.get("target/quartz/out", targetFileName));
+        });
+
+        RestAssured
+                .get("/file/get/{folder}/{name}", "quartz/out", targetFileName)
+                .then()
+                .statusCode(200)
+                .body(equalTo(FILE_BODY));
+    }
+
     private static void awaitEvent(final Path dir, final Path file, final String type) {
-        Awaitility.await()
+        await()
                 .pollInterval(10, TimeUnit.MILLISECONDS)
                 .atMost(10, TimeUnit.SECONDS)
                 .until(() -> {