From 77981ac2ae92f485c6ef41b468eedae24d823b3c Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Mon, 25 May 2020 14:13:26 +0200 Subject: [PATCH] Polish "Use the container IP address for tests using TestContainer" See gh-21480 --- .../data/redis/RedisRepositoriesAutoConfigurationTests.java | 5 +++-- .../session/SessionAutoConfigurationRedisTests.java | 2 +- .../data/redis/DataRedisTestIntegrationTests.java | 2 +- .../data/redis/DataRedisTestPropertiesIntegrationTests.java | 1 + .../DataRedisTestWithIncludeFilterIntegrationTests.java | 2 +- 5 files changed, 7 insertions(+), 5 deletions(-) diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java index 79cebf190d..30e65e5e29 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisRepositoriesAutoConfigurationTests.java @@ -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 diff --git a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java index a1d0437c24..a7b3025c6c 100644 --- a/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java +++ b/spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/session/SessionAutoConfigurationRedisTests.java @@ -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. diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java index abd8c64753..bbd055b911 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestIntegrationTests.java @@ -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 diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java index c6d191dd3f..dac22dd178 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestPropertiesIntegrationTests.java @@ -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); } diff --git a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java index 1bc9e172ae..0eebd13bf7 100644 --- a/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java +++ b/spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/data/redis/DataRedisTestWithIncludeFilterIntegrationTests.java @@ -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