Skip to content

Commit 00489c7

Browse files
committed
Start building against Spring Data Kay SR4 snapshots
The fix in Spring Data Redis for sentinel configuration means that two Jedis sentinel tests now attempt to connect to a Sentinel. As a result the tests fail. Running a Redis Sentinel in a Docker container appears to be non-trivial. As an alternative, this commit updates the tests to capture the JedisConnectionFactory prior to its initialization (which is the failure trigger) and then assert that its configuration is as expected. See spring-projectsgh-11884 Closes spring-projectsgh-11855
1 parent 9a87424 commit 00489c7

File tree

2 files changed

+43
-6
lines changed

2 files changed

+43
-6
lines changed

spring-boot-project/spring-boot-autoconfigure/src/test/java/org/springframework/boot/autoconfigure/data/redis/RedisAutoConfigurationJedisTests.java

+42-5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.junit.Test;
2020
import org.junit.runner.RunWith;
2121

22+
import org.springframework.beans.BeansException;
23+
import org.springframework.beans.factory.config.BeanPostProcessor;
2224
import org.springframework.boot.autoconfigure.AutoConfigurations;
2325
import org.springframework.boot.test.context.runner.ApplicationContextRunner;
2426
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
@@ -160,8 +162,12 @@ public void testRedisConfigurationWithSentinel() {
160162
this.runner
161163
.withPropertyValues("spring.redis.sentinel.master:mymaster",
162164
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
163-
.run((context) -> assertThat(context.getBean(JedisConnectionFactory.class)
164-
.isRedisSentinelAware()).isTrue());
165+
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
166+
.run((context) -> {
167+
assertThat(context).hasFailed();
168+
assertThat(JedisConnectionFactoryCaptor.connectionFactory
169+
.isRedisSentinelAware()).isTrue();
170+
});
165171
}
166172

167173
@Test
@@ -170,9 +176,15 @@ public void testRedisConfigurationWithSentinelAndPassword() {
170176
.withPropertyValues("spring.redis.password=password",
171177
"spring.redis.sentinel.master:mymaster",
172178
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
173-
.run((context) -> assertThat(
174-
context.getBean(JedisConnectionFactory.class).getPassword())
175-
.isEqualTo("password"));
179+
.withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
180+
.run((context) -> {
181+
assertThat(context).hasFailed();
182+
assertThat(JedisConnectionFactoryCaptor.connectionFactory
183+
.isRedisSentinelAware()).isTrue();
184+
assertThat(
185+
JedisConnectionFactoryCaptor.connectionFactory.getPassword())
186+
.isEqualTo("password");
187+
});
176188
}
177189

178190
@Test
@@ -194,4 +206,29 @@ JedisClientConfigurationBuilderCustomizer customizer() {
194206

195207
}
196208

209+
@Configuration
210+
static class JedisConnectionFactoryCaptorConfiguration {
211+
212+
@Bean
213+
JedisConnectionFactoryCaptor jedisConnectionFactoryCaptor() {
214+
return new JedisConnectionFactoryCaptor();
215+
}
216+
217+
}
218+
219+
static class JedisConnectionFactoryCaptor implements BeanPostProcessor {
220+
221+
static JedisConnectionFactory connectionFactory;
222+
223+
@Override
224+
public Object postProcessBeforeInitialization(Object bean, String beanName)
225+
throws BeansException {
226+
if (bean instanceof JedisConnectionFactory) {
227+
connectionFactory = (JedisConnectionFactory) bean;
228+
}
229+
return bean;
230+
}
231+
232+
}
233+
197234
}

spring-boot-project/spring-boot-dependencies/pom.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@
144144
<spring-amqp.version>2.0.2.RELEASE</spring-amqp.version>
145145
<spring-batch.version>4.0.0.RELEASE</spring-batch.version>
146146
<spring-cloud-connectors.version>2.0.1.RELEASE</spring-cloud-connectors.version>
147-
<spring-data-releasetrain.version>Kay-SR3</spring-data-releasetrain.version>
147+
<spring-data-releasetrain.version>Kay-BUILD-SNAPSHOT</spring-data-releasetrain.version>
148148
<spring-hateoas.version>0.24.0.RELEASE</spring-hateoas.version>
149149
<spring-integration.version>5.0.1.RELEASE</spring-integration.version>
150150
<spring-kafka.version>2.1.2.RELEASE</spring-kafka.version>

0 commit comments

Comments
 (0)