Commit 77981ac2 authored by Stephane Nicoll's avatar Stephane Nicoll

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

See gh-21480
parent 0c2bf70b
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -54,7 +54,8 @@ class RedisRepositoriesAutoConfigurationTests { ...@@ -54,7 +54,8 @@ class RedisRepositoriesAutoConfigurationTests {
@BeforeEach @BeforeEach
void setUp() { 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 @AfterEach
......
/* /*
* 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"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
......
...@@ -60,8 +60,8 @@ class DataRedisTestIntegrationTests { ...@@ -60,8 +60,8 @@ class DataRedisTestIntegrationTests {
@DynamicPropertySource @DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) { static void redisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.port", redis::getFirstMappedPort);
registry.add("spring.redis.host", redis::getContainerIpAddress); registry.add("spring.redis.host", redis::getContainerIpAddress);
registry.add("spring.redis.port", redis::getFirstMappedPort);
} }
@Test @Test
......
...@@ -46,6 +46,7 @@ class DataRedisTestPropertiesIntegrationTests { ...@@ -46,6 +46,7 @@ class DataRedisTestPropertiesIntegrationTests {
@DynamicPropertySource @DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) { static void redisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.host", redis::getContainerIpAddress);
registry.add("spring.redis.port", redis::getFirstMappedPort); registry.add("spring.redis.port", redis::getFirstMappedPort);
} }
......
...@@ -49,8 +49,8 @@ class DataRedisTestWithIncludeFilterIntegrationTests { ...@@ -49,8 +49,8 @@ class DataRedisTestWithIncludeFilterIntegrationTests {
@DynamicPropertySource @DynamicPropertySource
static void redisProperties(DynamicPropertyRegistry registry) { static void redisProperties(DynamicPropertyRegistry registry) {
registry.add("spring.redis.port", redis::getFirstMappedPort);
registry.add("spring.redis.host", redis::getContainerIpAddress); registry.add("spring.redis.host", redis::getContainerIpAddress);
registry.add("spring.redis.port", redis::getFirstMappedPort);
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment