This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit e90944a16558f9492a5e0e677a183cf23f39ad53 Author: Philippe Schaller <[email protected]> AuthorDate: Sun Apr 19 17:19:47 2020 +0200 Add integration test for a read lock on minimal length of a file --- .../quarkus/component/file/it/FileRoutes.java | 44 ++++++++++++++++++++++ .../camel/quarkus/component/file/it/FileTest.java | 22 +++++++++++ 2 files changed, 66 insertions(+) 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 new file mode 100644 index 0000000..a19ae83 --- /dev/null +++ b/integration-tests/file/src/main/java/org/apache/camel/quarkus/component/file/it/FileRoutes.java @@ -0,0 +1,44 @@ +/* + * 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.file.it; + +import javax.enterprise.context.ApplicationScoped; + +import org.apache.camel.builder.RouteBuilder; + +@ApplicationScoped +public class FileRoutes extends RouteBuilder { + + public static final String READ_LOCK_IN = "read-lock-in"; + public static final String READ_LOCK_OUT = "read-lock-out"; + + @Override + public void configure() { + from("file://target/" + READ_LOCK_IN + "?" + + "initialDelay=0&" + + "move=.done&" + + "delay=1000&" + + "readLock=changed&" + + "readLockMinAge=1000&" + + "readLockMinLength=100&" + + "readLockCheckInterval=2000&" + + "readLockLoggingLevel=TRACE&" + + "readLockTimeout=5000") + .to("file://target/" + READ_LOCK_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 6497cea..4452c1f 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 @@ -83,6 +83,28 @@ class FileTest { } + @Test + public void fileReadLock_minLength() throws Exception { + // Create a new file + String fileName = RestAssured.given() + .contentType(ContentType.TEXT) + .body("") + .post("/file/create/" + FileRoutes.READ_LOCK_IN) + .then() + .statusCode(201) + .extract() + .body() + .asString(); + + Thread.sleep(10_000L); + + // Read the file that should not be there + RestAssured + .get("/file/get/" + FileRoutes.READ_LOCK_OUT + "/" + Paths.get(fileName).getFileName()) + .then() + .statusCode(204); + } + private static void awaitEvent(final Path dir, final Path file, final String type) { Awaitility.await() .pollInterval(10, TimeUnit.MILLISECONDS)
