Add support for Testcontainer Redis
Add support for the official `com.redis:testcontainers-redis` container. See gh-41450
This commit is contained in:
		
							parent
							
								
									926b0ec1c8
								
							
						
					
					
						commit
						e7faca3bbb
					
				| 
						 | 
				
			
			@ -15,6 +15,7 @@ dependencies {
 | 
			
		|||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-autoconfigure"))
 | 
			
		||||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-test"))
 | 
			
		||||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
 | 
			
		||||
	dockerTestImplementation("com.redis:testcontainers-redis")
 | 
			
		||||
	dockerTestImplementation("org.assertj:assertj-core")
 | 
			
		||||
	dockerTestImplementation("org.junit.jupiter:junit-jupiter")
 | 
			
		||||
	dockerTestImplementation("org.springframework:spring-test")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ package org.springframework.boot.actuate.metrics.cache;
 | 
			
		|||
import java.util.UUID;
 | 
			
		||||
import java.util.function.BiConsumer;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import io.micrometer.core.instrument.MeterRegistry;
 | 
			
		||||
import io.micrometer.core.instrument.Tags;
 | 
			
		||||
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +33,6 @@ import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
 | 
			
		|||
import org.springframework.boot.test.context.assertj.AssertableApplicationContext;
 | 
			
		||||
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
 | 
			
		||||
import org.springframework.boot.test.context.runner.ContextConsumer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.cache.annotation.EnableCaching;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -25,7 +25,9 @@ dependencies {
 | 
			
		|||
 | 
			
		||||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-test"))
 | 
			
		||||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
 | 
			
		||||
	dockerTestImplementation("com.redis:testcontainers-redis")
 | 
			
		||||
	dockerTestImplementation("org.assertj:assertj-core")
 | 
			
		||||
	dockerTestImplementation("org.awaitility:awaitility")
 | 
			
		||||
	dockerTestImplementation("org.junit.jupiter:junit-jupiter")
 | 
			
		||||
	dockerTestImplementation("org.mockito:mockito-core")
 | 
			
		||||
	dockerTestImplementation("org.springframework:spring-test")
 | 
			
		||||
| 
						 | 
				
			
			@ -37,7 +39,6 @@ dependencies {
 | 
			
		|||
	dockerTestImplementation("org.testcontainers:neo4j")
 | 
			
		||||
	dockerTestImplementation("org.testcontainers:pulsar")
 | 
			
		||||
	dockerTestImplementation("org.testcontainers:testcontainers")
 | 
			
		||||
	dockerTestImplementation("org.awaitility:awaitility")
 | 
			
		||||
 | 
			
		||||
	optional("co.elastic.clients:elasticsearch-java") {
 | 
			
		||||
		exclude group: "commons-logging", module: "commons-logging"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.boot.autoconfigure.data.redis;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.AfterEach;
 | 
			
		||||
import org.junit.jupiter.api.BeforeEach;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +30,6 @@ import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage;
 | 
			
		|||
import org.springframework.boot.autoconfigure.data.redis.city.City;
 | 
			
		||||
import org.springframework.boot.autoconfigure.data.redis.city.CityRepository;
 | 
			
		||||
import org.springframework.boot.test.util.TestPropertyValues;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.session;
 | 
			
		|||
import java.time.Duration;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Container;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Testcontainers;
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +32,6 @@ import org.springframework.boot.test.context.FilteredClassLoader;
 | 
			
		|||
import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext;
 | 
			
		||||
import org.springframework.boot.test.context.runner.ContextConsumer;
 | 
			
		||||
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.http.ResponseCookie;
 | 
			
		||||
import org.springframework.session.MapSession;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ package org.springframework.boot.autoconfigure.session;
 | 
			
		|||
import java.time.Duration;
 | 
			
		||||
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;
 | 
			
		||||
| 
						 | 
				
			
			@ -31,7 +32,6 @@ import org.springframework.boot.test.context.FilteredClassLoader;
 | 
			
		|||
import org.springframework.boot.test.context.assertj.AssertableWebApplicationContext;
 | 
			
		||||
import org.springframework.boot.test.context.runner.ContextConsumer;
 | 
			
		||||
import org.springframework.boot.test.context.runner.WebApplicationContextRunner;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2167,6 +2167,16 @@ bom {
 | 
			
		|||
			releaseNotes("https://github.com/testcontainers/testcontainers-java/releases/tag/{version}")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	library("Testcontainers Redis Module", "2.2.2") {
 | 
			
		||||
		group("com.redis") {
 | 
			
		||||
			modules = [
 | 
			
		||||
				"testcontainers-redis"
 | 
			
		||||
			]
 | 
			
		||||
		}
 | 
			
		||||
		links {
 | 
			
		||||
			site("https://testcontainers.com/modules/redis/")
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	library("Thymeleaf", "3.1.2.RELEASE") {
 | 
			
		||||
		group("org.thymeleaf") {
 | 
			
		||||
			modules = [
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -13,6 +13,7 @@ dependencies {
 | 
			
		|||
	api(project(":spring-boot-project:spring-boot"))
 | 
			
		||||
 | 
			
		||||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
 | 
			
		||||
	dockerTestImplementation("com.redis:testcontainers-redis")
 | 
			
		||||
	dockerTestImplementation("org.assertj:assertj-core")
 | 
			
		||||
	dockerTestImplementation("org.awaitility:awaitility")
 | 
			
		||||
	dockerTestImplementation("org.junit.jupiter:junit-jupiter")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -107,8 +107,8 @@ This works as long as Spring Boot is able to get the instance of the `Container`
 | 
			
		|||
 | 
			
		||||
If you're using a `@Bean` method, Spring Boot won't call the bean method to get the Docker image name, because this would cause eager initialization issues.
 | 
			
		||||
Instead, the return type of the bean method is used to find out which connection detail should be used.
 | 
			
		||||
This works as long as you're using typed containers, e.g. `Neo4jContainer` or `RabbitMQContainer`.
 | 
			
		||||
This stops working if you're using `GenericContainer`, e.g. with Redis, as shown in the following example:
 | 
			
		||||
This works as long as you're using typed containers such as `Neo4jContainer` or `RabbitMQContainer`.
 | 
			
		||||
This stops working if you're using `GenericContainer`, for example with Redis as shown in the following example:
 | 
			
		||||
 | 
			
		||||
include-code::MyRedisConfiguration[]
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@ dependencies {
 | 
			
		|||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
 | 
			
		||||
	dockerTestImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support-docker"))
 | 
			
		||||
	dockerTestImplementation("io.projectreactor:reactor-test")
 | 
			
		||||
	dockerTestImplementation("com.redis:testcontainers-redis")
 | 
			
		||||
	dockerTestImplementation("org.assertj:assertj-core")
 | 
			
		||||
	dockerTestImplementation("org.junit.jupiter:junit-jupiter")
 | 
			
		||||
	dockerTestImplementation("org.testcontainers:cassandra")
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ package org.springframework.boot.test.autoconfigure.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.NoSuchBeanDefinitionException;
 | 
			
		|||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
 | 
			
		||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnectionAutoConfiguration;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.ApplicationContext;
 | 
			
		||||
import org.springframework.data.redis.core.RedisOperations;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.boot.test.autoconfigure.data.redis;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Nested;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Container;
 | 
			
		||||
| 
						 | 
				
			
			@ -23,7 +24,6 @@ import org.testcontainers.junit.jupiter.Testcontainers;
 | 
			
		|||
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
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.env.Environment;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ package org.springframework.boot.test.autoconfigure.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.NoSuchBeanDefinitionException;
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
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.ApplicationContext;
 | 
			
		||||
import org.springframework.data.redis.core.ReactiveRedisOperations;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,13 +16,13 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.boot.test.autoconfigure.data.redis;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Container;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Testcontainers;
 | 
			
		||||
 | 
			
		||||
import org.springframework.beans.factory.annotation.Autowired;
 | 
			
		||||
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.ComponentScan.Filter;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -81,6 +81,7 @@ dependencies {
 | 
			
		|||
	optional("org.testcontainers:rabbitmq")
 | 
			
		||||
	optional("org.testcontainers:redpanda")
 | 
			
		||||
	optional("org.testcontainers:r2dbc")
 | 
			
		||||
	optional("com.redis:testcontainers-redis")
 | 
			
		||||
 | 
			
		||||
	testImplementation(project(":spring-boot-project:spring-boot-test"))
 | 
			
		||||
	testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -20,6 +20,7 @@ import java.util.ArrayList;
 | 
			
		|||
import java.util.Collections;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.junit.jupiter.api.extension.ExtendWith;
 | 
			
		||||
import org.junit.jupiter.api.extension.ExtensionContext;
 | 
			
		||||
| 
						 | 
				
			
			@ -30,7 +31,6 @@ import org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycle
 | 
			
		|||
import org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycleOrderIntegrationTests.TestConfig;
 | 
			
		||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
 | 
			
		||||
import org.springframework.boot.testsupport.container.DisabledIfDockerUnavailable;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
| 
						 | 
				
			
			@ -63,7 +63,7 @@ class TestcontainersLifecycleOrderIntegrationTests {
 | 
			
		|||
	static class ContainerConfig {
 | 
			
		||||
 | 
			
		||||
		@Bean
 | 
			
		||||
		@ServiceConnection("redis")
 | 
			
		||||
		@ServiceConnection
 | 
			
		||||
		RedisContainer redisContainer() {
 | 
			
		||||
			return TestImage.container(EventRecordingRedisContainer.class);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -22,6 +22,7 @@ import java.util.HashMap;
 | 
			
		|||
import java.util.List;
 | 
			
		||||
import java.util.Map;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.junit.jupiter.api.extension.ExtendWith;
 | 
			
		||||
import org.junit.jupiter.api.extension.ExtensionContext;
 | 
			
		||||
| 
						 | 
				
			
			@ -34,7 +35,6 @@ import org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycle
 | 
			
		|||
import org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycleOrderWithScopeIntegrationTests.TestConfig;
 | 
			
		||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
 | 
			
		||||
import org.springframework.boot.testsupport.container.DisabledIfDockerUnavailable;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
| 
						 | 
				
			
			@ -74,7 +74,7 @@ class TestcontainersLifecycleOrderWithScopeIntegrationTests {
 | 
			
		|||
 | 
			
		||||
		@Bean
 | 
			
		||||
		@Scope("custom")
 | 
			
		||||
		@ServiceConnection("redis")
 | 
			
		||||
		@ServiceConnection
 | 
			
		||||
		RedisContainer redisContainer() {
 | 
			
		||||
			return TestImage.container(EventRecordingRedisContainer.class);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -19,6 +19,7 @@ package org.springframework.boot.testcontainers.properties;
 | 
			
		|||
import java.util.ArrayList;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
 | 
			
		||||
import org.springframework.boot.autoconfigure.AutoConfigurations;
 | 
			
		||||
| 
						 | 
				
			
			@ -28,7 +29,6 @@ import org.springframework.boot.test.context.runner.ApplicationContextRunner;
 | 
			
		|||
import org.springframework.boot.testcontainers.lifecycle.BeforeTestcontainerUsedEvent;
 | 
			
		||||
import org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycleApplicationContextInitializer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.DisabledIfDockerUnavailable;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.ApplicationEvent;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,6 +18,7 @@ package org.springframework.boot.testcontainers.service.connection;
 | 
			
		|||
 | 
			
		||||
import java.util.Set;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.mockito.Mockito;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -32,7 +33,6 @@ import org.springframework.boot.testcontainers.beans.TestcontainerBeanDefinition
 | 
			
		|||
import org.springframework.boot.testcontainers.lifecycle.TestcontainersLifecycleApplicationContextInitializer;
 | 
			
		||||
import org.springframework.boot.testsupport.classpath.ClassPathExclusions;
 | 
			
		||||
import org.springframework.boot.testsupport.container.DisabledIfDockerUnavailable;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 | 
			
		||||
import org.springframework.context.annotation.Bean;
 | 
			
		||||
| 
						 | 
				
			
			@ -134,7 +134,7 @@ class ServiceConnectionAutoConfigurationTests {
 | 
			
		|||
	static class ContainerConfiguration {
 | 
			
		||||
 | 
			
		||||
		@Bean
 | 
			
		||||
		@ServiceConnection("redis")
 | 
			
		||||
		@ServiceConnection
 | 
			
		||||
		RedisContainer redisContainer() {
 | 
			
		||||
			return TestImage.container(RedisContainer.class);
 | 
			
		||||
		}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.boot.testcontainers.service.connection.redis;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Container;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Testcontainers;
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +26,6 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
 | 
			
		|||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
 | 
			
		||||
import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails;
 | 
			
		||||
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.Configuration;
 | 
			
		||||
import org.springframework.data.redis.connection.RedisConnection;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -16,6 +16,7 @@
 | 
			
		|||
 | 
			
		||||
package org.springframework.boot.testcontainers.service.connection.redis;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisStackContainer;
 | 
			
		||||
import org.junit.jupiter.api.Test;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Container;
 | 
			
		||||
import org.testcontainers.junit.jupiter.Testcontainers;
 | 
			
		||||
| 
						 | 
				
			
			@ -25,7 +26,6 @@ import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
 | 
			
		|||
import org.springframework.boot.autoconfigure.data.redis.RedisAutoConfiguration;
 | 
			
		||||
import org.springframework.boot.autoconfigure.data.redis.RedisConnectionDetails;
 | 
			
		||||
import org.springframework.boot.testcontainers.service.connection.ServiceConnection;
 | 
			
		||||
import org.springframework.boot.testsupport.container.RedisStackContainer;
 | 
			
		||||
import org.springframework.boot.testsupport.container.TestImage;
 | 
			
		||||
import org.springframework.context.annotation.Configuration;
 | 
			
		||||
import org.springframework.data.redis.connection.RedisConnection;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -31,4 +31,5 @@ dependencies {
 | 
			
		|||
	optional("org.testcontainers:pulsar")
 | 
			
		||||
	optional("org.testcontainers:rabbitmq")
 | 
			
		||||
	optional("org.testcontainers:redpanda")
 | 
			
		||||
	optional("com.redis:testcontainers-redis")
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,35 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2012-2024 the original author or authors.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed 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
 | 
			
		||||
 *
 | 
			
		||||
 *      https://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.springframework.boot.testsupport.container;
 | 
			
		||||
 | 
			
		||||
import org.testcontainers.containers.GenericContainer;
 | 
			
		||||
import org.testcontainers.utility.DockerImageName;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A {@link GenericContainer} for Redis.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Andy Wilkinson
 | 
			
		||||
 * @author Madhura Bhave
 | 
			
		||||
 */
 | 
			
		||||
public class RedisContainer extends GenericContainer<RedisContainer> {
 | 
			
		||||
 | 
			
		||||
	public RedisContainer(DockerImageName dockerImageName) {
 | 
			
		||||
		super(dockerImageName);
 | 
			
		||||
		addExposedPorts(6379);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -1,35 +0,0 @@
 | 
			
		|||
/*
 | 
			
		||||
 * Copyright 2012-2024 the original author or authors.
 | 
			
		||||
 *
 | 
			
		||||
 * Licensed 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
 | 
			
		||||
 *
 | 
			
		||||
 *      https://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.springframework.boot.testsupport.container;
 | 
			
		||||
 | 
			
		||||
import org.testcontainers.containers.GenericContainer;
 | 
			
		||||
import org.testcontainers.utility.DockerImageName;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * A {@link GenericContainer} for Redis Stack.
 | 
			
		||||
 *
 | 
			
		||||
 * @author Andy Wilkinson
 | 
			
		||||
 * @author Madhura Bhave
 | 
			
		||||
 */
 | 
			
		||||
public class RedisStackContainer extends GenericContainer<RedisStackContainer> {
 | 
			
		||||
 | 
			
		||||
	public RedisStackContainer(DockerImageName dockerImageName) {
 | 
			
		||||
		super(dockerImageName);
 | 
			
		||||
		addExposedPorts(6379);
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
| 
						 | 
				
			
			@ -23,6 +23,8 @@ import java.util.List;
 | 
			
		|||
import java.util.function.Consumer;
 | 
			
		||||
import java.util.function.Supplier;
 | 
			
		||||
 | 
			
		||||
import com.redis.testcontainers.RedisContainer;
 | 
			
		||||
import com.redis.testcontainers.RedisStackContainer;
 | 
			
		||||
import org.testcontainers.activemq.ActiveMQContainer;
 | 
			
		||||
import org.testcontainers.activemq.ArtemisContainer;
 | 
			
		||||
import org.testcontainers.containers.CassandraContainer;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in New Issue