From d08688124e4a6b4b870984240864dd5337714f5b Mon Sep 17 00:00:00 2001 From: Reinhard Prechtl Date: Fri, 22 Dec 2017 15:05:16 +0100 Subject: [PATCH] Create seperate test examples for different Infinispan versions Programmatic cache configuration only works for Infinispan 9.1.x. Previous versions can use a linked configuration file to create caches. The InfinispanContainer needed to be updated in order to make the use of GenericContainer methods work. --- .../infinispan/InfinispanContainer.java | 10 +- ...ricInfinispanContainerIntegrationTest.java | 2 +- ...Infinispan90xContainerIntegrationTest.java | 11 +- ...Infinispan91xContainerIntegrationTest.java | 2 +- .../resources/infinispan-90x-standalone.xml | 286 ++++++++++++++++++ ...lone.xml => infinispan-91x-standalone.xml} | 0 6 files changed, 301 insertions(+), 10 deletions(-) rename src/test/resources/{infinispan-standalone.xml => infinispan-91x-standalone.xml} (100%) diff --git a/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java b/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java index e98b5f5..5cba6be 100644 --- a/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java +++ b/src/main/java/de/rpr/testcontainers/infinispan/InfinispanContainer.java @@ -20,7 +20,7 @@ import static java.time.temporal.ChronoUnit.SECONDS; * @param */ @SuppressWarnings("ALL") -public class InfinispanContainer> extends GenericContainer { +public class InfinispanContainer extends GenericContainer { private static final String IMAGE_NAME = "jboss/infinispan-server"; public static final String STANDALONE_MODE_CMD = "standalone"; @@ -48,7 +48,7 @@ public class InfinispanContainer> extends } private ProtocolVersion protocolVersion; - private Collection cacheNames; + private Collection cacheNames = new ArrayList<>(); private RemoteCacheManager cacheManager; @@ -72,7 +72,7 @@ public class InfinispanContainer> extends this.waitStrategy = new LogMessageWaitStrategy() .withRegEx(".*Infinispan Server.*started in.*\\s") - .withStartupTimeout(Duration.of(20, SECONDS)); + .withStartupTimeout(Duration.of(60, SECONDS)); } /** @@ -87,7 +87,7 @@ public class InfinispanContainer> extends * @return The container instance */ @Override - public SELF withCommand(String cmd) { + public InfinispanContainer withCommand(String cmd) { super.setCommand(cmd); this.withCommand(ensureStandaloneCommand(getCommandParts())); return self(); @@ -100,7 +100,7 @@ public class InfinispanContainer> extends * @return */ @Override - public SELF withCommand(String... commandParts) { + public InfinispanContainer withCommand(String... commandParts) { this.setCommand(ensureStandaloneCommand(commandParts)); return self(); } diff --git a/src/test/java/GenericInfinispanContainerIntegrationTest.java b/src/test/java/GenericInfinispanContainerIntegrationTest.java index d7c981a..024e51d 100644 --- a/src/test/java/GenericInfinispanContainerIntegrationTest.java +++ b/src/test/java/GenericInfinispanContainerIntegrationTest.java @@ -25,7 +25,7 @@ public class GenericInfinispanContainerIntegrationTest { .waitingFor(new LogMessageWaitStrategy().withRegEx(".*Infinispan Server.*started in.*\\s")) .withStartupTimeout(Duration.ofMillis(20000)) .withClasspathResourceMapping( - "infinispan-standalone.xml", + "infinispan-91x-standalone.xml", "/opt/jboss/infinispan-server/standalone/configuration/standalone.xml", BindMode.READ_ONLY) .withCommand("standalone"); diff --git a/src/test/java/Infinispan90xContainerIntegrationTest.java b/src/test/java/Infinispan90xContainerIntegrationTest.java index 734d81c..5d01c93 100644 --- a/src/test/java/Infinispan90xContainerIntegrationTest.java +++ b/src/test/java/Infinispan90xContainerIntegrationTest.java @@ -2,15 +2,20 @@ import de.rpr.testcontainers.infinispan.InfinispanContainer; import org.infinispan.client.hotrod.ProtocolVersion; import org.junit.ClassRule; import org.junit.Test; +import org.testcontainers.containers.BindMode; +import org.testcontainers.containers.GenericContainer; import static org.junit.Assert.assertNotNull; -public class Infinispan91xContainerIntegrationTest { +public class Infinispan90xContainerIntegrationTest { @ClassRule - public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.1.4.Final") + public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.0.3.Final") .withProtocolVersion(ProtocolVersion.PROTOCOL_VERSION_26) - .withCaches("testCache"); + .withClasspathResourceMapping( + "infinispan-90x-standalone.xml", + "/opt/jboss/infinispan-server/standalone/configuration/standalone.xml", + BindMode.READ_ONLY) ; @Test public void rule_should_have_mapped_hotrod_port() { diff --git a/src/test/java/Infinispan91xContainerIntegrationTest.java b/src/test/java/Infinispan91xContainerIntegrationTest.java index eb239ef..734d81c 100644 --- a/src/test/java/Infinispan91xContainerIntegrationTest.java +++ b/src/test/java/Infinispan91xContainerIntegrationTest.java @@ -5,7 +5,7 @@ import org.junit.Test; import static org.junit.Assert.assertNotNull; -public class InfinispanContainerIntegrationTest { +public class Infinispan91xContainerIntegrationTest { @ClassRule public static InfinispanContainer infinispan = new InfinispanContainer("jboss/infinispan-server:9.1.4.Final") diff --git a/src/test/resources/infinispan-90x-standalone.xml b/src/test/resources/infinispan-90x-standalone.xml index e69de29..de9d73f 100644 --- a/src/test/resources/infinispan-90x-standalone.xml +++ b/src/test/resources/infinispan-90x-standalone.xml @@ -0,0 +1,286 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + + org.h2.jdbcx.JdbcDataSource + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/test/resources/infinispan-standalone.xml b/src/test/resources/infinispan-91x-standalone.xml similarity index 100% rename from src/test/resources/infinispan-standalone.xml rename to src/test/resources/infinispan-91x-standalone.xml