Skip to content

Commit 77981ac

Browse files
committed
Polish "Use the container IP address for tests using TestContainer"
See gh-21480
1 parent 0c2bf70 commit 77981ac

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -54,7 +54,8 @@ class RedisRepositoriesAutoConfigurationTests {
5454

5555
@BeforeEach
5656
void setUp() {
57-
TestPropertyValues.of("spring.redis.port=" + redis.getFirstMappedPort()).applyTo(this.context.getEnvironment());
57+
TestPropertyValues.of("spring.redis.host=" + redis.getContainerIpAddress(),
58+
"spring.redis.port=" + redis.getFirstMappedPort()).applyTo(this.context.getEnvironment());
5859
}
5960

6061
@AfterEach

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 the original author or authors.
2+
* Copyright 2012-2020 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ class DataRedisTestIntegrationTests {
6060

6161
@DynamicPropertySource
6262
static void redisProperties(DynamicPropertyRegistry registry) {
63-
registry.add("spring.redis.port", redis::getFirstMappedPort);
6463
registry.add("spring.redis.host", redis::getContainerIpAddress);
64+
registry.add("spring.redis.port", redis::getFirstMappedPort);
6565
}
6666

6767
@Test

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java

+1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class DataRedisTestPropertiesIntegrationTests {
4646

4747
@DynamicPropertySource
4848
static void redisProperties(DynamicPropertyRegistry registry) {
49+
registry.add("spring.redis.host", redis::getContainerIpAddress);
4950
registry.add("spring.redis.port", redis::getFirstMappedPort);
5051
}
5152

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ class DataRedisTestWithIncludeFilterIntegrationTests {
4949

5050
@DynamicPropertySource
5151
static void redisProperties(DynamicPropertyRegistry registry) {
52-
registry.add("spring.redis.port", redis::getFirstMappedPort);
5352
registry.add("spring.redis.host", redis::getContainerIpAddress);
53+
registry.add("spring.redis.port", redis::getFirstMappedPort);
5454
}
5555

5656
@Test

0 commit comments

Comments
 (0)