DATAREDIS-552 - Polishing.
Apply client name to Sentinel and unpooled connections if set. Add ticket references to JavaDoc. Add tests. Fix existing JavaDoc letter casing and punctuation. Rearrange isClusterAware/isRedisSentinelAware methods. Original pull request: #219.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014 the original author or authors.
|
||||
* Copyright 2014-2016 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.
|
||||
@@ -27,6 +27,7 @@ import org.springframework.data.redis.test.util.RedisSentinelRule;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Fu Jian
|
||||
*/
|
||||
public class JedisConnectionFactoryTests {
|
||||
|
||||
@@ -55,7 +56,10 @@ public class JedisConnectionFactoryTests {
|
||||
public void shouldSendCommandCorrectlyViaConnectionFactoryUsingSentinel() {
|
||||
assertThat(factory.getConnection().ping(), equalTo("PONG"));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-552
|
||||
*/
|
||||
@Test
|
||||
public void getClientNameShouldEqualWithFactorySetting() {
|
||||
assertThat(factory.getConnection().getClientName(), equalTo("clientName"));
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2015 the original author or authors.
|
||||
* Copyright 2011-2016 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.
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.redis.connection.jedis;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
@@ -62,6 +61,7 @@ import redis.clients.jedis.JedisPoolConfig;
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
* @author David Liu
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(RelaxedJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@@ -402,6 +402,14 @@ public class JedisConnectionIntegrationTests extends AbstractConnectionIntegrati
|
||||
assertThat(connection.getSentinelConnection(), notNullValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-552
|
||||
*/
|
||||
@Test
|
||||
public void shouldSetClientName() {
|
||||
assertThat(connection.getClientName(), is(equalTo("jedis-client")));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-106
|
||||
*/
|
||||
|
||||
@@ -18,6 +18,8 @@ package org.springframework.data.redis.connection.jedis;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
@@ -36,10 +38,12 @@ import org.springframework.data.redis.connection.ReturnType;
|
||||
import org.springframework.data.redis.test.util.MinimumRedisVersionRule;
|
||||
import org.springframework.data.redis.test.util.RedisSentinelRule;
|
||||
import org.springframework.test.annotation.IfProfileValue;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Thomas Darimont
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class JedisSentinelIntegrationTests extends AbstractConnectionIntegrationTests {
|
||||
|
||||
@@ -59,6 +63,7 @@ public class JedisSentinelIntegrationTests extends AbstractConnectionIntegration
|
||||
@Before
|
||||
public void setUp() {
|
||||
JedisConnectionFactory jedisConnectionFactory = new JedisConnectionFactory(SENTINEL_CONFIG);
|
||||
jedisConnectionFactory.setClientName("jedis-client");
|
||||
jedisConnectionFactory.afterPropertiesSet();
|
||||
connectionFactory = jedisConnectionFactory;
|
||||
super.setUp();
|
||||
@@ -149,4 +154,16 @@ public class JedisSentinelIntegrationTests extends AbstractConnectionIntegration
|
||||
assertThat(slaves, hasItems(SLAVE_0, SLAVE_1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-552
|
||||
*/
|
||||
@Test
|
||||
public void shouldSetClientName() {
|
||||
|
||||
RedisSentinelConnection sentinelConnection = connectionFactory.getSentinelConnection();
|
||||
Jedis jedis = (Jedis) ReflectionTestUtils.getField(sentinelConnection, "jedis");
|
||||
|
||||
assertThat(jedis.clientGetname(), is(equalTo("jedis-client")));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user