Add support for Testcontainer Redis
Add support for the official `com.redis:testcontainers-redis` container. See gh-41450
This commit is contained in:
committed by
Phillip Webb
parent
926b0ec1c8
commit
e7faca3bbb
@@ -32,6 +32,7 @@ dependencies {
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
|
||||
dockerTestImplementation("com.redis:testcontainers-redis")
|
||||
dockerTestImplementation("org.testcontainers:junit-jupiter")
|
||||
|
||||
ehcache(enforcedPlatform(project(":spring-boot-project:spring-boot-dependencies")))
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package smoketest.cache;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
@@ -23,7 +24,6 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.cache.Cache;
|
||||
import org.springframework.cache.CacheManager;
|
||||
|
||||
@@ -11,6 +11,7 @@ dependencies {
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
|
||||
dockerTestImplementation("com.redis:testcontainers-redis")
|
||||
dockerTestImplementation("io.projectreactor:reactor-core")
|
||||
dockerTestImplementation("io.projectreactor:reactor-test")
|
||||
dockerTestImplementation("org.junit.jupiter:junit-jupiter")
|
||||
|
||||
@@ -19,6 +19,7 @@ package smoketest.data.redis;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
@@ -27,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.autoconfigure.data.redis.DataRedisTest;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package smoketest.data.redis;
|
||||
import java.time.Duration;
|
||||
import java.util.UUID;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
@@ -27,7 +28,6 @@ import reactor.test.StepVerifier;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.data.redis.core.ReactiveRedisOperations;
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ package smoketest.data.redis;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
@@ -26,7 +27,6 @@ import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.data.redis.core.RedisOperations;
|
||||
|
||||
|
||||
@@ -16,11 +16,10 @@
|
||||
|
||||
package smoketest.data.redis;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
import org.testcontainers.utility.DockerImageName;
|
||||
import org.testcontainers.utility.MountableFile;
|
||||
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
|
||||
/**
|
||||
* A {@link RedisContainer} for Redis with SSL configuration.
|
||||
*
|
||||
|
||||
@@ -10,6 +10,7 @@ dependencies {
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||
dockerTestImplementation("com.redis:testcontainers-redis")
|
||||
dockerTestImplementation("org.testcontainers:junit-jupiter")
|
||||
|
||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-actuator"))
|
||||
|
||||
@@ -21,6 +21,7 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
@@ -29,7 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.client.TestRestTemplate;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.core.ParameterizedTypeReference;
|
||||
import org.springframework.http.HttpEntity;
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package smoketest.session.redis;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.testcontainers.context.ImportTestcontainers;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
import org.springframework.test.context.DynamicPropertySource;
|
||||
|
||||
@@ -16,9 +16,10 @@
|
||||
|
||||
package smoketest.session.redis;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.test.context.DynamicPropertyRegistry;
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
package smoketest.session.redis;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.testcontainers.context.ImportTestcontainers;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
|
||||
public class TestServiceConnectionImportSampleSessionRedisApplication {
|
||||
|
||||
@@ -16,10 +16,11 @@
|
||||
|
||||
package smoketest.session.redis;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.test.context.TestConfiguration;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class TestServiceConnectionSampleSessionRedisApplication {
|
||||
static class ContainerConfiguration {
|
||||
|
||||
@Bean
|
||||
@ServiceConnection("redis")
|
||||
@ServiceConnection
|
||||
RedisContainer redisContainer() {
|
||||
return TestImage.container(RedisContainer.class);
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ dependencies {
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-test"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
|
||||
dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
|
||||
dockerTestImplementation("com.redis:testcontainers-redis")
|
||||
dockerTestImplementation("org.testcontainers:junit-jupiter")
|
||||
|
||||
implementation(project(":spring-boot-project:spring-boot-starters:spring-boot-starter-security"))
|
||||
|
||||
@@ -19,6 +19,7 @@ package smoketest.session;
|
||||
import java.time.Duration;
|
||||
import java.util.Base64;
|
||||
|
||||
import com.redis.testcontainers.RedisContainer;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.junit.jupiter.Container;
|
||||
import org.testcontainers.junit.jupiter.Testcontainers;
|
||||
@@ -28,7 +29,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.boot.test.web.server.LocalServerPort;
|
||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
|
||||
import org.springframework.boot.testsupport.container.RedisContainer;
|
||||
import org.springframework.boot.testsupport.container.TestImage;
|
||||
import org.springframework.http.HttpStatus;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
|
||||
Reference in New Issue
Block a user