mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-08-29 03:06:45 +08:00
Polish "Use the container IP address for tests using TestContainer"
See gh-21480
This commit is contained in:
parent
0c2bf70bb8
commit
77981ac2ae
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user