add HazelcastReplicatedmapConsumer test fixes
*/
package org.apache.camel.quarkus.component.hazelcast.it;
+import java.util.Arrays;
+import java.util.List;
import java.util.concurrent.TimeUnit;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.RestAssured;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.component.hazelcast.it.model.HazelcastMapRequest;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
+import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
@@ -89,7 +93,7 @@ public class HazelcastReplicatedmapTest {
.then()
.body(equalTo("true"));
- // verify that map doesn't contain value "val2"
+ // verify that map doesn't contain value "val3"
given()
.contentType(ContentType.JSON)
.when()
@@ -119,5 +123,17 @@ public class HazelcastReplicatedmapTest {
.then()
.statusCode(202);
+ // verify that the consumer has received all added keys
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/added").then().extract().body().as(List.class);
+ return body.size() == 2 && body.containsAll(Arrays.asList("1", "2"));
+ });
+
+ // verify that the consumer has received all removed keys
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/deleted").then().extract().body().as(List.class);
+ return body.size() == 1 && body.contains("1");
+ });
+
}
}
