DATAREDIS-765 - Enable pooling when configuring Jedis to use Redis Sentinel.
We now enable pool usage when configuring JedisConnectionFactory with RedisSentinelConfiguration to prevent accidental connections using the non-pooled standalone configuration. Jedis can operate with Sentinel only with pooling. We also reject calls to disable pooling when JedisConnectionFactory is configured to use Sentinel. Original Pull request: #307
This commit is contained in:
committed by
Christoph Strobl
parent
c5eea4affd
commit
404a66f437
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2017 the original author or authors.
|
||||
* Copyright 2014-2018 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.
|
||||
@@ -15,7 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection.jedis;
|
||||
|
||||
import static org.hamcrest.core.IsEqual.*;
|
||||
import static org.hamcrest.Matchers.*;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.After;
|
||||
@@ -26,8 +27,11 @@ import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.test.util.RedisSentinelRule;
|
||||
|
||||
/**
|
||||
* Sentinel integration tests for {@link JedisConnectionFactory}.
|
||||
*
|
||||
* @author Christoph Strobl
|
||||
* @author Fu Jian
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class JedisConnectionFactoryTests {
|
||||
|
||||
@@ -49,6 +53,11 @@ public class JedisConnectionFactoryTests {
|
||||
factory.destroy();
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-765
|
||||
public void shouldInitializeWithSentinelConfiguration() {
|
||||
assertThat(factory.getUsePool(), is(true));
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-324
|
||||
public void shouldSendCommandCorrectlyViaConnectionFactoryUsingSentinel() {
|
||||
assertThat(factory.getConnection().ping(), equalTo("PONG"));
|
||||
|
||||
@@ -62,6 +62,14 @@ public class JedisConnectionFactoryUnitTests {
|
||||
verify(connectionFactory, never()).createRedisSentinelPool(Matchers.any(RedisSentinelConfiguration.class));
|
||||
}
|
||||
|
||||
@Test(expected = IllegalStateException.class) // DATAREDIS-765
|
||||
public void shouldRejectPoolDisablingWhenSentinelConfigPresent() {
|
||||
|
||||
connectionFactory = new JedisConnectionFactory(new RedisSentinelConfiguration());
|
||||
|
||||
connectionFactory.setUsePool(false);
|
||||
}
|
||||
|
||||
@Test // DATAREDIS-315
|
||||
public void shouldInitConnectionCorrectlyWhenClusterConfigPresent() {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user