You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by pp...@apache.org on 2021/01/08 13:43:28 UTC
[camel-quarkus] branch master updated: Add more integration tests
for camel-hazelcast extension #2094
This is an automated email from the ASF dual-hosted git repository.
ppalaga pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git
The following commit(s) were added to refs/heads/master by this push:
new beba017 Add more integration tests for camel-hazelcast extension #2094
beba017 is described below
commit beba017629240b76c63aad5a4328793eac40d886
Author: Zineb Bendhiba <be...@gmail.com>
AuthorDate: Wed Dec 23 17:38:46 2020 +0100
Add more integration tests for camel-hazelcast extension #2094
---
integration-tests/hazelcast/pom.xml | 23 +++-
.../it/AbstractHazelcastCollectionResource.java | 27 ++--
.../hazelcast/it/AbstractHazelcastMapResource.java | 9 +-
.../hazelcast/it/HazelcastAtomicResource.java | 9 +-
...ource.java => HazelcastIdempotentResource.java} | 24 ++--
...esource.java => HazelcastInstanceResource.java} | 43 +++----
.../hazelcast/it/HazelcastMapResource.java | 6 +-
...cResource.java => HazelcastPolicyResource.java} | 27 ++--
.../hazelcast/it/HazelcastQueueResource.java | 140 +++++++++++++++++++++
...ource.java => HazelcastRingbufferResource.java} | 56 +++++----
.../component/hazelcast/it/HazelcastRoutes.java | 107 +++++++++++++++-
.../hazelcast/it/HazelcastSedaResource.java | 112 +++++++++++++++++
.../hazelcast/it/HazelcastTopicResource.java | 7 +-
.../src/main/resources/application.properties | 17 +++
.../hazelcast/src/main/resources/hazelcast.xml | 34 +++++
.../hazelcast/it/HazelcastAtomicTest.java | 3 +-
.../hazelcast/it/HazelcastIdempotentIT.java | 23 ++++
...edmapTest.java => HazelcastIdempotentTest.java} | 87 ++++---------
.../hazelcast/it/HazelcastInstanceIT.java | 23 ++++
...stTopicTest.java => HazelcastInstanceTest.java} | 30 ++---
.../component/hazelcast/it/HazelcastListTest.java | 3 +-
.../component/hazelcast/it/HazelcastMapTest.java | 3 +-
.../hazelcast/it/HazelcastMultimapTest.java | 3 +-
.../component/hazelcast/it/HazelcastPolicyIT.java | 23 ++++
...castTopicTest.java => HazelcastPolicyTest.java} | 38 ++++--
.../component/hazelcast/it/HazelcastQueueIT.java | 23 ++++
...elcastListTest.java => HazelcastQueueTest.java} | 109 ++++++++--------
.../hazelcast/it/HazelcastReplicatedmapIT.java | 23 ++++
.../hazelcast/it/HazelcastReplicatedmapTest.java | 3 +-
.../hazelcast/it/HazelcastRingbufferIT.java | 23 ++++
...tomicTest.java => HazelcastRingbufferTest.java} | 58 ++++++---
.../component/hazelcast/it/HazelcastSedaIT.java | 23 ++++
...azelcastSetTest.java => HazelcastSedaTest.java} | 89 ++++++-------
.../component/hazelcast/it/HazelcastSetTest.java | 3 +-
.../hazelcast/it/HazelcastTestResource.java | 53 ++++++++
.../component/hazelcast/it/HazelcastTopicTest.java | 3 +-
poms/bom-test/pom.xml | 6 -
37 files changed, 936 insertions(+), 357 deletions(-)
diff --git a/integration-tests/hazelcast/pom.xml b/integration-tests/hazelcast/pom.xml
index dae841b..724f906 100644
--- a/integration-tests/hazelcast/pom.xml
+++ b/integration-tests/hazelcast/pom.xml
@@ -26,8 +26,8 @@
</parent>
<artifactId>camel-quarkus-integration-test-hazelcast</artifactId>
- <name>Camel Quarkus :: Integration Tests :: Hazelcast Atomic Number</name>
- <description>Integration tests for Camel Quarkus Hazelcast Atomic Number extension</description>
+ <name>Camel Quarkus :: Integration Tests :: Hazelcast</name>
+ <description>Integration tests for Camel Quarkus Hazelcast extension</description>
<dependencyManagement>
<dependencies>
@@ -54,6 +54,10 @@
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-log</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct</artifactId>
+ </dependency>
<dependency>
<groupId>io.quarkus</groupId>
@@ -75,9 +79,20 @@
<artifactId>rest-assured</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>
- <groupId>com.hazelcast</groupId>
- <artifactId>quarkus-test-hazelcast</artifactId>
+ <groupId>org.apache.camel.quarkus</groupId>
+ <artifactId>camel-quarkus-direct-deployment</artifactId>
+ <version>${project.version}</version>
+ <type>pom</type>
+ <scope>test</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>*</groupId>
+ <artifactId>*</artifactId>
+ </exclusion>
+ </exclusions>
</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 -->
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 21e4492..a876c47 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
@@ -16,10 +16,7 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
-import java.util.Collection;
-import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.stream.Collectors;
import javax.inject.Inject;
@@ -68,7 +65,7 @@ public abstract class AbstractHazelcastCollectionResource {
@PUT
@Path("all")
- public Response addAll(Collection values) {
+ public Response addAll(List<String> values) {
producerTemplate.sendBodyAndHeader(endpointUri, values, HazelcastConstants.OPERATION, HazelcastOperation.ADD_ALL);
return Response.accepted().build();
}
@@ -76,24 +73,20 @@ public abstract class AbstractHazelcastCollectionResource {
@DELETE
@Path("value")
public Response delete(String value) {
- Map<String, Object> headers = new HashMap<>();
- headers.put(HazelcastConstants.OPERATION, HazelcastOperation.REMOVE_VALUE);
- producerTemplate.sendBodyAndHeaders(endpointUri, value, headers);
+ producerTemplate.sendBodyAndHeader(endpointUri, value, HazelcastConstants.OPERATION, HazelcastOperation.REMOVE_VALUE);
return Response.accepted().build();
}
@DELETE
@Path("all")
- public Response delete(Collection values) {
- Map<String, Object> headers = new HashMap<>();
- headers.put(HazelcastConstants.OPERATION, HazelcastOperation.REMOVE_ALL);
- producerTemplate.sendBodyAndHeaders(endpointUri, values, headers);
+ public Response delete(List<String> values) {
+ producerTemplate.sendBodyAndHeader(endpointUri, values, HazelcastConstants.OPERATION, HazelcastOperation.REMOVE_ALL);
return Response.accepted().build();
}
@POST
@Path("retain")
- public Response retainAll(Collection values) {
+ public Response retainAll(List<String> values) {
producerTemplate.sendBodyAndHeader(endpointUri, values, HazelcastConstants.OPERATION, HazelcastOperation.RETAIN_ALL);
return Response.accepted().build();
}
@@ -110,15 +103,11 @@ public abstract class AbstractHazelcastCollectionResource {
return getValues(mockDeletedEndpoint);
}
- private List<String> getValues(String endpointName) {
+ public List<String> getValues(String endpointName) {
LOG.infof("getting response from mock endpoint %s", endpointName);
MockEndpoint mockEndpoint = context.getEndpoint(endpointName, MockEndpoint.class);
- List<String> values = mockEndpoint.getReceivedExchanges().stream().map(
- exchange -> {
- ItemEvent itemEvent = exchange.getIn().getBody(ItemEvent.class);
- return (String) itemEvent.getItem();
- })
+ return mockEndpoint.getReceivedExchanges().stream().map(
+ exchange -> (String) exchange.getIn().getBody(ItemEvent.class).getItem())
.collect(Collectors.toList());
- return values;
}
}
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 e3b8ad0..7a13ebe 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
@@ -120,22 +120,21 @@ public abstract class AbstractHazelcastMapResource {
@GET
@Path("added")
- public List getAddedValues() {
+ public List<String> getAddedValues() {
return getValues(mockAddedEndpoint);
}
@GET
@Path("deleted")
- public List getDeletedValues() {
+ public List<String> getDeletedValues() {
return getValues(mockDeletedEndpoint);
}
- protected List getValues(String endpointName) {
+ protected List<String> getValues(String endpointName) {
LOG.infof("getting response from mock endpoint %s", endpointName);
MockEndpoint mockEndpoint = context.getEndpoint(endpointName, MockEndpoint.class);
- List<String> values = mockEndpoint.getReceivedExchanges().stream().map(
+ return mockEndpoint.getReceivedExchanges().stream().map(
exchange -> exchange.getIn().getHeader(HazelcastConstants.OBJECT_ID, String.class))
.collect(Collectors.toList());
- return values;
}
}
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 6c57f3c..ace6bae 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
@@ -51,30 +51,27 @@ public class HazelcastAtomicResource {
@GET()
public Long get() {
LOG.infof("getting one atomic value");
- Long value = producerTemplate.requestBodyAndHeader(
+ return producerTemplate.requestBodyAndHeader(
"hazelcast-atomicvalue:foo-atomic",
null, HazelcastConstants.OPERATION, HazelcastOperation.GET, Long.class);
- return value;
}
@GET
@Path("increment")
public Long incrementAndGet() {
LOG.infof("increment and get new value");
- Long value = producerTemplate.requestBodyAndHeader(
+ return producerTemplate.requestBodyAndHeader(
"hazelcast-atomicvalue:foo-atomic",
null, HazelcastConstants.OPERATION, HazelcastOperation.INCREMENT, Long.class);
- return value;
}
@GET
@Path("decrement")
public Long decrementAndGet() {
LOG.infof("decrement and get new value");
- Long value = producerTemplate.requestBodyAndHeader(
+ return producerTemplate.requestBodyAndHeader(
"hazelcast-atomicvalue:foo-atomic",
null, HazelcastConstants.OPERATION, HazelcastOperation.DECREMENT, Long.class);
- return value;
}
@DELETE
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentResource.java
similarity index 67%
copy from integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
copy to integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentResource.java
index 3ce0671..eb54501 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentResource.java
@@ -29,20 +29,18 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import com.hazelcast.topic.impl.DataAwareMessage;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.hazelcast.HazelcastConstants;
-import org.apache.camel.component.hazelcast.HazelcastOperation;
import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.quarkus.component.hazelcast.it.model.HazelcastMapRequest;
-import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_TOPIC_RECEIVED;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_IDEMPOTENT_ADDED;
-@Path("/hazelcast/topic")
+@Path("/hazelcast/instance")
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
-public class HazelcastTopicResource {
+public class HazelcastIdempotentResource {
@Inject
ProducerTemplate producerTemplate;
@@ -51,18 +49,16 @@ public class HazelcastTopicResource {
CamelContext context;
@POST
- public Response publish(String message) {
- producerTemplate.sendBodyAndHeader("hazelcast-topic:foo-topic", message, HazelcastConstants.OPERATION,
- HazelcastOperation.PUBLISH);
+ public Response add(HazelcastMapRequest request) {
+ producerTemplate.sendBodyAndHeader("direct:in-idempotent", request.getValue(), "messageId", request.getId());
return Response.accepted().build();
}
@GET
- public List getValues() {
- MockEndpoint mockEndpoint = context.getEndpoint(MOCK_TOPIC_RECEIVED, MockEndpoint.class);
- List<Object> values = mockEndpoint.getReceivedExchanges().stream().map(
- exchange -> exchange.getMessage().getBody(DataAwareMessage.class).getMessageObject())
+ public List get() {
+ MockEndpoint mockEndpoint = context.getEndpoint(MOCK_IDEMPOTENT_ADDED, MockEndpoint.class);
+ return mockEndpoint.getReceivedExchanges().stream().map(
+ exchange -> exchange.getIn().getBody(String.class))
.collect(Collectors.toList());
- return values;
}
}
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceResource.java
similarity index 55%
copy from integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
copy to integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceResource.java
index 3ce0671..158ee95 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceResource.java
@@ -16,53 +16,44 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
-import java.util.List;
-import java.util.stream.Collectors;
-
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
-import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import com.hazelcast.topic.impl.DataAwareMessage;
import org.apache.camel.CamelContext;
-import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.hazelcast.HazelcastConstants;
-import org.apache.camel.component.hazelcast.HazelcastOperation;
import org.apache.camel.component.mock.MockEndpoint;
-import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_TOPIC_RECEIVED;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_INSTANCE_ADDED;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_INSTANCE_REMOVED;
-@Path("/hazelcast/topic")
+@Path("/hazelcast/instance")
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
-public class HazelcastTopicResource {
-
- @Inject
- ProducerTemplate producerTemplate;
+public class HazelcastInstanceResource {
@Inject
CamelContext context;
- @POST
- public Response publish(String message) {
- producerTemplate.sendBodyAndHeader("hazelcast-topic:foo-topic", message, HazelcastConstants.OPERATION,
- HazelcastOperation.PUBLISH);
- return Response.accepted().build();
+ @GET
+ @Path("added")
+ public Integer added() {
+ return getValues(MOCK_INSTANCE_ADDED);
}
@GET
- public List getValues() {
- MockEndpoint mockEndpoint = context.getEndpoint(MOCK_TOPIC_RECEIVED, MockEndpoint.class);
- List<Object> values = mockEndpoint.getReceivedExchanges().stream().map(
- exchange -> exchange.getMessage().getBody(DataAwareMessage.class).getMessageObject())
- .collect(Collectors.toList());
- return values;
+ @Path("deleted")
+ public Integer deleted() {
+ return getValues(MOCK_INSTANCE_REMOVED);
}
+
+ public Integer getValues(String endpointName) {
+ MockEndpoint mockEndpoint = context.getEndpoint(endpointName, MockEndpoint.class);
+ return mockEndpoint.getReceivedExchanges().size();
+ }
+
}
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 454c4a9..bf27731 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
@@ -59,7 +59,7 @@ public class HazelcastMapResource extends AbstractHazelcastMapResource {
@POST
@Path("get")
- public Map getAll(Set oids) {
+ public Map getAll(Set<String> oids) {
Map<String, Object> headers = new HashMap<>();
headers.put(HazelcastConstants.OPERATION, HazelcastOperation.GET_ALL);
headers.put(HazelcastConstants.OBJECT_ID, oids);
@@ -68,7 +68,7 @@ public class HazelcastMapResource extends AbstractHazelcastMapResource {
@GET
@Path("updated")
- public List getUpdatedValues() {
+ public List<String> getUpdatedValues() {
return getValues(mockUpdatedEndpoint);
}
@@ -93,7 +93,7 @@ public class HazelcastMapResource extends AbstractHazelcastMapResource {
@GET
@Path("evicted")
- public List getEvictedValues() {
+ public List<String> getEvictedValues() {
return getValues(mockEvictedEndpoint);
}
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyResource.java
similarity index 67%
copy from integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
copy to integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyResource.java
index 3ce0671..6658725 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyResource.java
@@ -29,40 +29,35 @@ import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import com.hazelcast.topic.impl.DataAwareMessage;
import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
-import org.apache.camel.component.hazelcast.HazelcastConstants;
-import org.apache.camel.component.hazelcast.HazelcastOperation;
import org.apache.camel.component.mock.MockEndpoint;
-import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_TOPIC_RECEIVED;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_POLICY;
-@Path("/hazelcast/topic")
+@Path("/hazelcast/policy")
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
-public class HazelcastTopicResource {
+public class HazelcastPolicyResource {
@Inject
- ProducerTemplate producerTemplate;
+ CamelContext context;
@Inject
- CamelContext context;
+ ProducerTemplate producerTemplate;
@POST
- public Response publish(String message) {
- producerTemplate.sendBodyAndHeader("hazelcast-topic:foo-topic", message, HazelcastConstants.OPERATION,
- HazelcastOperation.PUBLISH);
+ public Response post(String message) {
+ producerTemplate.sendBody("direct:in-policy", message);
return Response.accepted().build();
}
@GET
- public List getValues() {
- MockEndpoint mockEndpoint = context.getEndpoint(MOCK_TOPIC_RECEIVED, MockEndpoint.class);
- List<Object> values = mockEndpoint.getReceivedExchanges().stream().map(
- exchange -> exchange.getMessage().getBody(DataAwareMessage.class).getMessageObject())
+ public List<String> get() {
+ MockEndpoint mockEndpoint = context.getEndpoint(MOCK_POLICY, MockEndpoint.class);
+ return mockEndpoint.getReceivedExchanges().stream().map(
+ exchange -> exchange.getIn().getBody(String.class))
.collect(Collectors.toList());
- return values;
}
}
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
new file mode 100644
index 0000000..e0bfec5
--- /dev/null
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueResource.java
@@ -0,0 +1,140 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.event.Observes;
+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.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import com.hazelcast.collection.IQueue;
+import com.hazelcast.core.HazelcastInstance;
+import io.quarkus.runtime.StartupEvent;
+import org.apache.camel.component.hazelcast.HazelcastConstants;
+import org.apache.camel.component.hazelcast.HazelcastOperation;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_QUEUE_ADDED;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_QUEUE_DELETED;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_QUEUE_POLL;
+
+@Path("/hazelcast/queue")
+@ApplicationScoped
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class HazelcastQueueResource extends AbstractHazelcastCollectionResource {
+
+ @Inject
+ HazelcastInstance hazelcastInstance;
+
+ @Override
+ public void init(@Observes StartupEvent startupEvent) {
+ endpointUri = "hazelcast-queue:foo-queue";
+ mockAddedEndpoint = MOCK_QUEUE_ADDED;
+ mockDeletedEndpoint = MOCK_QUEUE_DELETED;
+ }
+
+ @PUT
+ @Path("put")
+ public Response addBlocking(String value) {
+ producerTemplate.sendBodyAndHeader(endpointUri, value, HazelcastConstants.OPERATION, HazelcastOperation.PUT);
+ return Response.accepted().build();
+ }
+
+ @PUT
+ @Path("offer")
+ public Response offer(String value) {
+ producerTemplate.sendBodyAndHeader(endpointUri, value, HazelcastConstants.OPERATION, HazelcastOperation.OFFER);
+ return Response.accepted().build();
+ }
+
+ @DELETE
+ @Path("poll")
+ public String poll() {
+ return producerTemplate.requestBodyAndHeader(endpointUri, null, HazelcastConstants.OPERATION, HazelcastOperation.POLL,
+ String.class);
+ }
+
+ @GET
+ @Path("peek")
+ public String peek() {
+ return producerTemplate.requestBodyAndHeader(endpointUri, null, HazelcastConstants.OPERATION, HazelcastOperation.PEEK,
+ String.class);
+ }
+
+ @DELETE
+ @Path("take")
+ public String take() {
+ return producerTemplate.requestBodyAndHeader(endpointUri, null, HazelcastConstants.OPERATION, HazelcastOperation.TAKE,
+ String.class);
+ }
+
+ @GET
+ @Path("remainingCapacity")
+ public Integer remainingCapacity() {
+ return producerTemplate.requestBodyAndHeader(endpointUri, null, HazelcastConstants.OPERATION,
+ HazelcastOperation.REMAINING_CAPACITY, Integer.class);
+ }
+
+ @DELETE
+ @Path("drain")
+ public List<String> drainTo() {
+ 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);
+ producerTemplate.sendBodyAndHeaders(endpointUri, "", headers);
+ return result;
+ }
+
+ /**
+ * add list of values to queue with poll consumer
+ *
+ * @param values
+ * @return
+ */
+ @PUT
+ @Path("poll/list")
+ public Response addListToPollConsumer(List<String> values) {
+ IQueue<String> queue = hazelcastInstance.getQueue("foo-queue-poll");
+ queue.addAll(values);
+ return Response.accepted().build();
+ }
+
+ @GET
+ @Path("polled")
+ public List<String> getPolledValues() {
+ MockEndpoint mockEndpoint = context.getEndpoint(MOCK_QUEUE_POLL, MockEndpoint.class);
+ return mockEndpoint.getReceivedExchanges().stream().map(
+ exchange -> exchange.getIn().getBody(String.class))
+ .collect(Collectors.toList());
+ }
+
+}
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferResource.java
similarity index 53%
copy from integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
copy to integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferResource.java
index 3ce0671..a106abc 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferResource.java
@@ -16,53 +16,61 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
-import java.util.List;
-import java.util.stream.Collectors;
-
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
-import javax.ws.rs.POST;
+import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
-import com.hazelcast.topic.impl.DataAwareMessage;
-import org.apache.camel.CamelContext;
import org.apache.camel.ProducerTemplate;
import org.apache.camel.component.hazelcast.HazelcastConstants;
import org.apache.camel.component.hazelcast.HazelcastOperation;
-import org.apache.camel.component.mock.MockEndpoint;
-
-import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_TOPIC_RECEIVED;
-@Path("/hazelcast/topic")
+@Path("/hazelcast/ringbuffer")
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
-public class HazelcastTopicResource {
+public class HazelcastRingbufferResource {
+ private static final String ENDPOINT_URI = "hazelcast-ringbuffer:foo-ringbuffer";
@Inject
ProducerTemplate producerTemplate;
- @Inject
- CamelContext context;
-
- @POST
- public Response publish(String message) {
- producerTemplate.sendBodyAndHeader("hazelcast-topic:foo-topic", message, HazelcastConstants.OPERATION,
- HazelcastOperation.PUBLISH);
+ @PUT
+ public Response add(String value) {
+ producerTemplate.sendBodyAndHeader(ENDPOINT_URI, value, HazelcastConstants.OPERATION, HazelcastOperation.ADD);
return Response.accepted().build();
}
@GET
- public List getValues() {
- MockEndpoint mockEndpoint = context.getEndpoint(MOCK_TOPIC_RECEIVED, MockEndpoint.class);
- List<Object> values = mockEndpoint.getReceivedExchanges().stream().map(
- exchange -> exchange.getMessage().getBody(DataAwareMessage.class).getMessageObject())
- .collect(Collectors.toList());
- return values;
+ @Path("capacity")
+ public Long getCapacity() {
+ return producerTemplate.requestBodyAndHeader(ENDPOINT_URI, null, HazelcastConstants.OPERATION,
+ HazelcastOperation.CAPACITY, Long.class);
+ }
+
+ @GET
+ @Path("capacity/remaining")
+ public Long getRemainingCapacity() {
+ return producerTemplate.requestBodyAndHeader(ENDPOINT_URI, null, HazelcastConstants.OPERATION,
+ HazelcastOperation.REMAINING_CAPACITY, Long.class);
+ }
+
+ @GET
+ @Path("tail")
+ public String getTail() {
+ return producerTemplate.requestBodyAndHeader(ENDPOINT_URI, null, HazelcastConstants.OPERATION,
+ HazelcastOperation.READ_ONCE_TAIL, String.class);
+ }
+
+ @GET
+ @Path("head")
+ public String getHead() {
+ return producerTemplate.requestBodyAndHeader(ENDPOINT_URI, null, HazelcastConstants.OPERATION,
+ HazelcastOperation.READ_ONCE_HEAD, String.class);
}
}
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRoutes.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRoutes.java
index ef9e212..e81784c 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRoutes.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRoutes.java
@@ -16,6 +16,8 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
+import java.util.concurrent.TimeUnit;
+
import javax.enterprise.context.ApplicationScoped;
import javax.inject.Inject;
import javax.inject.Named;
@@ -31,9 +33,15 @@ import org.apache.camel.component.hazelcast.instance.HazelcastInstanceComponent;
import org.apache.camel.component.hazelcast.list.HazelcastListComponent;
import org.apache.camel.component.hazelcast.map.HazelcastMapComponent;
import org.apache.camel.component.hazelcast.multimap.HazelcastMultimapComponent;
+import org.apache.camel.component.hazelcast.policy.HazelcastRoutePolicy;
+import org.apache.camel.component.hazelcast.queue.HazelcastQueueComponent;
import org.apache.camel.component.hazelcast.replicatedmap.HazelcastReplicatedmapComponent;
+import org.apache.camel.component.hazelcast.ringbuffer.HazelcastRingbufferComponent;
+import org.apache.camel.component.hazelcast.seda.HazelcastSedaComponent;
import org.apache.camel.component.hazelcast.set.HazelcastSetComponent;
import org.apache.camel.component.hazelcast.topic.HazelcastTopicComponent;
+import org.apache.camel.processor.idempotent.hazelcast.HazelcastIdempotentRepository;
+import org.apache.camel.spi.RoutePolicy;
@ApplicationScoped
public class HazelcastRoutes extends RouteBuilder {
@@ -50,6 +58,17 @@ public class HazelcastRoutes extends RouteBuilder {
public static final String MOCK_REPLICATED_ADDED = "mock:replicatedmap-added";
public static final String MOCK_REPLICATED_DELETED = "mock:replicatedmap-removed";
public static final String MOCK_TOPIC_RECEIVED = "mock:topic-received";
+ public static final String MOCK_QUEUE_ADDED = "mock:queue-listen-added";
+ public static final String MOCK_QUEUE_DELETED = "mock:queue-listen-removed";
+ public static final String MOCK_QUEUE_POLL = "mock:queue-poll-result";
+ public static final String MOCK_SEDA_FIFO = "mock:seda-fifo";
+ public static final String MOCK_SEDA_IN_ONLY = "mock:seda-in-only";
+ public static final String MOCK_SEDA_IN_OUT = "mock:seda-in-out";
+ public static final String MOCK_SEDA_IN_OUT_TRANSACTED = "mock:seda-in-out-trans";
+ public static final String MOCK_INSTANCE_ADDED = "mock:instance-added";
+ public static final String MOCK_INSTANCE_REMOVED = "mock:instance-removed";
+ public static final String MOCK_IDEMPOTENT_ADDED = "mock:idempotent-added";
+ public static final String MOCK_POLICY = "mock:policy";
@Inject
HazelcastInstance hazelcastInstance;
@@ -126,6 +145,33 @@ public class HazelcastRoutes extends RouteBuilder {
return configureHazelcastComponent(hazelcastComponent);
}
+ @Produces
+ @ApplicationScoped
+ @Unremovable
+ @Named("hazelcast-queue")
+ HazelcastDefaultComponent hazelcastQueue() {
+ final HazelcastQueueComponent hazelcastComponent = new HazelcastQueueComponent();
+ return configureHazelcastComponent(hazelcastComponent);
+ }
+
+ @Produces
+ @ApplicationScoped
+ @Unremovable
+ @Named("hazelcast-ringbuffer")
+ HazelcastDefaultComponent hazelcastRingbuffer() {
+ final HazelcastRingbufferComponent hazelcastComponent = new HazelcastRingbufferComponent();
+ return configureHazelcastComponent(hazelcastComponent);
+ }
+
+ @Produces
+ @ApplicationScoped
+ @Unremovable
+ @Named("hazelcast-seda")
+ HazelcastDefaultComponent hazelcastSeda() {
+ final HazelcastSedaComponent hazelcastComponent = new HazelcastSedaComponent();
+ return configureHazelcastComponent(hazelcastComponent);
+ }
+
private HazelcastDefaultComponent configureHazelcastComponent(HazelcastDefaultComponent hazelcastComponent) {
// pass the hazelcast generated by the hazelcast extension
hazelcastComponent.setHazelcastInstance(hazelcastInstance);
@@ -135,7 +181,7 @@ public class HazelcastRoutes extends RouteBuilder {
}
@Override
- public void configure() throws Exception {
+ public void configure() {
// HazelcastListConsumer
from("hazelcast-list:foo-list").log("object...").choice()
.when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
@@ -185,5 +231,64 @@ public class HazelcastRoutes extends RouteBuilder {
.log("...received").to(MOCK_TOPIC_RECEIVED)
.otherwise()
.log("fail!");
+
+ // 2 different consumers of type : HazelcastQueueConsumer
+ // consumer mode : LISTEN
+ from("hazelcast-queue:foo-queue").log("object...").choice()
+ .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
+ .log("...added").to(MOCK_QUEUE_ADDED)
+ .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.REMOVED))
+ .log("...removed").to(MOCK_QUEUE_DELETED).otherwise()
+ .log("fail!");
+ // consumer mode : poll
+ from("hazelcast-queue:foo-queue-poll?queueConsumerMode=Poll")
+ .to(MOCK_QUEUE_POLL);
+
+ //different HazelcastSedaConsumer
+ // FIFO consumer
+ from("hazelcast-seda:foo-fifo")
+ .to(MOCK_SEDA_FIFO);
+ // IN ONLY consumer
+ from("hazelcast-seda:foo-in-only")
+ .to(MOCK_SEDA_IN_ONLY);
+ // IN OUT consumer
+ from("hazelcast-seda:foo-in-out")
+ .to(MOCK_SEDA_IN_OUT);
+ // IN OUT transacted consumer
+ from("hazelcast-seda:foo-in-out-trans?transacted=true")
+ .to(MOCK_SEDA_IN_OUT_TRANSACTED);
+
+ // HazelcastInstanceConsumer
+ from("hazelcast-instance:foo-instance").log("instance...")
+ .choice()
+ .when(header(HazelcastConstants.LISTENER_ACTION).isEqualTo(HazelcastConstants.ADDED))
+ .log("...added").to(MOCK_INSTANCE_ADDED)
+ .otherwise().log("...removed").to(MOCK_INSTANCE_REMOVED);
+
+ // Idempotent Repository
+ HazelcastIdempotentRepository repo = new HazelcastIdempotentRepository(hazelcastInstance, "myRepo");
+ from("direct:in-idempotent")
+ .idempotentConsumer(header("messageId"), repo)
+ .to(MOCK_IDEMPOTENT_ADDED);
+
+ // route policy
+ from("direct:in-policy")
+ .routeId("id-value")
+ .routePolicy(createRoutePolicy())
+ .to(MOCK_POLICY);
+
+ }
+
+ /**
+ * Creates a RoutePolicy
+ *
+ */
+ private RoutePolicy createRoutePolicy() {
+ HazelcastRoutePolicy policy = new HazelcastRoutePolicy(hazelcastInstance);
+ policy.setLockMapName("camel:lock:map");
+ policy.setLockKey("route-policy");
+ policy.setLockValue("id-value");
+ policy.setTryLockTimeout(5, TimeUnit.SECONDS);
+ return policy;
}
}
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaResource.java
new file mode 100644
index 0000000..cec8adc
--- /dev/null
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaResource.java
@@ -0,0 +1,112 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.inject.Inject;
+import javax.ws.rs.Consumes;
+import javax.ws.rs.GET;
+import javax.ws.rs.PUT;
+import javax.ws.rs.Path;
+import javax.ws.rs.Produces;
+import javax.ws.rs.core.MediaType;
+import javax.ws.rs.core.Response;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.component.mock.MockEndpoint;
+
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_SEDA_FIFO;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_SEDA_IN_ONLY;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_SEDA_IN_OUT;
+import static org.apache.camel.quarkus.component.hazelcast.it.HazelcastRoutes.MOCK_SEDA_IN_OUT_TRANSACTED;
+
+@Path("/hazelcast/seda")
+@ApplicationScoped
+@Produces(MediaType.APPLICATION_JSON)
+@Consumes(MediaType.APPLICATION_JSON)
+public class HazelcastSedaResource {
+
+ @Inject
+ ProducerTemplate producerTemplate;
+
+ @Inject
+ CamelContext context;
+
+ @PUT
+ @Path("fifo")
+ public Response addFifo(String value) {
+ producerTemplate.sendBody("hazelcast-seda:foo-fifo", value);
+ return Response.accepted().build();
+ }
+
+ @GET
+ @Path("fifo")
+ public List<String> getFifoValues() {
+ return getValues(MOCK_SEDA_FIFO);
+ }
+
+ @PUT
+ @Path("in")
+ public Response addInOnly(String value) {
+ producerTemplate.sendBody("hazelcast-seda:foo-in-only", ExchangePattern.InOnly, value);
+ return Response.accepted().build();
+ }
+
+ @GET
+ @Path("in")
+ public List<String> getInOnlyValues() {
+ return getValues(MOCK_SEDA_IN_ONLY);
+ }
+
+ @PUT
+ @Path("out")
+ public Response addInOut(String value) {
+ producerTemplate.sendBody("hazelcast-seda:foo-in-out", ExchangePattern.InOut, value);
+ return Response.accepted().build();
+ }
+
+ @GET
+ @Path("out")
+ public List<String> getInOutValues() {
+ return getValues(MOCK_SEDA_IN_OUT);
+ }
+
+ @PUT
+ @Path("out/transacted")
+ public Response addInOutTransacted(String value) {
+ producerTemplate.sendBody("hazelcast-seda:foo-in-out-trans", ExchangePattern.InOut, value);
+ return Response.accepted().build();
+ }
+
+ @GET
+ @Path("out/transacted")
+ public List<String> getInOutTransactedValues() {
+ return getValues(MOCK_SEDA_IN_OUT_TRANSACTED);
+ }
+
+ private List<String> getValues(String endpoint) {
+ MockEndpoint mockEndpoint = context.getEndpoint(endpoint, MockEndpoint.class);
+ return mockEndpoint.getReceivedExchanges().stream().map(
+ exchange -> exchange.getMessage().getBody(String.class))
+ .collect(Collectors.toList());
+ }
+}
diff --git a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
index 3ce0671..9413799 100644
--- a/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
+++ b/integration-tests/hazelcast/src/main/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicResource.java
@@ -58,11 +58,10 @@ public class HazelcastTopicResource {
}
@GET
- public List getValues() {
+ public List<String> getValues() {
MockEndpoint mockEndpoint = context.getEndpoint(MOCK_TOPIC_RECEIVED, MockEndpoint.class);
- List<Object> values = mockEndpoint.getReceivedExchanges().stream().map(
- exchange -> exchange.getMessage().getBody(DataAwareMessage.class).getMessageObject())
+ return mockEndpoint.getReceivedExchanges().stream().map(
+ exchange -> (String) exchange.getMessage().getBody(DataAwareMessage.class).getMessageObject())
.collect(Collectors.toList());
- return values;
}
}
diff --git a/integration-tests/hazelcast/src/main/resources/application.properties b/integration-tests/hazelcast/src/main/resources/application.properties
new file mode 100644
index 0000000..2a23dd8
--- /dev/null
+++ b/integration-tests/hazelcast/src/main/resources/application.properties
@@ -0,0 +1,17 @@
+## ---------------------------------------------------------------------------
+## Licensed to the Apache Software Foundation (ASF) under one or more
+## contributor license agreements. See the NOTICE file distributed with
+## this work for additional information regarding copyright ownership.
+## The ASF licenses this file to You under the Apache License, Version 2.0
+## (the "License"); you may not use this file except in compliance with
+## the License. You may obtain a copy of the License at
+##
+## http://www.apache.org/licenses/LICENSE-2.0
+##
+## Unless required by applicable law or agreed to in writing, software
+## distributed under the License is distributed on an "AS IS" BASIS,
+## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+## See the License for the specific language governing permissions and
+## limitations under the License.
+## ---------------------------------------------------------------------------
+quarkus.hazelcast-client.cluster-members=localhost:5701
\ No newline at end of file
diff --git a/integration-tests/hazelcast/src/main/resources/hazelcast.xml b/integration-tests/hazelcast/src/main/resources/hazelcast.xml
new file mode 100644
index 0000000..b05c0c1
--- /dev/null
+++ b/integration-tests/hazelcast/src/main/resources/hazelcast.xml
@@ -0,0 +1,34 @@
+<!--
+
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+-->
+<hazelcast xmlns="http://www.hazelcast.com/schema/config"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://www.hazelcast.com/schema/config
+ 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>
+ <join>
+ <multicast enabled="false"/>
+ <tcp-ip enabled="true">
+ <required-member>127.0.0.1:5701</required-member>
+ <members>127.0.0.1:5702,127.0.0.1:5703</members>
+ </tcp-ip>
+ </join>
+ </network>
+</hazelcast>
\ No newline at end of file
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicTest.java
index 3ca5324..845c276 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.quarkus.component.hazelcast.it;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import org.junit.jupiter.api.Test;
@@ -27,7 +26,7 @@ import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
@TestHTTPEndpoint(HazelcastAtomicResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
class HazelcastAtomicTest {
@Test
public void testAtomicLong() {
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentIT.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentIT.java
new file mode 100644
index 0000000..4aec2b4
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class HazelcastIdempotentIT extends HazelcastIdempotentTest {
+}
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/HazelcastIdempotentTest.java
similarity index 52%
copy from integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapTest.java
copy to integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastIdempotentTest.java
index 2558ab3..7c9a02f 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/HazelcastIdempotentTest.java
@@ -16,109 +16,74 @@
*/
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.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
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.equalTo;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.hasSize;
+import static org.hamcrest.Matchers.not;
@QuarkusTest
-@TestHTTPEndpoint(HazelcastReplicatedMapResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
-public class HazelcastReplicatedmapTest {
+@TestHTTPEndpoint(HazelcastIdempotentResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
+public class HazelcastIdempotentTest {
@Test
- public void testReplicatedmap() {
- // add one value
+ public void testIdempotentRepository() {
+ // add value with key 1
HazelcastMapRequest request = new HazelcastMapRequest().withVaLue("val1").withId("1");
given()
.contentType(ContentType.JSON)
.body(request)
.when()
- .post("/add")
+ .post()
.then()
.statusCode(202);
- // get value with id
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/get/1")
- .then()
- .body(equalTo("val1"));
-
- // add one value with TTL
- request = request.withId("2")
- .withVaLue("val2")
- .withTtl(Long.valueOf(5), TimeUnit.MINUTES);
+ // add value with key 2
+ request = request.withVaLue("val2").withId("2");
given()
.contentType(ContentType.JSON)
.body(request)
.when()
- .post("/add")
+ .post()
.then()
.statusCode(202);
- // verify that map contains key "1"
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/key/1")
- .then()
- .body(equalTo("true"));
-
- // verify that map doesn't contain key "3"
- given()
- .contentType(ContentType.JSON)
- .when()
- .get("/key/3")
- .then()
- .body(equalTo("false"));
-
- // verify that map contains value "val1"
+ // add same value with key 3
+ request = request.withVaLue("val2").withId("3");
given()
.contentType(ContentType.JSON)
+ .body(request)
.when()
- .get("/value/val1")
+ .post()
.then()
- .body(equalTo("true"));
+ .statusCode(202);
- // verify that map doesn't contain value "val2"
+ // add another value with key 1 -- this one is supposed to be skipped
+ request = request.withVaLue("val4").withId("1");
given()
.contentType(ContentType.JSON)
+ .body(request)
.when()
- .get("/value/val3")
- .then()
- .body(equalTo("false"));
-
- // remove value by id
- given()
- .when()
- .delete("/1")
+ .post()
.then()
.statusCode(202);
- // verify that map doesn't contain key "1" anymore
+ // get all values added to the map
given()
.contentType(ContentType.JSON)
.when()
- .get("/key/1")
+ .get()
.then()
- .body(equalTo("false"));
-
- // clear
- given()
- .when()
- .get("/clear")
- .then()
- .statusCode(202);
+ .body("$", hasSize(3))
+ .body("$", hasItems("val1", "val2"))
+ .body("$", not(hasItems("val4")));
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceIT.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceIT.java
new file mode 100644
index 0000000..0e72f92
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class HazelcastInstanceIT extends HazelcastInstanceTest {
+}
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/HazelcastInstanceTest.java
similarity index 59%
copy from integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicTest.java
copy to integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastInstanceTest.java
index d401556..f6b173f 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/HazelcastInstanceTest.java
@@ -18,37 +18,25 @@ package org.apache.camel.quarkus.component.hazelcast.it;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
-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.hamcrest.Matchers.equalTo;
@QuarkusTest
-@TestHTTPEndpoint(HazelcastTopicResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
-public class HazelcastTopicTest {
+@TestHTTPEndpoint(HazelcastInstanceResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
+public class HazelcastInstanceTest {
+
@Test
- public void testTopic() {
- // publish topic
+ public void testInstance() {
+ HazelcastTestResource.addMemberToCluster();
given()
- .contentType(ContentType.JSON)
- .body("test1")
.when()
- .post()
+ .get("/added")
.then()
- .statusCode(202);
+ .body(equalTo("1"));
- // verify that the consumer has received the topic
- given()
- .contentType(ContentType.JSON)
- .when()
- .get()
- .then()
- .body("$", hasSize(1))
- .body("$", hasItems("test1"));
}
}
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 c38faba..d334fb8 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
@@ -20,7 +20,6 @@ import java.util.Arrays;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -32,7 +31,7 @@ import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
@TestHTTPEndpoint(HazelcastListResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastListTest {
@Test
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 96b9615..6a994d4 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
@@ -21,7 +21,6 @@ import java.util.concurrent.TimeUnit;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.component.hazelcast.it.model.HazelcastMapRequest;
@@ -34,7 +33,7 @@ import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
@TestHTTPEndpoint(HazelcastMapResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastMapTest {
@Test
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 8e330c0..a02b2ed 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
@@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.component.hazelcast.it.model.HazelcastMapRequest;
@@ -33,7 +32,7 @@ import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
@TestHTTPEndpoint(HazelcastMultimapResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastMultimapTest {
@Test
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyIT.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyIT.java
new file mode 100644
index 0000000..a65670f
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class HazelcastPolicyIT extends HazelcastPolicyTest {
+}
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/HazelcastPolicyTest.java
similarity index 67%
copy from integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTopicTest.java
copy to integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastPolicyTest.java
index d401556..bd7f1a6 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/HazelcastPolicyTest.java
@@ -18,7 +18,6 @@ package org.apache.camel.quarkus.component.hazelcast.it;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -28,27 +27,46 @@ import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
-@TestHTTPEndpoint(HazelcastTopicResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
-public class HazelcastTopicTest {
+@TestHTTPEndpoint(HazelcastPolicyResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
+public class HazelcastPolicyTest {
+
@Test
- public void testTopic() {
- // publish topic
+ public void testPolicy() {
+
+ // send exchanges
+ given()
+ .contentType(ContentType.JSON)
+ .body("foo1")
+ .when()
+ .post()
+ .then()
+ .statusCode(202);
+
given()
.contentType(ContentType.JSON)
- .body("test1")
+ .body("foo2")
.when()
.post()
.then()
.statusCode(202);
- // verify that the consumer has received the topic
+ given()
+ .contentType(ContentType.JSON)
+ .body("foo3")
+ .when()
+ .post()
+ .then()
+ .statusCode(202);
+
+ // should receive the 3 exchanges
given()
.contentType(ContentType.JSON)
.when()
.get()
.then()
- .body("$", hasSize(1))
- .body("$", hasItems("test1"));
+ .body("$", hasSize(3))
+ .body("$", hasItems("foo1", "foo2", "foo3"));
+
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueIT.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueIT.java
new file mode 100644
index 0000000..6c1c132
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class HazelcastQueueIT extends HazelcastQueueTest {
+}
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/HazelcastQueueTest.java
similarity index 62%
copy from integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastListTest.java
copy to integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastQueueTest.java
index c38faba..f0e13bc 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/HazelcastQueueTest.java
@@ -18,9 +18,7 @@ package org.apache.camel.quarkus.component.hazelcast.it;
import java.util.Arrays;
-import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -31,123 +29,130 @@ import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
-@TestHTTPEndpoint(HazelcastListResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
-public class HazelcastListTest {
-
+@TestHTTPEndpoint(HazelcastQueueResource.class)
+public class HazelcastQueueTest {
@Test
- public void testList() {
- // add one value
+ public void testQueue() {
+ // add a value using the add method :: non blocking
given()
.contentType(ContentType.JSON)
- .body("foo1")
+ .body("q1")
.when()
.put()
.then()
.statusCode(202);
- // find value :: should be first value
+ // retrieves head
given()
.contentType(ContentType.JSON)
.when()
- .get("/0")
+ .get("peek")
.then()
- .body(equalTo("foo1"));
+ .body(equalTo("q1"));
- // remove value by index
+ // add a value :: blocking method put
given()
.contentType(ContentType.JSON)
- .body(0)
+ .body("q2")
.when()
- .delete("/index")
+ .put("put")
.then()
.statusCode(202);
- // add all values
+ // take
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .delete("take")
+ .then()
+ .body(equalTo("q1"));
+
+ // offer
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo2", "foo3"))
+ .body("q3")
.when()
- .put("/all")
+ .put("offer")
.then()
.statusCode(202);
- // find values
+ // poll
given()
.contentType(ContentType.JSON)
.when()
- .get("/0")
+ .delete("poll")
.then()
- .body(equalTo("foo2"));
+ .body(equalTo("q2"));
+
+ // poll after q2 is deleted by precedent poll
given()
.contentType(ContentType.JSON)
.when()
- .get("/1")
+ .delete("poll")
.then()
- .body(equalTo("foo3"));
+ .body(equalTo("q3"));
- // remove value foo2
+ // add multiple values
given()
.contentType(ContentType.JSON)
- .body("foo2")
+ .body("q4")
.when()
- .delete("/value")
+ .put()
.then()
.statusCode(202);
-
- // foo3 must be on index 0 now
given()
.contentType(ContentType.JSON)
+ .body("q5")
.when()
- .get("/0")
+ .put()
.then()
- .body(equalTo("foo3"));
-
- // delete all
+ .statusCode(202);
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo3"))
+ .body("alpha1")
.when()
- .delete("/all")
+ .put()
.then()
.statusCode(202);
- // add multiple values
+ // remaining capacity :: no max capacity so max capacity of the queue is Integer.MAX_VALUE
+ Integer remainingCapacity = Integer.MAX_VALUE - 3;
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo4", "foo5", "foo6", "foo7"))
.when()
- .put("/all")
+ .get("/remainingCapacity")
.then()
- .statusCode(202);
+ .body(equalTo(remainingCapacity.toString()));
- // retain only 2 : should delete foo5 and foo6
+ // drainTo : delete all values and return to list
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo4", "foo7"))
.when()
- .post("/retain")
+ .delete("drain")
.then()
- .statusCode(202);
+ .body("$", hasSize(3))
+ .body("$", hasItems("q4", "q5", "alpha1"));
- // verify that the consumer has received all added values
+ }
+
+ @Test
+ public void testPollConsumer() {
+ // add all values
given()
.contentType(ContentType.JSON)
+ .body(Arrays.asList("v1", "v2", "v3"))
.when()
- .get("/added")
+ .put("poll/list")
.then()
- .body("$", hasSize(7))
- .body("$", hasItems("foo1", "foo2", "foo3", "foo4", "foo5", "foo6", "foo7"));
+ .statusCode(202);
- // 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
+ // retrieve values from consumer
given()
.contentType(ContentType.JSON)
.when()
- .get("/deleted")
+ .get("/polled")
.then()
- .body("$", hasSize(5))
- .body("$", hasItems("foo2", "foo3", "foo5", "foo6"));
+ .body("$", hasSize(3))
+ .body("$", hasItems("v1", "v2", "v3"));
}
-
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapIT.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapIT.java
new file mode 100644
index 0000000..b9aadfb
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastReplicatedmapIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class HazelcastReplicatedmapIT extends HazelcastReplicatedmapTest {
+}
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 2558ab3..c194e14 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
@@ -20,7 +20,6 @@ import java.util.concurrent.TimeUnit;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.apache.camel.quarkus.component.hazelcast.it.model.HazelcastMapRequest;
@@ -31,7 +30,7 @@ import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
@TestHTTPEndpoint(HazelcastReplicatedMapResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastReplicatedmapTest {
@Test
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferIT.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferIT.java
new file mode 100644
index 0000000..d3927b2
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class HazelcastRingbufferIT extends HazelcastRingbufferTest {
+}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicTest.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferTest.java
similarity index 52%
copy from integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicTest.java
copy to integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferTest.java
index 3ca5324..89482da 100644
--- a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastAtomicTest.java
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastRingbufferTest.java
@@ -18,54 +18,74 @@ package org.apache.camel.quarkus.component.hazelcast.it;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
+import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
import static io.restassured.RestAssured.given;
import static org.hamcrest.Matchers.equalTo;
@QuarkusTest
-@TestHTTPEndpoint(HazelcastAtomicResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
-class HazelcastAtomicTest {
+@TestHTTPEndpoint(HazelcastRingbufferResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
+public class HazelcastRingbufferTest {
@Test
- public void testAtomicLong() {
+ public void testRingBuffer() {
+ // get capacity -- should be default capacity 10K
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/capacity")
+ .then()
+ .body(equalTo("10000"));
- // set value
+ // add values
given()
+ .contentType(ContentType.JSON)
+ .body("foo1")
.when()
- .put("/4711")
+ .put()
.then()
.statusCode(202);
- // get value
given()
+ .contentType(ContentType.JSON)
+ .body("foo2")
.when()
- .get()
+ .put()
.then()
- .body(equalTo("4711"));
+ .statusCode(202);
- // increment and get new value
given()
+ .contentType(ContentType.JSON)
+ .body("foo3")
.when()
- .get("/increment")
+ .put()
.then()
- .body(equalTo("4712"));
+ .statusCode(202);
- // decrement and get new value
+ // gets HEAD
given()
+ .contentType(ContentType.JSON)
.when()
- .get("/decrement")
+ .get("/head")
.then()
- .body(equalTo("4711"));
+ .body(equalTo("foo1"));
- // destroy value
+ // gets TAIL
given()
+ .contentType(ContentType.JSON)
.when()
- .delete()
+ .get("/tail")
.then()
- .statusCode(202);
+ .body(equalTo("foo3"));
+ // it returns capacity instead because there is no expiration policy set for the RingBuffer
+ given()
+ .contentType(ContentType.JSON)
+ .when()
+ .get("/capacity/remaining")
+ .then()
+ .body(equalTo("10000"));
}
}
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaIT.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaIT.java
new file mode 100644
index 0000000..773ca4f
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaIT.java
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import io.quarkus.test.junit.NativeImageTest;
+
+@NativeImageTest
+public class HazelcastSedaIT extends HazelcastSedaTest {
+}
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/HazelcastSedaTest.java
similarity index 56%
copy from integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSetTest.java
copy to integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastSedaTest.java
index 474f3c9..80b435e 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/HazelcastSedaTest.java
@@ -16,11 +16,8 @@
*/
package org.apache.camel.quarkus.component.hazelcast.it;
-import java.util.Arrays;
-
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -30,100 +27,88 @@ import static org.hamcrest.Matchers.hasItems;
import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
-@TestHTTPEndpoint(HazelcastSetResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
-public class HazelcastSetTest {
-
+@TestHTTPEndpoint(HazelcastSedaResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
+public class HazelcastSedaTest {
@Test
- public void testSet() {
- // add one value
+ public void testSedaFifo() {
+ // add one value First In First Out
given()
.contentType(ContentType.JSON)
.body("foo1")
.when()
- .put()
+ .put("/fifo")
.then()
.statusCode(202);
- // trying to add same value:: shouldn't be added twice : verify with consumer
+ // verify that the consumer received the message
given()
.contentType(ContentType.JSON)
- .body("foo1")
.when()
- .put()
+ .get("/fifo")
.then()
- .statusCode(202);
+ .body("$", hasSize(1))
+ .body("$", hasItems("foo1"));
+ }
- // remove value
+ @Test
+ public void testSedaInOnly() {
+ // add one value In Only
given()
.contentType(ContentType.JSON)
.body("foo1")
.when()
- .delete("/value")
+ .put("/in")
.then()
.statusCode(202);
- // add multiple values
+ // verify that the consumer received the message
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo2", "foo3"))
.when()
- .put("/all")
+ .get("/in")
.then()
- .statusCode(202);
-
- // remove value foo2
- given()
- .contentType(ContentType.JSON)
- .body("foo2")
- .when()
- .delete("/value")
- .then()
- .statusCode(202);
+ .body("$", hasSize(1))
+ .body("$", hasItems("foo1"));
+ }
- // delete all
+ @Test
+ public void testSedaInOut() {
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo3"))
+ .body("foo1")
.when()
- .delete("/all")
+ .put("/out")
.then()
.statusCode(202);
- // add multiple values
+ // verify that the consumer received the message
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo4", "foo5", "foo6", "foo7"))
.when()
- .put("/all")
+ .get("/out")
.then()
- .statusCode(202);
+ .body("$", hasSize(1))
+ .body("$", hasItems("foo1"));
+ }
- // retain only 2 : should delete foo5 and foo6
+ @Test
+ public void testSedaInOutTransacted() {
given()
.contentType(ContentType.JSON)
- .body(Arrays.asList("foo4", "foo7"))
+ .body("foo1")
.when()
- .post("/retain")
+ .put("/out/transacted")
.then()
.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"));
-
- // verify that the consumer has received all removed values
+ // verify that the consumer received the message
given()
.contentType(ContentType.JSON)
.when()
- .get("/deleted")
+ .get("/out/transacted")
.then()
- .body("$", hasSize(5))
- .body("$", hasItems("foo1", "foo2", "foo3", "foo5", "foo6"));
+ .body("$", hasSize(1))
+ .body("$", hasItems("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 474f3c9..13340ed 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
@@ -20,7 +20,6 @@ import java.util.Arrays;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -31,7 +30,7 @@ import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
@TestHTTPEndpoint(HazelcastSetResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastSetTest {
@Test
diff --git a/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTestResource.java b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTestResource.java
new file mode 100644
index 0000000..c73c9d9
--- /dev/null
+++ b/integration-tests/hazelcast/src/test/java/org/apache/camel/quarkus/component/hazelcast/it/HazelcastTestResource.java
@@ -0,0 +1,53 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.quarkus.component.hazelcast.it;
+
+import java.util.Map;
+
+import com.hazelcast.core.Hazelcast;
+import com.hazelcast.core.HazelcastInstance;
+import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;
+
+public class HazelcastTestResource implements QuarkusTestResourceLifecycleManager {
+ private volatile HazelcastInstance member;
+ private static volatile HazelcastInstance member2;
+
+ @Override
+ public Map<String, String> start() {
+ member = Hazelcast.newHazelcastInstance();
+ return null;
+ }
+
+ @Override
+ public void stop() {
+ if (member != null) {
+ member.shutdown();
+ }
+
+ if (member2 != null) {
+ member.shutdown();
+ }
+ }
+
+ /**
+ * this is used to test new instance in the same cluster
+ */
+ public static void addMemberToCluster() {
+ member2 = Hazelcast.newHazelcastInstance();
+ }
+
+}
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 d401556..5e525f8 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
@@ -18,7 +18,6 @@ package org.apache.camel.quarkus.component.hazelcast.it;
import io.quarkus.test.common.QuarkusTestResource;
import io.quarkus.test.common.http.TestHTTPEndpoint;
-import io.quarkus.test.hazelcast.HazelcastServerTestResource;
import io.quarkus.test.junit.QuarkusTest;
import io.restassured.http.ContentType;
import org.junit.jupiter.api.Test;
@@ -29,7 +28,7 @@ import static org.hamcrest.Matchers.hasSize;
@QuarkusTest
@TestHTTPEndpoint(HazelcastTopicResource.class)
-@QuarkusTestResource(HazelcastServerTestResource.class)
+@QuarkusTestResource(HazelcastTestResource.class)
public class HazelcastTopicTest {
@Test
public void testTopic() {
diff --git a/poms/bom-test/pom.xml b/poms/bom-test/pom.xml
index fa0f073..76ccd47 100644
--- a/poms/bom-test/pom.xml
+++ b/poms/bom-test/pom.xml
@@ -52,12 +52,6 @@
<type>pom</type>
<scope>import</scope>
</dependency>
-
- <dependency>
- <groupId>com.hazelcast</groupId>
- <artifactId>quarkus-test-hazelcast</artifactId>
- <version>${quarkus-hazelcast-client.version}</version>
- </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-integration-test-support-custom-dataformat</artifactId>