Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

file: fix a race condition where an exchange is missed due to a call … #3596

Merged
merged 1 commit into from
Mar 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,17 +91,22 @@ public void startRoute(String routeId) throws Exception {

@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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,12 @@ public void idempotent() throws IOException {
.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);
Expand Down