Polish "Use the container IP address for tests using TestContainer"

See gh-21480
This commit is contained in:
Stephane Nicoll
2020-05-25 14:29:24 +02:00
parent 0c2bf70bb8
commit 77981ac2ae
5 changed files with 7 additions and 5 deletions
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -54,7 +54,8 @@ class RedisRepositoriesAutoConfigurationTests {
@BeforeEach
void setUp() {
TestPropertyValues.of("spring.redis.port=" + redis.getFirstMappedPort()).applyTo(this.context.getEnvironment());
TestPropertyValues.of("spring.redis.host=" + redis.getContainerIpAddress(),
"spring.redis.port=" + redis.getFirstMappedPort()).applyTo(this.context.getEnvironment());
}
@AfterEach
@@ -1,5 +1,5 @@
/*
* Copyright 2012-2019 the original author or authors.
* Copyright 2012-2020 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.
@@ -60,8 +60,8 @@ class DataRedisTestIntegrationTests {
@DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.port", redis::getFirstMappedPort);
registry.add("spring.redis.host", redis::getContainerIpAddress);
registry.add("spring.redis.port", redis::getFirstMappedPort);
}
@Test
@@ -46,6 +46,7 @@ class DataRedisTestPropertiesIntegrationTests {
@DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.host", redis::getContainerIpAddress);
registry.add("spring.redis.port", redis::getFirstMappedPort);
}
@@ -49,8 +49,8 @@ class DataRedisTestWithIncludeFilterIntegrationTests {
@DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.port", redis::getFirstMappedPort);
registry.add("spring.redis.host", redis::getContainerIpAddress);
registry.add("spring.redis.port", redis::getFirstMappedPort);
}
@Test