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/07 12:40:13 UTC
[camel-quarkus] branch main updated: file: fix a race condition where an exchange is missed due to a call to mockEndpoint.reset() #3584
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 40029d1 file: fix a race condition where an exchange is missed due to a call to mockEndpoint.reset() #3584
40029d1 is described below
commit 40029d10bfb5f717a602bb2f0c30950217643529
Author: aldettinger <al...@gmail.com>
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);