Skip to content

Commit

Permalink
Increase MockEndpoint assertion wait timeout for JMS resequence test
Browse files Browse the repository at this point in the history
Fixes #2957
  • Loading branch information
jamesnetherton committed Oct 15, 2024
1 parent f1b05ed commit de7d87c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.QueryParam;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
import org.apache.camel.CamelContext;
Expand Down Expand Up @@ -247,17 +248,28 @@ public void topicPubSub(@PathParam("topicName") String topicName, String message
topicResultB.assertIsSatisfied(5000);
}

@Path("/mock/{name}/{count}/{timeout}")
@Path("/resequence")
@Consumes(MediaType.TEXT_PLAIN)
@Produces(MediaType.APPLICATION_JSON)
@GET
public List<String> mock(@PathParam("name") String name, @PathParam("count") int count, @PathParam("timeout") int timeout) {
MockEndpoint mock = context.getEndpoint("mock:" + name, MockEndpoint.class);
mock.setExpectedMessageCount(count);
@POST
public List<String> resequence(@QueryParam("queueName") String queueName, String payload) {
String[] messages = payload.split(",");
MockEndpoint mock = context.getEndpoint("mock:resequence", MockEndpoint.class);
mock.setExpectedMessageCount(messages.length);
mock.setResultWaitTime(30000);

try {
mock.assertIsSatisfied(timeout);
for (String message : messages) {
produceJmsQueueMessage(queueName, message);
}

mock.assertIsSatisfied(10000);
} catch (InterruptedException e1) {
Thread.currentThread().interrupt();
} catch (Exception e) {
throw new RuntimeException(e);
}

return mock.getExchanges().stream().map(e -> e.getMessage().getBody(String.class)).collect(Collectors.toList());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestInstance;
import org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;

Expand Down Expand Up @@ -152,23 +151,19 @@ public void testJmsTransaction() {
.body(is("JMS Transaction Success"));
}

@DisabledIfEnvironmentVariable(named = "CI", matches = "true", disabledReason = "https://github.com/apache/camel-quarkus/issues/2957")
@Test
public void testResequence() {
final List<String> messages = Arrays.asList("a", "b", "c", "c", "d");
for (String msg : messages) {
RestAssured.given()
.body(msg)
.post("/messaging/{queueName}", queue)
.then()
.statusCode(201);
}
Collections.reverse(messages);
final List<String> actual = RestAssured.given()
.get("/messaging/mock/resequence/5/10000")
.contentType(ContentType.TEXT)
.queryParam("queueName", queue)
.body(String.join(",", messages))
.post("/messaging/resequence")
.then()
.statusCode(200)
.extract().body().jsonPath().getList(".", String.class);

Collections.reverse(messages);
Assertions.assertEquals(messages, actual);
}

Expand Down

0 comments on commit de7d87c

Please sign in to comment.