This is an automated email from the ASF dual-hosted git repository. jamesnetherton pushed a commit to branch 2.7.x in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
commit 092dcc3ba0c09c98502367017828314a00ddb1cc Author: aldettinger <[email protected]> AuthorDate: Mon Mar 7 11:26:17 2022 +0100 file: fix a race condition where an exchange is missed due to a call to mockEndpoint.reset() #3584 --- .../apache/camel/quarkus/component/file/it/FileResource.java | 11 ++++++++--- .../org/apache/camel/quarkus/component/file/it/FileTest.java | 6 ++++++ 2 files changed, 14 insertions(+), 3 deletions(-) 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 3695917..e5b8f79 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 @@ -91,17 +91,22 @@ public class FileResource { @Path("/getFromMock/{mockId}") @GET - public String getFromMock(@PathParam("mockId") String mockId) throws Exception { + public String getFromMock(@PathParam("mockId") String mockId) { MockEndpoint mockEndpoint = context.getEndpoint("mock:" + mockId, MockEndpoint.class); String result = mockEndpoint.getExchanges().stream().map(e -> e.getIn().getBody(String.class)) .collect(Collectors.joining(SEPARATOR)); - mockEndpoint.reset(); - return result; } + @Path("/resetMock/{mockId}") + @GET + public void resetMock(@PathParam("mockId") String mockId) { + MockEndpoint mockEndpoint = context.getEndpoint("mock:" + mockId, MockEndpoint.class); + mockEndpoint.reset(); + } + @Path("/create/{folder}") @POST @Consumes(MediaType.APPLICATION_OCTET_STREAM) 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 ded7443..2922d7d 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 @@ -141,6 +141,12 @@ class FileTest { .extract().asString(), equalTo(FILE_CONTENT_01)); + // clear the mock to assert that FILE_CONTENT_01 will not be received again even if presented a second time to the route + RestAssured + .get("/file/resetMock/idempotent") + .then() + .statusCode(204); + // move file back Path donePath = Paths.get(fileName01.replaceFirst("target/idempotent", "target/idempotent/done")); Path targetPath = Paths.get(fileName01);
