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 gh-11884
Closes gh-11855
pull/11888/head
Andy Wilkinson 7 years ago
parent 9a87424809
commit 00489c74ea

@ -19,6 +19,8 @@ package org.springframework.boot.autoconfigure.data.redis;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfigurations; import org.springframework.boot.autoconfigure.AutoConfigurations;
import org.springframework.boot.test.context.runner.ApplicationContextRunner; import org.springframework.boot.test.context.runner.ApplicationContextRunner;
import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions; import org.springframework.boot.testsupport.runner.classpath.ClassPathExclusions;
@ -160,8 +162,12 @@ public class RedisAutoConfigurationJedisTests {
this.runner this.runner
.withPropertyValues("spring.redis.sentinel.master:mymaster", .withPropertyValues("spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380") "spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
.run((context) -> assertThat(context.getBean(JedisConnectionFactory.class) .withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
.isRedisSentinelAware()).isTrue()); .run((context) -> {
assertThat(context).hasFailed();
assertThat(JedisConnectionFactoryCaptor.connectionFactory
.isRedisSentinelAware()).isTrue();
});
} }
@Test @Test
@ -170,9 +176,15 @@ public class RedisAutoConfigurationJedisTests {
.withPropertyValues("spring.redis.password=password", .withPropertyValues("spring.redis.password=password",
"spring.redis.sentinel.master:mymaster", "spring.redis.sentinel.master:mymaster",
"spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380") "spring.redis.sentinel.nodes:127.0.0.1:26379,127.0.0.1:26380")
.run((context) -> assertThat( .withUserConfiguration(JedisConnectionFactoryCaptorConfiguration.class)
context.getBean(JedisConnectionFactory.class).getPassword()) .run((context) -> {
.isEqualTo("password")); assertThat(context).hasFailed();
assertThat(JedisConnectionFactoryCaptor.connectionFactory
.isRedisSentinelAware()).isTrue();
assertThat(
JedisConnectionFactoryCaptor.connectionFactory.getPassword())
.isEqualTo("password");
});
} }
@Test @Test
@ -194,4 +206,29 @@ public class RedisAutoConfigurationJedisTests {
} }
@Configuration
static class JedisConnectionFactoryCaptorConfiguration {
@Bean
JedisConnectionFactoryCaptor jedisConnectionFactoryCaptor() {
return new JedisConnectionFactoryCaptor();
}
}
static class JedisConnectionFactoryCaptor implements BeanPostProcessor {
static JedisConnectionFactory connectionFactory;
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName)
throws BeansException {
if (bean instanceof JedisConnectionFactory) {
connectionFactory = (JedisConnectionFactory) bean;
}
return bean;
}
}
} }

@ -144,7 +144,7 @@
<spring-amqp.version>2.0.2.RELEASE</spring-amqp.version> <spring-amqp.version>2.0.2.RELEASE</spring-amqp.version>
<spring-batch.version>4.0.0.RELEASE</spring-batch.version> <spring-batch.version>4.0.0.RELEASE</spring-batch.version>
<spring-cloud-connectors.version>2.0.1.RELEASE</spring-cloud-connectors.version> <spring-cloud-connectors.version>2.0.1.RELEASE</spring-cloud-connectors.version>
<spring-data-releasetrain.version>Kay-SR3</spring-data-releasetrain.version> <spring-data-releasetrain.version>Kay-BUILD-SNAPSHOT</spring-data-releasetrain.version>
<spring-hateoas.version>0.24.0.RELEASE</spring-hateoas.version> <spring-hateoas.version>0.24.0.RELEASE</spring-hateoas.version>
<spring-integration.version>5.0.1.RELEASE</spring-integration.version> <spring-integration.version>5.0.1.RELEASE</spring-integration.version>
<spring-kafka.version>2.1.2.RELEASE</spring-kafka.version> <spring-kafka.version>2.1.2.RELEASE</spring-kafka.version>

Loading…
Cancel
Save