Use TestContainers util from spring-boot-test-support

See gh-10516
pull/11498/merge
Madhura Bhave 7 years ago
parent 996b3ef7f2
commit 9a6c339243

@ -16,25 +16,20 @@
package org.springframework.boot.autoconfigure.data.cassandra; package org.springframework.boot.autoconfigure.data.cassandra;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import com.datastax.driver.core.Cluster; import com.datastax.driver.core.Cluster;
import com.datastax.driver.core.Session; import com.datastax.driver.core.Session;
import com.datastax.driver.core.exceptions.NoHostAvailableException;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.rnorth.ducttape.TimeoutException; import org.testcontainers.containers.GenericContainer;
import org.rnorth.ducttape.unreliables.Unreliables;
import org.testcontainers.containers.FixedHostPortGenericContainer;
import org.testcontainers.containers.wait.HostPortWaitStrategy;
import org.springframework.boot.autoconfigure.AutoConfigurationPackages; import org.springframework.boot.autoconfigure.AutoConfigurationPackages;
import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration; import org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration;
import org.springframework.boot.autoconfigure.data.cassandra.city.City; import org.springframework.boot.autoconfigure.data.cassandra.city.City;
import org.springframework.boot.test.util.TestPropertyValues; import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.testcontainers.DockerTestContainer; import org.springframework.boot.testsupport.testcontainers.DockerTestContainer;
import org.springframework.boot.testsupport.testcontainers.TestContainers;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.data.cassandra.config.CassandraSessionFactoryBean; import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
import org.springframework.data.cassandra.config.SchemaAction; import org.springframework.data.cassandra.config.SchemaAction;
@ -50,13 +45,19 @@ import static org.assertj.core.api.Assertions.assertThat;
public class CassandraDataAutoConfigurationIntegrationTests { public class CassandraDataAutoConfigurationIntegrationTests {
@ClassRule @ClassRule
public static DockerTestContainer<FixedHostPortGenericContainer<?>> cassandra = new DockerTestContainer<>( public static DockerTestContainer<GenericContainer<?>> cassandra = new DockerTestContainer<>(
() -> new FixedHostPortGenericContainer<>("cassandra:latest") TestContainers::cassandra);
.withFixedExposedPort(9042, 9042)
.waitingFor(new ConnectionVerifyingWaitStrategy()));
private AnnotationConfigApplicationContext context; private AnnotationConfigApplicationContext context;
@Before
public void setUp() {
this.context = new AnnotationConfigApplicationContext();
TestPropertyValues
.of("spring.data.cassandra.port=" + cassandra.getMappedPort(9042))
.applyTo(this.context.getEnvironment());
}
@After @After
public void close() { public void close() {
if (this.context != null) { if (this.context != null) {
@ -66,7 +67,6 @@ public class CassandraDataAutoConfigurationIntegrationTests {
@Test @Test
public void hasDefaultSchemaActionSet() { public void hasDefaultSchemaActionSet() {
this.context = new AnnotationConfigApplicationContext();
String cityPackage = City.class.getPackage().getName(); String cityPackage = City.class.getPackage().getName();
AutoConfigurationPackages.register(this.context, cityPackage); AutoConfigurationPackages.register(this.context, cityPackage);
this.context.register(CassandraAutoConfiguration.class, this.context.register(CassandraAutoConfiguration.class,
@ -81,7 +81,6 @@ public class CassandraDataAutoConfigurationIntegrationTests {
@Test @Test
public void hasRecreateSchemaActionSet() { public void hasRecreateSchemaActionSet() {
createTestKeyspaceIfNotExists(); createTestKeyspaceIfNotExists();
this.context = new AnnotationConfigApplicationContext();
String cityPackage = City.class.getPackage().getName(); String cityPackage = City.class.getPackage().getName();
AutoConfigurationPackages.register(this.context, cityPackage); AutoConfigurationPackages.register(this.context, cityPackage);
TestPropertyValues TestPropertyValues
@ -97,41 +96,12 @@ public class CassandraDataAutoConfigurationIntegrationTests {
} }
private void createTestKeyspaceIfNotExists() { private void createTestKeyspaceIfNotExists() {
Cluster cluster = Cluster.builder().addContactPoint("localhost").build(); Cluster cluster = Cluster.builder().withPort(cassandra.getMappedPort(9042))
.addContactPoint("localhost").build();
try (Session session = cluster.connect()) { try (Session session = cluster.connect()) {
session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test" session.execute("CREATE KEYSPACE IF NOT EXISTS boot_test"
+ " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };"); + " WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 };");
} }
} }
static class ConnectionVerifyingWaitStrategy extends HostPortWaitStrategy {
@Override
protected void waitUntilReady() {
super.waitUntilReady();
try {
Unreliables.retryUntilTrue((int) this.startupTimeout.getSeconds(),
TimeUnit.SECONDS, checkConnection());
}
catch (TimeoutException ex) {
throw new IllegalStateException(ex);
}
}
private Callable<Boolean> checkConnection() {
return () -> {
try (Cluster cluster = Cluster.builder().addContactPoint("localhost")
.build()) {
cluster.connect();
return true;
}
catch (NoHostAvailableException ex) {
return false;
}
};
}
}
} }

@ -17,6 +17,7 @@
package org.springframework.boot.autoconfigure.data.redis; package org.springframework.boot.autoconfigure.data.redis;
import org.junit.After; import org.junit.After;
import org.junit.Before;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.testcontainers.containers.GenericContainer; import org.testcontainers.containers.GenericContainer;
@ -27,6 +28,7 @@ import org.springframework.boot.autoconfigure.data.alt.redis.CityRedisRepository
import org.springframework.boot.autoconfigure.data.empty.EmptyDataPackage; 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.City;
import org.springframework.boot.autoconfigure.data.redis.city.CityRepository; import org.springframework.boot.autoconfigure.data.redis.city.CityRepository;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.testcontainers.DockerTestContainer; import org.springframework.boot.testsupport.testcontainers.DockerTestContainer;
import org.springframework.boot.testsupport.testcontainers.TestContainers; import org.springframework.boot.testsupport.testcontainers.TestContainers;
import org.springframework.context.annotation.AnnotationConfigApplicationContext; import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@ -44,10 +46,17 @@ public class RedisRepositoriesAutoConfigurationTests {
@ClassRule @ClassRule
public static DockerTestContainer<GenericContainer<?>> redis = new DockerTestContainer<>( public static DockerTestContainer<GenericContainer<?>> redis = new DockerTestContainer<>(
() -> TestContainers.redis()); TestContainers::redis);
private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(); private AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
@Before
public void setUp() {
TestPropertyValues
.of("spring.redis.port=" + redis.getMappedPort(6379))
.applyTo(this.context.getEnvironment());
}
@After @After
public void close() { public void close() {
this.context.close(); this.context.close();

@ -16,9 +16,7 @@
package org.springframework.boot.autoconfigure.session; package org.springframework.boot.autoconfigure.session;
import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.testcontainers.containers.FixedHostPortGenericContainer;
import org.springframework.beans.DirectFieldAccessor; import org.springframework.beans.DirectFieldAccessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
@ -28,7 +26,6 @@ import org.springframework.boot.test.context.FilteredClassLoader;
import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext; import org.springframework.boot.test.context.assertj.AssertableReactiveWebApplicationContext;
import org.springframework.boot.test.context.runner.ContextConsumer; import org.springframework.boot.test.context.runner.ContextConsumer;
import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner; import org.springframework.boot.test.context.runner.ReactiveWebApplicationContextRunner;
import org.springframework.boot.testsupport.testcontainers.DockerTestContainer;
import org.springframework.session.data.mongo.ReactiveMongoOperationsSessionRepository; import org.springframework.session.data.mongo.ReactiveMongoOperationsSessionRepository;
import org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository; import org.springframework.session.data.redis.ReactiveRedisOperationsSessionRepository;
import org.springframework.session.data.redis.RedisFlushMode; import org.springframework.session.data.redis.RedisFlushMode;
@ -45,11 +42,6 @@ import static org.assertj.core.api.Assertions.assertThat;
public class ReactiveSessionAutoConfigurationRedisTests public class ReactiveSessionAutoConfigurationRedisTests
extends AbstractSessionAutoConfigurationTests { extends AbstractSessionAutoConfigurationTests {
@ClassRule
public static DockerTestContainer<FixedHostPortGenericContainer<?>> redis = new DockerTestContainer<>(
() -> new FixedHostPortGenericContainer<>("redis:latest")
.withFixedExposedPort(6379, 6379));
protected final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner() protected final ReactiveWebApplicationContextRunner contextRunner = new ReactiveWebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(SessionAutoConfiguration.class)); .withConfiguration(AutoConfigurations.of(SessionAutoConfiguration.class));

@ -49,7 +49,7 @@ public class SessionAutoConfigurationRedisTests
@ClassRule @ClassRule
public static DockerTestContainer<GenericContainer<?>> redis = new DockerTestContainer<>( public static DockerTestContainer<GenericContainer<?>> redis = new DockerTestContainer<>(
() -> TestContainers.redis()); TestContainers::redis);
protected final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner() protected final WebApplicationContextRunner contextRunner = new WebApplicationContextRunner()
.withConfiguration(AutoConfigurations.of(SessionAutoConfiguration.class)); .withConfiguration(AutoConfigurations.of(SessionAutoConfiguration.class));

@ -16,26 +16,23 @@
package org.springframework.boot.test.autoconfigure.data.neo4j; package org.springframework.boot.test.autoconfigure.data.neo4j;
import java.util.concurrent.Callable;
import java.util.concurrent.TimeUnit;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Rule; import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.neo4j.ogm.config.Configuration;
import org.neo4j.ogm.session.Session; import org.neo4j.ogm.session.Session;
import org.neo4j.ogm.session.SessionFactory; import org.testcontainers.containers.GenericContainer;
import org.rnorth.ducttape.TimeoutException;
import org.rnorth.ducttape.unreliables.Unreliables;
import org.testcontainers.containers.FixedHostPortGenericContainer;
import org.testcontainers.containers.wait.HostPortWaitStrategy;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.testcontainers.DockerTestContainer; import org.springframework.boot.testsupport.testcontainers.DockerTestContainer;
import org.springframework.boot.testsupport.testcontainers.TestContainers;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -47,15 +44,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Stephane Nicoll * @author Stephane Nicoll
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(initializers = DataNeo4jTestIntegrationTests.Initializer.class)
@DataNeo4jTest @DataNeo4jTest
public class DataNeo4jTestIntegrationTests { public class DataNeo4jTestIntegrationTests {
@ClassRule @ClassRule
public static DockerTestContainer<FixedHostPortGenericContainer<?>> neo4j = new DockerTestContainer<>( public static DockerTestContainer<GenericContainer<?>> neo4j = new DockerTestContainer<>(
() -> new FixedHostPortGenericContainer<>("neo4j:latest") TestContainers::neo4j);
.withFixedExposedPort(7687, 7687)
.waitingFor(new ConnectionVerifyingWaitStrategy())
.withEnv("NEO4J_AUTH", "none"));
@Rule @Rule
public ExpectedException thrown = ExpectedException.none(); public ExpectedException thrown = ExpectedException.none();
@ -85,35 +80,17 @@ public class DataNeo4jTestIntegrationTests {
this.applicationContext.getBean(ExampleService.class); this.applicationContext.getBean(ExampleService.class);
} }
static class ConnectionVerifyingWaitStrategy extends HostPortWaitStrategy { static class Initializer
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override @Override
protected void waitUntilReady() { public void initialize(
super.waitUntilReady(); ConfigurableApplicationContext configurableApplicationContext) {
Configuration configuration = new Configuration.Builder() TestPropertyValues
.uri("bolt://localhost:7687").build(); .of("spring.data.neo4j.uri=bolt://localhost:" + neo4j.getMappedPort(7687))
SessionFactory sessionFactory = new SessionFactory(configuration, .applyTo(configurableApplicationContext.getEnvironment());
"org.springframework.boot.test.autoconfigure.data.neo4j");
try {
Unreliables.retryUntilTrue((int) this.startupTimeout.getSeconds(),
TimeUnit.SECONDS, checkConnection(sessionFactory));
}
catch (TimeoutException e) {
throw new IllegalStateException();
}
} }
private Callable<Boolean> checkConnection(SessionFactory sessionFactory) {
return () -> {
try {
sessionFactory.openSession().beginTransaction().close();
return true;
}
catch (Exception ex) {
return false;
}
};
}
} }
} }

@ -19,12 +19,17 @@ package org.springframework.boot.test.autoconfigure.data.neo4j;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.testcontainers.containers.FixedHostPortGenericContainer; import org.testcontainers.containers.GenericContainer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.testcontainers.DockerTestContainer; import org.springframework.boot.testsupport.testcontainers.DockerTestContainer;
import org.springframework.boot.testsupport.testcontainers.TestContainers;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -35,16 +40,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Eddú Meléndez * @author Eddú Meléndez
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(initializers = DataNeo4jTestWithIncludeFilterIntegrationTests.Initializer.class)
@DataNeo4jTest(includeFilters = @Filter(Service.class)) @DataNeo4jTest(includeFilters = @Filter(Service.class))
public class DataNeo4jTestWithIncludeFilterIntegrationTests { public class DataNeo4jTestWithIncludeFilterIntegrationTests {
@ClassRule @ClassRule
public static DockerTestContainer<FixedHostPortGenericContainer<?>> neo4j = new DockerTestContainer<>( public static DockerTestContainer<GenericContainer<?>> neo4j = new DockerTestContainer<>(
() -> new FixedHostPortGenericContainer<>("neo4j:latest") TestContainers::neo4j);
.withFixedExposedPort(7687, 7687)
.waitingFor(
new DataNeo4jTestIntegrationTests.ConnectionVerifyingWaitStrategy())
.withEnv("NEO4J_AUTH", "none"));
@Autowired @Autowired
private ExampleService service; private ExampleService service;
@ -54,4 +56,17 @@ public class DataNeo4jTestWithIncludeFilterIntegrationTests {
assertThat(this.service.hasNode(ExampleGraph.class)).isFalse(); assertThat(this.service.hasNode(ExampleGraph.class)).isFalse();
} }
static class Initializer
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(
ConfigurableApplicationContext configurableApplicationContext) {
TestPropertyValues
.of("spring.data.neo4j.uri=bolt://localhost:" + neo4j.getMappedPort(7687))
.applyTo(configurableApplicationContext.getEnvironment());
}
}
} }

@ -24,14 +24,19 @@ import org.junit.Rule;
import org.junit.Test; import org.junit.Test;
import org.junit.rules.ExpectedException; import org.junit.rules.ExpectedException;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.testcontainers.containers.FixedHostPortGenericContainer; import org.testcontainers.containers.GenericContainer;
import org.springframework.beans.factory.NoSuchBeanDefinitionException; import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.testcontainers.DockerTestContainer; import org.springframework.boot.testsupport.testcontainers.DockerTestContainer;
import org.springframework.boot.testsupport.testcontainers.TestContainers;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.data.redis.connection.RedisConnection; import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.core.RedisOperations; import org.springframework.data.redis.core.RedisOperations;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -42,13 +47,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Jayaram Pradhan * @author Jayaram Pradhan
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(initializers = DataRedisTestIntegrationTests.Initializer.class)
@DataRedisTest @DataRedisTest
public class DataRedisTestIntegrationTests { public class DataRedisTestIntegrationTests {
@ClassRule @ClassRule
public static DockerTestContainer<FixedHostPortGenericContainer<?>> redis = new DockerTestContainer<>( public static DockerTestContainer<GenericContainer<?>> redis = new DockerTestContainer<>(
() -> new FixedHostPortGenericContainer<>("redis:latest") TestContainers::redis);
.withFixedExposedPort(6379, 6379));
@Rule @Rule
public ExpectedException thrown = ExpectedException.none(); public ExpectedException thrown = ExpectedException.none();
@ -82,4 +87,17 @@ public class DataRedisTestIntegrationTests {
this.applicationContext.getBean(ExampleService.class); this.applicationContext.getBean(ExampleService.class);
} }
static class Initializer
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(
ConfigurableApplicationContext configurableApplicationContext) {
TestPropertyValues
.of("spring.redis.port=" + redis.getMappedPort(6379))
.applyTo(configurableApplicationContext.getEnvironment());
}
}
} }

@ -19,12 +19,17 @@ package org.springframework.boot.test.autoconfigure.data.redis;
import org.junit.ClassRule; import org.junit.ClassRule;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.testcontainers.containers.FixedHostPortGenericContainer; import org.testcontainers.containers.GenericContainer;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.util.TestPropertyValues;
import org.springframework.boot.testsupport.testcontainers.DockerTestContainer; import org.springframework.boot.testsupport.testcontainers.DockerTestContainer;
import org.springframework.boot.testsupport.testcontainers.TestContainers;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ComponentScan.Filter; import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.context.junit4.SpringRunner;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
@ -35,13 +40,13 @@ import static org.assertj.core.api.Assertions.assertThat;
* @author Jayaram Pradhan * @author Jayaram Pradhan
*/ */
@RunWith(SpringRunner.class) @RunWith(SpringRunner.class)
@ContextConfiguration(initializers = DataRedisTestWithIncludeFilterIntegrationTests.Initializer.class)
@DataRedisTest(includeFilters = @Filter(Service.class)) @DataRedisTest(includeFilters = @Filter(Service.class))
public class DataRedisTestWithIncludeFilterIntegrationTests { public class DataRedisTestWithIncludeFilterIntegrationTests {
@ClassRule @ClassRule
public static DockerTestContainer<FixedHostPortGenericContainer<?>> redis = new DockerTestContainer<>( public static DockerTestContainer<GenericContainer<?>> redis = new DockerTestContainer<>(
() -> new FixedHostPortGenericContainer<>("redis:latest") TestContainers::redis);
.withFixedExposedPort(6379, 6379));
@Autowired @Autowired
private ExampleRepository exampleRepository; private ExampleRepository exampleRepository;
@ -58,4 +63,17 @@ public class DataRedisTestWithIncludeFilterIntegrationTests {
assertThat(this.service.hasRecord(savedEntity)).isTrue(); assertThat(this.service.hasRecord(savedEntity)).isTrue();
} }
static class Initializer
implements ApplicationContextInitializer<ConfigurableApplicationContext> {
@Override
public void initialize(
ConfigurableApplicationContext configurableApplicationContext) {
TestPropertyValues
.of("spring.redis.port=" + redis.getMappedPort(6379))
.applyTo(configurableApplicationContext.getEnvironment());
}
}
} }

Loading…
Cancel
Save