Skip to content

Commit

Permalink
Upgrades to Infinispan 13.0.0.Final, adds infinispan test resource
Browse files Browse the repository at this point in the history
  • Loading branch information
karesti committed Oct 14, 2021
1 parent ec0a2d0 commit e9680f5
Show file tree
Hide file tree
Showing 5 changed files with 141 additions and 1 deletion.
12 changes: 11 additions & 1 deletion bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<junit.jupiter.version>5.8.1</junit.jupiter.version>
<testng.version>6.14.2</testng.version>
<assertj.version>3.20.2</assertj.version>
<infinispan.version>12.1.7.Final</infinispan.version>
<infinispan.version>13.0.0.Final</infinispan.version>
<infinispan.protostream.version>4.4.1.Final</infinispan.protostream.version>
<caffeine.version>2.9.2</caffeine.version>
<netty.version>4.1.68.Final</netty.version>
Expand Down Expand Up @@ -4802,6 +4802,11 @@
<artifactId>infinispan-objectfilter</artifactId>
<version>${infinispan.version}</version>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-server-testdriver-core</artifactId>
<version>${infinispan.version}</version>
</dependency>
<dependency>
<groupId>org.infinispan.protostream</groupId>
<artifactId>protostream-processor</artifactId>
Expand All @@ -4822,6 +4827,11 @@
<artifactId>infinispan-component-annotations</artifactId>
<version>${infinispan.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-infinispan-client</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.reactivestreams</groupId>
<artifactId>reactive-streams</artifactId>
Expand Down
10 changes: 10 additions & 0 deletions docs/src/main/asciidoc/infinispan-client.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,16 @@ The Infinispan Client has additional features that were not mentioned here. This
feature was not tested in a Quarkus environment and they may or may not work. Please let us
know if you need these added!

== Testing helpers

To start a Infinispan Server for your unit tests, Quarkus provides one `QuarkusTestResourceLifecycleManager` that relies on link:https://infinispan.org/docs/stable/titles/hotrod_java/hotrod_java.html#junit-testing[Infinispan Server Test Container].

- `io.quarkus.test.infinispan.client.InfinispanTestResource` will start a single instance on port 11222 with user 'admin' and password 'secret'.

To use them, you need to add the `io.quarkus:quarkus-test-infinispan-client` dependency to your pom.xml.

For more information about the usage of a `QuarkusTestResourceLifecycleManager` please read link:getting-started-testing#quarkus-test-resource[Quarkus test resource].

== Configuration Reference

include::{generated-dir}/config/quarkus-infinispan-client.adoc[opts=optional, leveloffset=+1]
67 changes: 67 additions & 0 deletions test-framework/infinispan-client/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-framework</artifactId>
<version>999-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>quarkus-test-infinispan-client</artifactId>
<name>Quarkus - Test Framework - Infinispan Client Support</name>
<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-test-common</artifactId>
</dependency>
<dependency>
<groupId>org.infinispan</groupId>
<artifactId>infinispan-server-testdriver-core</artifactId>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-interpolation</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-embedder</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-http-shared</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j-impl</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
</exclusion>
<exclusion>
<groupId>org.glassfish</groupId>
<artifactId>javax.json</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.marshalling</groupId>
<artifactId>jboss-marshalling-osgi</artifactId>
</exclusion>
<exclusion>
<groupId>org.jboss.shrinkwrap.resolver</groupId>
<artifactId>shrinkwrap-resolver-impl-maven-archive</artifactId>
</exclusion>
<exclusion>
<groupId>net.spy</groupId>
<artifactId>spymemcached</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.quarkus.test.infinispan.client;

import java.util.Collections;
import java.util.Map;
import java.util.Optional;

import org.infinispan.client.hotrod.impl.ConfigurationProperties;
import org.infinispan.commons.util.Version;
import org.infinispan.server.test.core.InfinispanContainer;
import org.jboss.logging.Logger;

import io.quarkus.test.common.QuarkusTestResourceLifecycleManager;

public class InfinispanTestResource implements QuarkusTestResourceLifecycleManager {
private static final Logger LOGGER = Logger.getLogger(InfinispanTestResource.class);
public static final String PORT_ARG = "port";
public static final String USER_ARG = "user";
public static final String PASSWORD_ARG = "password";
private static final int DEFAULT_PORT = ConfigurationProperties.DEFAULT_HOTROD_PORT;
private static final String DEFAULT_USER = "admin";
private static final String DEFAULT_PASSWORD = "password";
private static InfinispanContainer INFINISPAN;
private String USER;
private String PASSWORD;
private Integer HOTROD_PORT;

@Override
public void init(Map<String, String> initArgs) {
HOTROD_PORT = Optional.ofNullable(initArgs.get(PORT_ARG)).map(Integer::parseInt).orElse(DEFAULT_PORT);
USER = Optional.ofNullable(initArgs.get(USER_ARG)).orElse(DEFAULT_USER);
PASSWORD = Optional.ofNullable(initArgs.get(PASSWORD_ARG)).orElse(DEFAULT_PASSWORD);
}

@Override
public Map<String, String> start() {
INFINISPAN = new InfinispanContainer();
INFINISPAN.withUser(USER).withPassword(PASSWORD);
LOGGER.infof("Starting Infinispan Server %s on port %s with user %s and password %s", Version.getMajorMinor(),
HOTROD_PORT, USER, PASSWORD);
INFINISPAN.start();

final String hosts = INFINISPAN.getContainerIpAddress() + ":" + INFINISPAN.getMappedPort(HOTROD_PORT);
return Collections.singletonMap("quarkus.infinispan-client.server-list", hosts);
}

@Override
public void stop() {
if (INFINISPAN != null) {
INFINISPAN.stop();
}
}
}
1 change: 1 addition & 0 deletions test-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
<module>keycloak-server</module>
<module>jacoco</module>
<module>mongodb</module>
<module>infinispan-client</module>
</modules>

</project>

0 comments on commit e9680f5

Please sign in to comment.