You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2020/11/30 15:41:59 UTC
[camel] branch master updated: Migrates camel-infinispan to the new
test infra (#4703)
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/master by this push:
new 5528fa9 Migrates camel-infinispan to the new test infra (#4703)
5528fa9 is described below
commit 5528fa96c897e66eaaf1d5041060d4d590faf2dd
Author: Otavio Rodolfo Piske <or...@users.noreply.github.com>
AuthorDate: Mon Nov 30 16:40:51 2020 +0100
Migrates camel-infinispan to the new test infra (#4703)
---
components/camel-infinispan/pom.xml | 19 +++-
.../InfinispanTestContainerSupport.java | 42 +++-----
.../InfinispanTestContainersConsumerTest.java | 12 +--
...ispanTestContainersContainsKeyProducerTest.java | 10 +-
...spanTestContainersGetOrDefaultProducerTest.java | 10 +-
...spanTestContainersIdempotentRepositoryTest.java | 4 +-
.../InfinispanTestContainersProducerTest.java | 10 +-
...ispanTestContainersPutIfAbsentProducerTest.java | 15 +--
...InfinispanTestContainersRemoveProducerTest.java | 15 +--
test-infra/camel-test-infra-infinispan/pom.xml | 60 ++++++++++++
.../src/main/resources/META-INF/MANIFEST.MF | 0
.../infinispan/common/InfinispanProperties.java | 31 ++++++
.../services/InfinispanLocalContainerService.java | 107 +++++++++++++++++++++
.../services/InfinispanRemoteService.java | 68 +++++++++++++
.../infinispan/services/InfinispanService.java | 48 +++++++++
.../services/InfinispanServiceFactory.java | 43 +++++++++
test-infra/pom.xml | 1 +
17 files changed, 432 insertions(+), 63 deletions(-)
diff --git a/components/camel-infinispan/pom.xml b/components/camel-infinispan/pom.xml
index 1548e9f..52e1099 100644
--- a/components/camel-infinispan/pom.xml
+++ b/components/camel-infinispan/pom.xml
@@ -117,7 +117,24 @@
</dependency>
<dependency>
<groupId>org.apache.camel</groupId>
- <artifactId>camel-testcontainers-junit5</artifactId>
+ <artifactId>camel-test-junit5</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- test infra -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-infinispan</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
<scope>test</scope>
</dependency>
</dependencies>
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java
index 6e2ced7..d440ff2 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainerSupport.java
@@ -16,45 +16,23 @@
*/
package org.apache.camel.component.infinispan.testcontainers;
-import org.apache.camel.test.testcontainers.junit5.ContainerAwareTestSupport;
-import org.apache.camel.test.testcontainers.junit5.Wait;
+import org.apache.camel.test.infra.infinispan.services.InfinispanService;
+import org.apache.camel.test.infra.infinispan.services.InfinispanServiceFactory;
+import org.apache.camel.test.junit5.CamelTestSupport;
import org.infinispan.client.hotrod.DefaultTemplate;
import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.junit.jupiter.api.TestInstance;
-import org.testcontainers.containers.GenericContainer;
+import org.junit.jupiter.api.extension.RegisterExtension;
@TestInstance(TestInstance.Lifecycle.PER_CLASS)
-public class InfinispanTestContainerSupport extends ContainerAwareTestSupport {
-
- public static final String CONTAINER_IMAGE = "infinispan/server:11.0.5.Final-1";
- public static final String CONTAINER_NAME = "infinispan";
-
- @Override
- protected GenericContainer<?> createContainer() {
- return localstackContainer();
- }
-
- public static GenericContainer localstackContainer() {
- return new GenericContainer(CONTAINER_IMAGE)
- .withNetworkAliases(CONTAINER_NAME)
- .withEnv("USER", "admin")
- .withEnv("PASS", "password")
- .withExposedPorts(11222)
- .waitingFor(Wait.forListeningPort())
- .waitingFor(Wait.forLogMessageContaining("Infinispan Server 11.0.5.Final started", 1));
- }
-
- public String getInfispanUrl() {
- return String.format(
- "%s:%d",
- getContainerHost(CONTAINER_NAME),
- getContainerPort(CONTAINER_NAME, 11222));
- }
+public class InfinispanTestContainerSupport extends CamelTestSupport {
+ @RegisterExtension
+ InfinispanService service = InfinispanServiceFactory.createService();
public RemoteCacheManager createAndGetDefaultCache() {
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
- clientBuilder.addServer().host(getContainerHost(CONTAINER_NAME)).port(getContainerPort(CONTAINER_NAME, 11222))
+ clientBuilder.addServer().host(service.host()).port(service.port())
.security().authentication().username("admin").password("password").serverName("infinispan")
.saslMechanism("DIGEST-MD5").realm("default").remoteCache("mycache").templateName(DefaultTemplate.DIST_SYNC);
@@ -62,4 +40,8 @@ public class InfinispanTestContainerSupport extends ContainerAwareTestSupport {
remoteCacheManager.getCache("mycache");
return remoteCacheManager;
}
+
+ protected String getInfispanUrl() {
+ return service.getServiceAddress();
+ }
}
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersConsumerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersConsumerTest.java
index 816c98c..a050f3d 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersConsumerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersConsumerTest.java
@@ -69,12 +69,12 @@ public class InfinispanTestContainersConsumerTest extends InfinispanTestContaine
from("direct:put")
.delay(5000)
.startupOrder(2)
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=PUT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan&sync=false");
- from("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=GET&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan&eventTypes=CLIENT_CACHE_ENTRY_CREATED&sync=false")
- .startupOrder(1)
- .to("mock:result");
+ .toF("infinispan:mycache?hosts=%s&operation=PUT&username=%s&password=%s&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan&sync=false",
+ getInfispanUrl(), service.username(), service.password());
+ fromF("infinispan:mycache?hosts=%s&operation=GET&username=%s&password=%s&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan&eventTypes=CLIENT_CACHE_ENTRY_CREATED&sync=false",
+ getInfispanUrl(), service.username(), service.password())
+ .startupOrder(1)
+ .to("mock:result");
}
};
}
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersContainsKeyProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersContainsKeyProducerTest.java
index bb2023c..40f9c09 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersContainsKeyProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersContainsKeyProducerTest.java
@@ -64,11 +64,13 @@ public class InfinispanTestContainersContainsKeyProducerTest extends InfinispanT
@Override
public void configure() {
from("direct:put")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=PUT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=PUT&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
from("direct:containsKey")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=CONTAINSKEY&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=CONTAINSKEY&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
}
};
}
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersGetOrDefaultProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersGetOrDefaultProducerTest.java
index 5077fd8..00c7269 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersGetOrDefaultProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersGetOrDefaultProducerTest.java
@@ -72,11 +72,13 @@ public class InfinispanTestContainersGetOrDefaultProducerTest extends Infinispan
@Override
public void configure() {
from("direct:put")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=PUT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=PUT&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
from("direct:getOrDefault")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=GETORDEFAULT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan")
+ .toF("infinispan:mycache?hosts=%s&operation=GETORDEFAULT&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password())
.to("mock:result");
}
};
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersIdempotentRepositoryTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersIdempotentRepositoryTest.java
index d9c23db..fceb71d 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersIdempotentRepositoryTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersIdempotentRepositoryTest.java
@@ -64,8 +64,8 @@ public class InfinispanTestContainersIdempotentRepositoryTest extends Infinispan
new RemoteCacheManager(
new ConfigurationBuilder()
.addServers(getInfispanUrl())
- .security().authentication().username("admin")
- .password("password").realm("default")
+ .security().authentication().username(service.username())
+ .password(service.password()).realm("default")
.serverName("infinispan").saslMechanism("DIGEST-MD5")
.build(),
true),
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java
index ca35282..4e01744 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersProducerTest.java
@@ -64,11 +64,13 @@ public class InfinispanTestContainersProducerTest extends InfinispanTestContaine
@Override
public void configure() {
from("direct:put")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=PUT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=PUT&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
from("direct:get")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=GET&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=GET&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
}
};
}
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersPutIfAbsentProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersPutIfAbsentProducerTest.java
index 72a3205..77f5be2 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersPutIfAbsentProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersPutIfAbsentProducerTest.java
@@ -78,14 +78,17 @@ public class InfinispanTestContainersPutIfAbsentProducerTest extends InfinispanT
@Override
public void configure() {
from("direct:put")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=PUT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=PUT&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
from("direct:putIfAbsent")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=PUTIFABSENT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=PUTIFABSENT&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
from("direct:get")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=GET&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan")
+ .toF("infinispan:mycache?hosts=%s&operation=GET&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password())
.to("mock:result");
}
};
diff --git a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersRemoveProducerTest.java b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersRemoveProducerTest.java
index 7e756cd..ff5c2d6 100644
--- a/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersRemoveProducerTest.java
+++ b/components/camel-infinispan/src/test/java/org/apache/camel/component/infinispan/testcontainers/InfinispanTestContainersRemoveProducerTest.java
@@ -78,14 +78,17 @@ public class InfinispanTestContainersRemoveProducerTest extends InfinispanTestCo
@Override
public void configure() {
from("direct:put")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=PUT&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=PUT&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
from("direct:remove")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=REMOVE&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan");
+ .toF("infinispan:mycache?hosts=%s&operation=REMOVE&username=%s&password=%s&secure=true"
+ + "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password());
from("direct:get")
- .to("infinispan:mycache?hosts=" + getInfispanUrl()
- + "&operation=GET&username=admin&password=password&secure=true&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan")
+ .toF("infinispan:mycache?hosts=%s&operation=GET&username=%s&password=%s&secure=true" +
+ "&saslMechanism=RAW(DIGEST-MD5)&securityRealm=default&securityServerName=infinispan",
+ getInfispanUrl(), service.username(), service.password())
.to("mock:result");
}
};
diff --git a/test-infra/camel-test-infra-infinispan/pom.xml b/test-infra/camel-test-infra-infinispan/pom.xml
new file mode 100644
index 0000000..72a35a5
--- /dev/null
+++ b/test-infra/camel-test-infra-infinispan/pom.xml
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <artifactId>camel-test-infra-parent</artifactId>
+ <groupId>org.apache.camel</groupId>
+ <relativePath>../camel-test-infra-parent/pom.xml</relativePath>
+ <version>3.7.0-SNAPSHOT</version>
+ </parent>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>camel-test-infra-infinispan</artifactId>
+ <name>Camel :: Test Infra :: Infinispan</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-infra-common</artifactId>
+ <version>${project.version}</version>
+ <type>test-jar</type>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-jar-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+
+
+</project>
\ No newline at end of file
diff --git a/test-infra/camel-test-infra-infinispan/src/main/resources/META-INF/MANIFEST.MF b/test-infra/camel-test-infra-infinispan/src/main/resources/META-INF/MANIFEST.MF
new file mode 100644
index 0000000..e69de29
diff --git a/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/common/InfinispanProperties.java b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/common/InfinispanProperties.java
new file mode 100644
index 0000000..47f11df
--- /dev/null
+++ b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/common/InfinispanProperties.java
@@ -0,0 +1,31 @@
+/*
+ * 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.test.infra.infinispan.common;
+
+public final class InfinispanProperties {
+ public static final String SERVICE_ADDRESS = "infinispan.service.address";
+ public static final String SERVICE_HOST = "infinispan.service.host";
+ public static final String SERVICE_PORT = "infinispan.service.port";
+ public static final String SERVICE_USERNAME = "infinispan.service.username";
+ public static final String SERVICE_PASSWORD = "infinispan.service.password";
+ public static final int DEFAULT_SERVICE_PORT = 11222;
+
+ private InfinispanProperties() {
+
+ }
+}
diff --git a/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanLocalContainerService.java b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanLocalContainerService.java
new file mode 100644
index 0000000..3efba66
--- /dev/null
+++ b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanLocalContainerService.java
@@ -0,0 +1,107 @@
+/*
+ * 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.test.infra.infinispan.services;
+
+import org.apache.camel.test.infra.common.services.ContainerService;
+import org.apache.camel.test.infra.infinispan.common.InfinispanProperties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.testcontainers.containers.GenericContainer;
+import org.testcontainers.containers.wait.strategy.Wait;
+
+public class InfinispanLocalContainerService implements InfinispanService, ContainerService<GenericContainer> {
+ public static final String CONTAINER_IMAGE = "infinispan/server:11.0.5.Final-1";
+ public static final String CONTAINER_NAME = "infinispan";
+ private static final String DEFAULT_USERNAME = "admin";
+ private static final String DEFAULT_PASSWORD = "password";
+
+ private static final Logger LOG = LoggerFactory.getLogger(InfinispanLocalContainerService.class);
+
+ private GenericContainer container;
+
+ public InfinispanLocalContainerService() {
+ String containerName = System.getProperty("infinispan.container", CONTAINER_IMAGE);
+
+ initContainer(containerName);
+ }
+
+ public InfinispanLocalContainerService(String containerName) {
+ initContainer(containerName);
+ }
+
+ protected void initContainer(String containerName) {
+ container = new GenericContainer(containerName)
+ .withNetworkAliases(CONTAINER_NAME)
+ .withEnv("USER", DEFAULT_USERNAME)
+ .withEnv("PASS", DEFAULT_PASSWORD)
+ .withExposedPorts(InfinispanProperties.DEFAULT_SERVICE_PORT)
+ .waitingFor(Wait.forListeningPort())
+ .waitingFor(Wait.forLogMessage(".*Infinispan.*Server.*started.*", 1));
+ }
+
+ @Override
+ public void registerProperties() {
+ System.setProperty(InfinispanProperties.SERVICE_HOST, host());
+ System.setProperty(InfinispanProperties.SERVICE_PORT, String.valueOf(port()));
+ System.setProperty(InfinispanProperties.SERVICE_ADDRESS, getServiceAddress());
+ }
+
+ @Override
+ public void initialize() {
+ LOG.info("Trying to start the Infinispan container");
+ container.start();
+
+ registerProperties();
+ LOG.info("Infinispan instance running at {}", getServiceAddress());
+ }
+
+ @Override
+ public void shutdown() {
+ LOG.info("Stopping the Infinispan container");
+ container.stop();
+ }
+
+ @Override
+ public GenericContainer getContainer() {
+ return container;
+ }
+
+ @Override
+ public String getServiceAddress() {
+ return String.format("%s:%d", host(), port());
+ }
+
+ @Override
+ public int port() {
+ return container.getMappedPort(InfinispanProperties.DEFAULT_SERVICE_PORT);
+ }
+
+ @Override
+ public String host() {
+ return container.getHost();
+ }
+
+ @Override
+ public String username() {
+ return DEFAULT_USERNAME;
+ }
+
+ @Override
+ public String password() {
+ return DEFAULT_PASSWORD;
+ }
+}
diff --git a/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanRemoteService.java b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanRemoteService.java
new file mode 100644
index 0000000..378c314
--- /dev/null
+++ b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanRemoteService.java
@@ -0,0 +1,68 @@
+/*
+ * 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.test.infra.infinispan.services;
+
+import org.apache.camel.test.infra.infinispan.common.InfinispanProperties;
+
+public class InfinispanRemoteService implements InfinispanService {
+
+ @Override
+ public void registerProperties() {
+ // NO-OP
+ }
+
+ @Override
+ public void initialize() {
+ registerProperties();
+ }
+
+ @Override
+ public void shutdown() {
+ // NO-OP
+ }
+
+ @Override
+ public String getServiceAddress() {
+ return System.getProperty(InfinispanProperties.SERVICE_ADDRESS);
+ }
+
+ @Override
+ public int port() {
+ String port = System.getProperty(InfinispanProperties.SERVICE_PORT);
+
+ if (port == null) {
+ return InfinispanProperties.DEFAULT_SERVICE_PORT;
+ }
+
+ return Integer.valueOf(port);
+ }
+
+ @Override
+ public String host() {
+ return System.getProperty(InfinispanProperties.SERVICE_HOST);
+ }
+
+ @Override
+ public String username() {
+ return System.getProperty(InfinispanProperties.SERVICE_USERNAME);
+ }
+
+ @Override
+ public String password() {
+ return System.getProperty(InfinispanProperties.SERVICE_PASSWORD);
+ }
+}
diff --git a/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanService.java b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanService.java
new file mode 100644
index 0000000..1f5253c
--- /dev/null
+++ b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanService.java
@@ -0,0 +1,48 @@
+/*
+ * 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.test.infra.infinispan.services;
+
+import org.apache.camel.test.infra.common.services.TestService;
+import org.junit.jupiter.api.extension.AfterAllCallback;
+import org.junit.jupiter.api.extension.BeforeAllCallback;
+import org.junit.jupiter.api.extension.ExtensionContext;
+
+/**
+ * Test infra service for Infinispan
+ */
+public interface InfinispanService extends BeforeAllCallback, AfterAllCallback, TestService {
+
+ String username();
+
+ String password();
+
+ int port();
+
+ String host();
+
+ String getServiceAddress();
+
+ @Override
+ default void beforeAll(ExtensionContext extensionContext) throws Exception {
+ initialize();
+ }
+
+ @Override
+ default void afterAll(ExtensionContext extensionContext) throws Exception {
+ shutdown();
+ }
+}
diff --git a/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanServiceFactory.java b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanServiceFactory.java
new file mode 100644
index 0000000..344643a
--- /dev/null
+++ b/test-infra/camel-test-infra-infinispan/src/test/java/org/apache/camel/test/infra/infinispan/services/InfinispanServiceFactory.java
@@ -0,0 +1,43 @@
+/*
+ * 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.test.infra.infinispan.services;
+
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public final class InfinispanServiceFactory {
+ private static final Logger LOG = LoggerFactory.getLogger(InfinispanServiceFactory.class);
+
+ private InfinispanServiceFactory() {
+
+ }
+
+ public static InfinispanService createService() {
+ String instanceType = System.getProperty("infinispan.instance.type");
+
+ if (instanceType == null || instanceType.equals("local-infinispan-container")) {
+ return new InfinispanLocalContainerService();
+ }
+
+ if (instanceType.equals("remote")) {
+ return new InfinispanRemoteService();
+ }
+
+ LOG.error("Infinispan instance must be one of 'local-infinispan-container' or 'remote");
+ throw new UnsupportedOperationException("Invalid Infinispan instance type");
+ }
+}
diff --git a/test-infra/pom.xml b/test-infra/pom.xml
index 7a88e8f..40907ec 100644
--- a/test-infra/pom.xml
+++ b/test-infra/pom.xml
@@ -57,5 +57,6 @@
<module>camel-test-infra-google-pubsub</module>
<module>camel-test-infra-etcd</module>
<module>camel-test-infra-hbase</module>
+ <module>camel-test-infra-infinispan</module>
</modules>
</project>