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 48f0de44b38c..fb21e60d9e70 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 @@ -50,8 +50,9 @@ public void configure() { + "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"); + from("file://target/test-files/quartz-scheduled?scheduler=quartz&scheduler.cron=0/1+*+*+*+*+?&repeatCount=0") + .convertBodyTo(String.class) + .to("mock:quartzScheduledFilePolling"); from("file://target/" + CONSUME_BATCH + "?" + "initialDelay=0&delay=100") 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 caeec3e14c23..e40969faaf45 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 @@ -184,22 +184,6 @@ public void fileReadLock_minLength() throws Exception { .statusCode(200); } - @Test - public void quartzSchedulerFilePollingConsumer() throws InterruptedException, UnsupportedEncodingException { - String fileName = createFile(FILE_BODY, "/file/create/quartz"); - - 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 String createFile(String content, String path) throws UnsupportedEncodingException { return createFile(content, path, "UTF-8", null); } diff --git a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTest.java b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTest.java index b42ca887d6ad..c71a7a3cfb75 100644 --- a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTest.java +++ b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTest.java @@ -34,6 +34,7 @@ import static org.apache.camel.quarkus.component.file.it.NonFlakyFileTestResource.IDEMPOTENT_FILE_CONTENT; import static org.apache.camel.quarkus.component.file.it.NonFlakyFileTestResource.IDEMPOTENT_FILE_NAME; import static org.apache.camel.quarkus.component.file.it.NonFlakyFileTestResource.POLL_ENRICH_FILE_CONTENT; +import static org.apache.camel.quarkus.component.file.it.NonFlakyFileTestResource.QUARTZ_SCHEDULED_FILE_CONTENT; import static org.apache.camel.quarkus.component.file.it.NonFlakyFileTestResource.TEST_FILES_FOLDER; import static org.awaitility.Awaitility.await; import static org.hamcrest.core.IsEqual.equalTo; @@ -95,4 +96,14 @@ public void pollEnrichShouldSetExchangeBodyWithFileContent() { .body(Matchers.is(POLL_ENRICH_FILE_CONTENT)); } + @Test + public void quartzScheduledFilePollingShouldSucceed() { + await().atMost(10, TimeUnit.SECONDS).until( + () -> RestAssured + .get("/file/getFromMock/quartzScheduledFilePolling") + .then() + .extract().asString(), + equalTo(QUARTZ_SCHEDULED_FILE_CONTENT)); + } + } diff --git a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTestResource.java b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTestResource.java index fecf1404dd5c..0cfa91beb01d 100644 --- a/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTestResource.java +++ b/integration-tests/file/src/test/java/org/apache/camel/quarkus/component/file/it/NonFlakyFileTestResource.java @@ -40,6 +40,8 @@ public class NonFlakyFileTestResource implements QuarkusTestResourceLifecycleMan static final String IDEMPOTENT_FILE_CONTENT = IDEMPOTENT_FILE_NAME + "-CONTENT"; static final String POLL_ENRICH_FILE_NAME = "poll-enrich-file"; static final String POLL_ENRICH_FILE_CONTENT = POLL_ENRICH_FILE_NAME + "-CONTENT"; + static final String QUARTZ_SCHEDULED_FILE_NAME = "quartz-schedule-file"; + static final String QUARTZ_SCHEDULED_FILE_CONTENT = QUARTZ_SCHEDULED_FILE_NAME + "-CONTENT"; private final List createdTestFiles = new ArrayList(); @@ -55,6 +57,8 @@ public Map start() { createTestFile("poll-enrich", POLL_ENRICH_FILE_NAME); + createTestFile("quartz-scheduled", QUARTZ_SCHEDULED_FILE_NAME); + ensureAllTestFilesCreatedWithExpectedContent(); } catch (Exception ex) { throw new RuntimeException("Problem while initializing test files", ex);