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

See gh-21480
This commit is contained in:
Stephane Nicoll 2020-05-25 14:13:26 +02:00
parent 0c2bf70bb8
commit 77981ac2ae
5 changed files with 7 additions and 5 deletions

View File

@ -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

View File

@ -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.

View File

@ -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

View File

@ -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);
}

View File

@ -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