add Awaitility + suppress warnings #2127
diff --git a/integration-tests/hazelcast/pom.xml b/integration-tests/hazelcast/pom.xml
index 4d05fd4..1a60a97 100644
--- a/integration-tests/hazelcast/pom.xml
+++ b/integration-tests/hazelcast/pom.xml
@@ -79,6 +79,11 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
+ <dependency>
+ <groupId>org.awaitility</groupId>
+ <artifactId>awaitility</artifactId>
+ <scope>test</scope>
+ </dependency>
<!-- The following dependencies guarantee that this module is built after them. You can update them by running `mvn process-resources -Pformat -N` from the source tree root directory -->
<dependency>
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastCollectionResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastCollectionResource.java
index a876c47..63c3966 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastCollectionResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastCollectionResource.java
@@ -52,8 +52,6 @@
/**
* init endpoints
- *
- * @param startupEvent
*/
public abstract void init(StartupEvent startupEvent);
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastMapResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastMapResource.java
index 7a13ebe..16ae67a 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastMapResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/AbstractHazelcastMapResource.java
@@ -55,8 +55,6 @@
/**
* init endpoints
- *
- * @param startupEvent
*/
public abstract void init(StartupEvent startupEvent);
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicResource.java
index ace6bae..47bdd4b 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicResource.java
@@ -18,11 +18,14 @@
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
+import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import org.apache.camel.ProducerTemplate;
@@ -31,6 +34,8 @@
import org.jboss.logging.Logger;
@Path("/hazelcast/atomic")
+@Produces(MediaType.TEXT_PLAIN)
+@Consumes(MediaType.TEXT_PLAIN)
@ApplicationScoped
public class HazelcastAtomicResource {
private static final Logger LOG = Logger.getLogger(HazelcastAtomicResource.class);
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentResource.java
index eb54501..88c162b 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentResource.java
@@ -55,7 +55,7 @@
}
@GET
- public List get() {
+ public List<String> get() {
MockEndpoint mockEndpoint = context.getEndpoint(MOCK_IDEMPOTENT_ADDED, MockEndpoint.class);
return mockEndpoint.getReceivedExchanges().stream().map(
exchange -> exchange.getIn().getBody(String.class))
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapResource.java
index bf27731..36a35fb 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapResource.java
@@ -57,9 +57,10 @@
mockUpdatedEndpoint = MOCK_MAP_UPDATED;
}
+ @SuppressWarnings("unchecked")
@POST
@Path("get")
- public Map getAll(Set<String> oids) {
+ public Map<String, Object> getAll(Set<String> oids) {
Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastConstants.OPERATION, HazelcastOperation.GET_ALL);
headers.put(HazelcastConstants.OBJECT_ID, oids);
@@ -97,9 +98,10 @@
return getValues(mockEvictedEndpoint);
}
+ @SuppressWarnings("unchecked")
@POST
@Path("get/query")
- public Collection query(String sqlQuery) {
+ public Collection<String> query(String sqlQuery) {
Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastConstants.OPERATION, HazelcastOperation.QUERY);
headers.put(HazelcastConstants.QUERY, sqlQuery);
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueResource.java
index e0bfec5..7275da0 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueResource.java
@@ -106,7 +106,7 @@
@DELETE
@Path("drain")
public List<String> drainTo() {
- List<String> result = new ArrayList();
+ List<String> result = new ArrayList<>();
Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastConstants.OPERATION, HazelcastOperation.DRAIN_TO);
headers.put(HazelcastConstants.DRAIN_TO_COLLECTION, result);
@@ -117,8 +117,6 @@
/**
* add list of values to queue with poll consumer
*
- * @param values
- * @return
*/
@PUT
@Path("poll/list")
diff --git a/integration-tests/hazelcast/src/main/resources/hazelcast.xml b/integration-tests/hazelcast/src/main/resources/hazelcast.xml
index b05c0c1..5361d21 100644
--- a/integration-tests/hazelcast/src/main/resources/hazelcast.xml
+++ b/integration-tests/hazelcast/src/main/resources/hazelcast.xml
@@ -22,7 +22,7 @@
http://www.hazelcast.com/schema/config/hazelcast-config-4.0.xsd">
<cluster-name>dev</cluster-name>
<network>
- <port auto-increment="true" port-count="100">5701</port>
+ <port>5701</port>
<join>
<multicast enabled="false"/>
<tcp-ip enabled="true">
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentTest.java
index 7c9a02f..a750a59 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentTest.java
@@ -16,23 +16,27 @@
*/
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.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
-import static org.hamcrest.Matchers.not;
+import static org.awaitility.Awaitility.await;
@QuarkusTest
@TestHTTPEndpoint(HazelcastIdempotentResource.class)
@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastIdempotentTest {
+ @SuppressWarnings("unchecked")
@Test
public void testIdempotentRepository() {
// add value with key 1
@@ -76,14 +80,9 @@
.statusCode(202);
// get all values added to the map
- given()
- .contentType(ContentType.JSON)
- .when()
- .get()
- .then()
- .body("$", hasSize(3))
- .body("$", hasItems("val1", "val2"))
- .body("$", not(hasItems("val4")));
-
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get().then().extract().body().as(List.class);
+ return body.size() == 3 && body.containsAll(Arrays.asList("val1", "val2")) && !body.contains("val4");
+ });
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceTest.java
index f6b173f..1385e67 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceTest.java
@@ -16,13 +16,15 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
+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 org.junit.jupiter.api.Test;
-import static io.restassured.RestAssured.given;
-import static org.hamcrest.Matchers.equalTo;
+import static org.awaitility.Awaitility.await;
@QuarkusTest
@TestHTTPEndpoint(HazelcastInstanceResource.class)
@@ -32,11 +34,7 @@
@Test
public void testInstance() {
HazelcastTestResource.addMemberToCluster();
- given()
- .when()
- .get("/added")
- .then()
- .body(equalTo("1"));
-
+ await().atMost(10L, TimeUnit.SECONDS)
+ .until(() -> RestAssured.get("/added").then().extract().body().asString().equals("1"));
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastListTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastListTest.java
index d334fb8..a5e4c60 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastListTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastListTest.java
@@ -17,23 +17,26 @@
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.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
+import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
@TestHTTPEndpoint(HazelcastListResource.class)
@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastListTest {
+ @SuppressWarnings("unchecked")
@Test
public void testList() {
// add one value
@@ -130,23 +133,17 @@
.statusCode(202);
// verify that the consumer has received all added values
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/added")
- .then()
- .body("$", hasSize(7))
- .body("$", hasItems("foo1", "foo2", "foo3", "foo4", "foo5", "foo6", "foo7"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/added").then().extract().body().as(List.class);
+ return body.size() == 7 && body.containsAll(Arrays.asList("foo1", "foo2", "foo3", "foo4", "foo5", "foo6", "foo7"));
+ });
// verify that the consumer has received all removed values
// we can't expect foo1 because we gave it just the index, not the value. but the size should be 5
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/deleted")
- .then()
- .body("$", hasSize(5))
- .body("$", hasItems("foo2", "foo3", "foo5", "foo6"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/deleted").then().extract().body().as(List.class);
+ return body.size() == 5 && body.containsAll(Arrays.asList("foo2", "foo3", "foo5", "foo6"));
+ });
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapTest.java
index 6a994d4..77b674b 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMapTest.java
@@ -17,25 +17,27 @@
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;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
@TestHTTPEndpoint(HazelcastMapResource.class)
@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastMapTest {
+ @SuppressWarnings("unchecked")
@Test
public void testMap() {
// add one value
@@ -59,7 +61,7 @@
// add one value with TTL
request = request.withId("2")
.withVaLue("val2")
- .withTtl(Long.valueOf(5), TimeUnit.MINUTES);
+ .withTtl(5L, TimeUnit.MINUTES);
given()
.contentType(ContentType.JSON)
.body(request)
@@ -165,40 +167,28 @@
.statusCode(202);
// verify that the consumer has received all the added values
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/added")
- .then()
- .body("$", hasSize(2))
- .body("$", hasItems("1", "2"));
+ 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 one removed value with key = 1
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/deleted")
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("1"));
+ 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");
+ });
// verify that the consumer has received one evicted value with key = 2
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/evicted")
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("2"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/evicted").then().extract().body().as(List.class);
+ return body.size() == 1 && body.contains("2");
+ });
// verify that the consumer has received one updated value with key = 2
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/updated")
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("2"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/updated").then().extract().body().as(List.class);
+ return body.size() == 1 && body.contains("2");
+ });
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMultimapTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMultimapTest.java
index a02b2ed..c3b9955 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMultimapTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastMultimapTest.java
@@ -16,16 +16,20 @@
*/
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;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
@@ -35,6 +39,7 @@
@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastMultimapTest {
+ @SuppressWarnings("unchecked")
@Test
public void testMultimap() {
// add one value
@@ -120,7 +125,7 @@
// add value with TTL
request = request.withId("2")
.withVaLue("val2.1")
- .withTtl(Long.valueOf(5), TimeUnit.MINUTES);
+ .withTtl(5L, TimeUnit.MINUTES);
given()
.contentType(ContentType.JSON)
.body(request)
@@ -161,21 +166,15 @@
.statusCode(202);
// verify that the consumer has received all the added values
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/added")
- .then()
- .body("$", hasSize(3))
- .body("$", hasItems("1", "2"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/added").then().extract().body().as(List.class);
+ return body.size() == 3 && body.containsAll(Arrays.asList("1", "2"));
+ });
// verify that the consumer has received one removed value with key = 1
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/deleted")
- .then()
- .body("$", hasSize(2))
- .body("$", hasItems("1"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/deleted").then().extract().body().as(List.class);
+ return body.size() == 2 && body.contains("1");
+ });
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyTest.java
index bd7f1a6..b6d2a30 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyTest.java
@@ -16,24 +16,28 @@
*/
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.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
+import static org.awaitility.Awaitility.await;
@QuarkusTest
@TestHTTPEndpoint(HazelcastPolicyResource.class)
@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastPolicyTest {
+ @SuppressWarnings("unchecked")
@Test
public void testPolicy() {
-
// send exchanges
given()
.contentType(ContentType.JSON)
@@ -60,13 +64,9 @@
.statusCode(202);
// should receive the 3 exchanges
- given()
- .contentType(ContentType.JSON)
- .when()
- .get()
- .then()
- .body("$", hasSize(3))
- .body("$", hasItems("foo1", "foo2", "foo3"));
-
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get().then().extract().body().as(List.class);
+ return body.size() == 3 && body.containsAll(Arrays.asList("foo1", "foo2", "foo3"));
+ });
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueTest.java
index e9dd3ad..b8ad960 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueTest.java
@@ -17,15 +17,19 @@
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.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
+import static org.awaitility.Awaitility.await;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
@@ -119,13 +123,13 @@
.statusCode(202);
// remaining capacity :: no max capacity so max capacity of the queue is Integer.MAX_VALUE
- Integer remainingCapacity = Integer.MAX_VALUE - 3;
+ int remainingCapacity = Integer.MAX_VALUE - 3;
given()
.contentType(ContentType.JSON)
.when()
.get("/remainingCapacity")
.then()
- .body(equalTo(remainingCapacity.toString()));
+ .body(equalTo(Integer.toString(remainingCapacity)));
// drainTo : delete all values and return to list
given()
@@ -138,6 +142,7 @@
}
+ @SuppressWarnings("unchecked")
@Test
@Disabled
public void testPollConsumer() {
@@ -151,12 +156,9 @@
.statusCode(202);
// retrieve values from consumer
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/polled")
- .then()
- .body("$", hasSize(3))
- .body("$", hasItems("v1", "v2", "v3"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/polled").then().extract().body().as(List.class);
+ return body.size() == 3 && body.containsAll(Arrays.asList("v1", "v2", "v3"));
+ });
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapTest.java
index c194e14..222e545 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapTest.java
@@ -56,7 +56,7 @@
// add one value with TTL
request = request.withId("2")
.withVaLue("val2")
- .withTtl(Long.valueOf(5), TimeUnit.MINUTES);
+ .withTtl(5L, TimeUnit.MINUTES);
given()
.contentType(ContentType.JSON)
.body(request)
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaTest.java
index 80b435e..45429aa 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaTest.java
@@ -16,15 +16,18 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
+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.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
+import static org.awaitility.Awaitility.await;
@QuarkusTest
@TestHTTPEndpoint(HazelcastSedaResource.class)
@@ -42,13 +45,8 @@
.statusCode(202);
// verify that the consumer received the message
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/fifo")
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("foo1"));
+ await().atMost(10L, TimeUnit.SECONDS)
+ .until(() -> RestAssured.get("/fifo").then().extract().body().as(List.class).contains("foo1"));
}
@Test
@@ -63,13 +61,8 @@
.statusCode(202);
// verify that the consumer received the message
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/in")
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("foo1"));
+ await().atMost(10L, TimeUnit.SECONDS)
+ .until(() -> RestAssured.get("/in").then().extract().body().as(List.class).contains("foo1"));
}
@Test
@@ -83,13 +76,8 @@
.statusCode(202);
// verify that the consumer received the message
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/out")
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("foo1"));
+ await().atMost(10L, TimeUnit.SECONDS)
+ .until(() -> RestAssured.get("/out").then().extract().body().as(List.class).contains("foo1"));
}
@Test
@@ -103,12 +91,7 @@
.statusCode(202);
// verify that the consumer received the message
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/out/transacted")
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("foo1"));
+ await().atMost(10L, TimeUnit.SECONDS)
+ .until(() -> RestAssured.get("/out/transacted").then().extract().body().as(List.class).contains("foo1"));
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSetTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSetTest.java
index 13340ed..d92d1ec 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSetTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSetTest.java
@@ -17,22 +17,25 @@
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.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
+import static org.awaitility.Awaitility.await;
@QuarkusTest
@TestHTTPEndpoint(HazelcastSetResource.class)
@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastSetTest {
+ @SuppressWarnings("unchecked")
@Test
public void testSet() {
// add one value
@@ -108,21 +111,15 @@
.statusCode(202);
// verify that the consumer has received all added values
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/added")
- .then()
- .body("$", hasSize(7))
- .body("$", hasItems("foo1", "foo2", "foo3", "foo4", "foo5", "foo6", "foo7"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/added").then().extract().body().as(List.class);
+ return body.size() == 7 && body.containsAll(Arrays.asList("foo1", "foo2", "foo3", "foo4", "foo5", "foo6", "foo7"));
+ });
// verify that the consumer has received all removed values
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/deleted")
- .then()
- .body("$", hasSize(5))
- .body("$", hasItems("foo1", "foo2", "foo3", "foo5", "foo6"));
+ await().atMost(10L, TimeUnit.SECONDS).until(() -> {
+ List<String> body = RestAssured.get("/deleted").then().extract().body().as(List.class);
+ return body.size() == 5 && body.containsAll(Arrays.asList("foo1", "foo2", "foo3", "foo5", "foo6"));
+ });
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicTest.java
index 5e525f8..8758835 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicTest.java
@@ -16,15 +16,18 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
+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.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.hasSize;
+import static org.awaitility.Awaitility.await;
@QuarkusTest
@TestHTTPEndpoint(HazelcastTopicResource.class)
@@ -42,12 +45,7 @@
.statusCode(202);
// verify that the consumer has received the topic
- given()
- .contentType(ContentType.JSON)
- .when()
- .get()
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("test1"));
+ await().atMost(10L, TimeUnit.SECONDS)
+ .until(() -> RestAssured.get().then().extract().body().as(List.class).contains("test1"));
}
}