DATAREDIS-462 - Support lettuce ClientResources.
Add ClientResources to LettuceConnectionFactory. Add TestClientResources for managed resources during tests and reuse ClientResources as much as possible in tests. Original Pull Request: #169
This commit is contained in:
committed by
Christoph Strobl
parent
0fa1319b8f
commit
b58c18f85b
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2014 the original author or authors.
|
||||
* Copyright 2013-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.
|
||||
@@ -57,6 +57,7 @@ public class DefaultLettucePoolTests {
|
||||
@Test
|
||||
public void testGetResource() {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
@@ -70,6 +71,7 @@ public class DefaultLettucePoolTests {
|
||||
poolConfig.setMaxTotal(1);
|
||||
poolConfig.setMaxWaitMillis(1);
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig);
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
@@ -86,6 +88,7 @@ public class DefaultLettucePoolTests {
|
||||
PoolConfig poolConfig = new PoolConfig();
|
||||
poolConfig.setTestOnBorrow(true);
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig);
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
@@ -95,6 +98,7 @@ public class DefaultLettucePoolTests {
|
||||
@Test(expected = PoolException.class)
|
||||
public void testGetResourceCreationUnsuccessful() throws Exception {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), 3333);
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
pool.getResource();
|
||||
}
|
||||
@@ -105,6 +109,7 @@ public class DefaultLettucePoolTests {
|
||||
poolConfig.setMaxTotal(1);
|
||||
poolConfig.setMaxWaitMillis(1);
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig);
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
@@ -119,6 +124,7 @@ public class DefaultLettucePoolTests {
|
||||
poolConfig.setMaxTotal(1);
|
||||
poolConfig.setMaxWaitMillis(1);
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), poolConfig);
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
@@ -136,6 +142,18 @@ public class DefaultLettucePoolTests {
|
||||
|
||||
@Test
|
||||
public void testCreateWithDbIndex() {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.setDatabase(1);
|
||||
pool.afterPropertiesSet();
|
||||
assertNotNull(pool.getResource());
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-462
|
||||
*/
|
||||
@Test
|
||||
public void poolWorksWithoutClientResources() {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
pool.setDatabase(1);
|
||||
pool.afterPropertiesSet();
|
||||
@@ -145,6 +163,7 @@ public class DefaultLettucePoolTests {
|
||||
@Test(expected = PoolException.class)
|
||||
public void testCreateWithDbIndexInvalid() {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.setDatabase(17);
|
||||
pool.afterPropertiesSet();
|
||||
pool.getResource();
|
||||
@@ -153,6 +172,7 @@ public class DefaultLettucePoolTests {
|
||||
@Test(expected = PoolException.class)
|
||||
public void testCreateWithPasswordNoPassword() {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.setPassword("notthepassword");
|
||||
pool.afterPropertiesSet();
|
||||
pool.getResource();
|
||||
@@ -162,6 +182,7 @@ public class DefaultLettucePoolTests {
|
||||
@Test
|
||||
public void testCreatePassword() {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.setPassword("foo");
|
||||
pool.afterPropertiesSet();
|
||||
RedisAsyncConnection<byte[], byte[]> conn = pool.getResource();
|
||||
@@ -173,6 +194,7 @@ public class DefaultLettucePoolTests {
|
||||
@Test(expected = PoolException.class)
|
||||
public void testCreateInvalidPassword() {
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
this.pool.setClientResources(TestClientResources.get());
|
||||
pool.setPassword("bad");
|
||||
pool.afterPropertiesSet();
|
||||
pool.getResource();
|
||||
|
||||
@@ -85,8 +85,8 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
@Before
|
||||
public void setUp() {
|
||||
|
||||
client = new RedisClusterClient(Builder.redis(CLUSTER_HOST, MASTER_NODE_1_PORT)
|
||||
.withTimeout(500, TimeUnit.MILLISECONDS).build());
|
||||
client = RedisClusterClient.create(TestClientResources.get(),
|
||||
Builder.redis(CLUSTER_HOST, MASTER_NODE_1_PORT).withTimeout(100, TimeUnit.MILLISECONDS).build());
|
||||
nativeConnection = client.connectCluster();
|
||||
clusterConnection = new LettuceClusterConnection(client);
|
||||
}
|
||||
@@ -2079,29 +2079,23 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
|
||||
assertThat(values,
|
||||
hasItems(LettuceConverters.toBytes("a"), LettuceConverters.toBytes("b"), LettuceConverters.toBytes("c")));
|
||||
assertThat(
|
||||
values,
|
||||
not(hasItems(LettuceConverters.toBytes("d"), LettuceConverters.toBytes("e"), LettuceConverters.toBytes("f"),
|
||||
LettuceConverters.toBytes("g"))));
|
||||
assertThat(values, not(hasItems(LettuceConverters.toBytes("d"), LettuceConverters.toBytes("e"),
|
||||
LettuceConverters.toBytes("f"), LettuceConverters.toBytes("g"))));
|
||||
|
||||
values = clusterConnection.zRangeByLex(KEY_1_BYTES, Range.range().lt("c"));
|
||||
assertThat(values, hasItems(LettuceConverters.toBytes("a"), LettuceConverters.toBytes("b")));
|
||||
assertThat(values, not(hasItem(LettuceConverters.toBytes("c"))));
|
||||
|
||||
values = clusterConnection.zRangeByLex(KEY_1_BYTES, Range.range().gte("aaa").lt("g"));
|
||||
assertThat(
|
||||
values,
|
||||
hasItems(LettuceConverters.toBytes("b"), LettuceConverters.toBytes("c"), LettuceConverters.toBytes("d"),
|
||||
LettuceConverters.toBytes("e"), LettuceConverters.toBytes("f")));
|
||||
assertThat(values, hasItems(LettuceConverters.toBytes("b"), LettuceConverters.toBytes("c"),
|
||||
LettuceConverters.toBytes("d"), LettuceConverters.toBytes("e"), LettuceConverters.toBytes("f")));
|
||||
assertThat(values, not(hasItems(LettuceConverters.toBytes("a"), LettuceConverters.toBytes("g"))));
|
||||
|
||||
values = clusterConnection.zRangeByLex(KEY_1_BYTES, Range.range().gte("e"));
|
||||
assertThat(values,
|
||||
hasItems(LettuceConverters.toBytes("e"), LettuceConverters.toBytes("f"), LettuceConverters.toBytes("g")));
|
||||
assertThat(
|
||||
values,
|
||||
not(hasItems(LettuceConverters.toBytes("a"), LettuceConverters.toBytes("b"), LettuceConverters.toBytes("c"),
|
||||
LettuceConverters.toBytes("d"))));
|
||||
assertThat(values, not(hasItems(LettuceConverters.toBytes("a"), LettuceConverters.toBytes("b"),
|
||||
LettuceConverters.toBytes("c"), LettuceConverters.toBytes("d"))));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -2279,8 +2273,8 @@ public class LettuceClusterConnectionTests implements ClusterConnectionTests {
|
||||
@Test
|
||||
public void clusterGetSlavesShouldReturnSlaveCorrectly() {
|
||||
|
||||
Set<RedisClusterNode> slaves = clusterConnection.clusterGetSlaves(new RedisClusterNode(CLUSTER_HOST,
|
||||
MASTER_NODE_1_PORT));
|
||||
Set<RedisClusterNode> slaves = clusterConnection
|
||||
.clusterGetSlaves(new RedisClusterNode(CLUSTER_HOST, MASTER_NODE_1_PORT));
|
||||
|
||||
assertThat(slaves.size(), is(1));
|
||||
assertThat(slaves, hasItem(new RedisClusterNode(CLUSTER_HOST, SLAVEOF_NODE_1_PORT)));
|
||||
|
||||
@@ -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.
|
||||
@@ -15,6 +15,8 @@
|
||||
*/
|
||||
package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.hamcrest.core.IsNull.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -40,6 +42,7 @@ import com.lambdaworks.redis.RedisException;
|
||||
* @author Jennifer Hickey
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class LettuceConnectionFactoryTests {
|
||||
|
||||
@@ -51,6 +54,7 @@ public class LettuceConnectionFactoryTests {
|
||||
public void setUp() {
|
||||
|
||||
factory = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
factory.setClientResources(TestClientResources.get());
|
||||
factory.afterPropertiesSet();
|
||||
factory.setShutdownTimeout(0);
|
||||
connection = new DefaultStringRedisConnection(factory.getConnection());
|
||||
@@ -122,6 +126,7 @@ public class LettuceConnectionFactoryTests {
|
||||
public void testSelectDb() {
|
||||
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
factory2.setClientResources(TestClientResources.get());
|
||||
factory2.setShutdownTimeout(0);
|
||||
factory2.setDatabase(1);
|
||||
factory2.afterPropertiesSet();
|
||||
@@ -224,6 +229,7 @@ public class LettuceConnectionFactoryTests {
|
||||
@Test
|
||||
public void testCreateFactoryWithPool() {
|
||||
DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
|
||||
factory2.setShutdownTimeout(0);
|
||||
@@ -279,6 +285,7 @@ public class LettuceConnectionFactoryTests {
|
||||
public void dbIndexShouldBePropagatedCorrectly() {
|
||||
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory();
|
||||
factory.setClientResources(TestClientResources.get());
|
||||
factory.setDatabase(2);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
@@ -297,4 +304,25 @@ public class LettuceConnectionFactoryTests {
|
||||
connectionToDbIndex2.close();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-462
|
||||
*/
|
||||
@Test
|
||||
public void factoryWorksWithoutClientResources() {
|
||||
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory();
|
||||
factory.setShutdownTimeout(0);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
ConnectionFactoryTracker.add(factory);
|
||||
|
||||
StringRedisConnection connection = new DefaultStringRedisConnection(factory.getConnection());
|
||||
|
||||
try {
|
||||
assertThat(connection.ping(), is(equalTo("PONG")));
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,8 +23,10 @@ import static org.springframework.test.util.ReflectionTestUtils.*;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.ConnectionFactoryTracker;
|
||||
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
||||
|
||||
import com.lambdaworks.redis.AbstractRedisClient;
|
||||
@@ -33,6 +35,7 @@ import com.lambdaworks.redis.cluster.RedisClusterClient;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class LettuceConnectionFactoryUnitTests {
|
||||
|
||||
@@ -43,6 +46,11 @@ public class LettuceConnectionFactoryUnitTests {
|
||||
clusterConfig = new RedisClusterConfiguration().clusterNode("127.0.0.1", 6379).clusterNode("127.0.0.1", 6380);
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
ConnectionFactoryTracker.cleanUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-315
|
||||
*/
|
||||
@@ -50,7 +58,9 @@ public class LettuceConnectionFactoryUnitTests {
|
||||
public void shouldInitClientCorrectlyWhenClusterConfigPresent() {
|
||||
|
||||
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(clusterConfig);
|
||||
connectionFactory.setClientResources(TestClientResources.get());
|
||||
connectionFactory.afterPropertiesSet();
|
||||
ConnectionFactoryTracker.add(connectionFactory);
|
||||
|
||||
assertThat(getField(connectionFactory, "client"), instanceOf(RedisClusterClient.class));
|
||||
}
|
||||
@@ -63,8 +73,10 @@ public class LettuceConnectionFactoryUnitTests {
|
||||
public void timeoutShouldBeSetCorrectlyOnClusterClient() {
|
||||
|
||||
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(clusterConfig);
|
||||
connectionFactory.setClientResources(TestClientResources.get());
|
||||
connectionFactory.setTimeout(1000);
|
||||
connectionFactory.afterPropertiesSet();
|
||||
ConnectionFactoryTracker.add(connectionFactory);
|
||||
|
||||
AbstractRedisClient client = (AbstractRedisClient) getField(connectionFactory, "client");
|
||||
assertThat(client, instanceOf(RedisClusterClient.class));
|
||||
@@ -85,8 +97,10 @@ public class LettuceConnectionFactoryUnitTests {
|
||||
public void passwordShouldBeSetCorrectlyOnClusterClient() {
|
||||
|
||||
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(clusterConfig);
|
||||
connectionFactory.setClientResources(TestClientResources.get());
|
||||
connectionFactory.setPassword("o_O");
|
||||
connectionFactory.afterPropertiesSet();
|
||||
ConnectionFactoryTracker.add(connectionFactory);
|
||||
|
||||
AbstractRedisClient client = (AbstractRedisClient) getField(connectionFactory, "client");
|
||||
assertThat(client, instanceOf(RedisClusterClient.class));
|
||||
@@ -97,4 +111,20 @@ public class LettuceConnectionFactoryUnitTests {
|
||||
assertThat(uri.getPassword(), is(equalTo(connectionFactory.getPassword().toCharArray())));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-462
|
||||
*/
|
||||
@Test
|
||||
@SuppressWarnings("unchecked")
|
||||
public void clusterClientShouldInitializeWithoutClientResources() {
|
||||
|
||||
LettuceConnectionFactory connectionFactory = new LettuceConnectionFactory(clusterConfig);
|
||||
connectionFactory.setShutdownTimeout(0);
|
||||
connectionFactory.afterPropertiesSet();
|
||||
ConnectionFactoryTracker.add(connectionFactory);
|
||||
|
||||
AbstractRedisClient client = (AbstractRedisClient) getField(connectionFactory, "client");
|
||||
assertThat(client, instanceOf(RedisClusterClient.class));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2014 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.
|
||||
@@ -59,6 +59,7 @@ import com.lambdaworks.redis.RedisAsyncConnection;
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
* @author David Liu
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(RelaxedJUnit4ClassRunner.class)
|
||||
@ContextConfiguration
|
||||
@@ -138,6 +139,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
@Test
|
||||
public void testClosePooledConnectionWithShared() {
|
||||
DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
|
||||
factory2.setShutdownTimeout(0);
|
||||
@@ -159,6 +161,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
@Test
|
||||
public void testClosePooledConnectionNotShared() {
|
||||
DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
|
||||
factory2.setShareNativeConnection(false);
|
||||
@@ -178,6 +181,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
@Test
|
||||
public void testCloseNonPooledConnectionNotShared() {
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
factory2.setClientResources(TestClientResources.get());
|
||||
factory2.setShutdownTimeout(0);
|
||||
factory2.setShareNativeConnection(false);
|
||||
factory2.afterPropertiesSet();
|
||||
@@ -197,6 +201,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
@Test
|
||||
public void testCloseReturnBrokenResourceToPool() {
|
||||
DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
|
||||
factory2.setShutdownTimeout(0);
|
||||
@@ -218,6 +223,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
@Test
|
||||
public void testSelectNotShared() {
|
||||
DefaultLettucePool pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
pool.setClientResources(TestClientResources.get());
|
||||
pool.afterPropertiesSet();
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(pool);
|
||||
factory2.setShutdownTimeout(0);
|
||||
@@ -246,6 +252,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
// Use a different factory to get a non-shared native conn for blocking script
|
||||
final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort());
|
||||
factory2.setClientResources(TestClientResources.get());
|
||||
factory2.setShutdownTimeout(0);
|
||||
factory2.afterPropertiesSet();
|
||||
DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
|
||||
@@ -275,6 +282,7 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
verifyResults(Arrays.asList(new Object[] { true }));
|
||||
// Lettuce does not support select when using shared conn, use a new conn factory
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory();
|
||||
factory2.setClientResources(TestClientResources.get());
|
||||
factory2.setShutdownTimeout(0);
|
||||
factory2.setDatabase(1);
|
||||
factory2.afterPropertiesSet();
|
||||
|
||||
@@ -65,6 +65,7 @@ public class LettuceConnectionPipelineIntegrationTests extends AbstractConnectio
|
||||
// Use separate conn factory to avoid using the underlying shared native conn on blocking script
|
||||
final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort());
|
||||
factory2.setClientResources(TestClientResources.get());
|
||||
factory2.afterPropertiesSet();
|
||||
DefaultStringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
|
||||
try {
|
||||
@@ -94,6 +95,7 @@ public class LettuceConnectionPipelineIntegrationTests extends AbstractConnectio
|
||||
verifyResults(Arrays.asList(new Object[] { true }));
|
||||
// Lettuce does not support select when using shared conn, use a new conn factory
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory();
|
||||
factory2.setClientResources(TestClientResources.get());
|
||||
factory2.setDatabase(1);
|
||||
factory2.afterPropertiesSet();
|
||||
StringRedisConnection conn2 = new DefaultStringRedisConnection(factory2.getConnection());
|
||||
|
||||
@@ -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.
|
||||
@@ -46,6 +46,7 @@ public class LettuceConnectionTransactionIntegrationTests extends AbstractConnec
|
||||
verifyResults(Arrays.asList(new Object[] { true }));
|
||||
// Lettuce does not support select when using shared conn, use a new conn factory
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory();
|
||||
factory2.setClientResources(TestClientResources.get());
|
||||
factory2.setShutdownTimeout(0);
|
||||
factory2.setDatabase(1);
|
||||
factory2.afterPropertiesSet();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -16,6 +16,8 @@
|
||||
package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.core.Is.is;
|
||||
import static org.hamcrest.core.IsEqual.equalTo;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.util.Collection;
|
||||
@@ -25,10 +27,13 @@ import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Rule;
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.redis.ConnectionFactoryTracker;
|
||||
import org.springframework.data.redis.connection.AbstractConnectionIntegrationTests;
|
||||
import org.springframework.data.redis.connection.DefaultStringRedisConnection;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConfiguration;
|
||||
import org.springframework.data.redis.connection.RedisSentinelConnection;
|
||||
import org.springframework.data.redis.connection.RedisServer;
|
||||
import org.springframework.data.redis.connection.StringRedisConnection;
|
||||
import org.springframework.data.redis.test.util.RedisSentinelRule;
|
||||
|
||||
/**
|
||||
@@ -53,6 +58,7 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
public void setUp() {
|
||||
|
||||
LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(SENTINEL_CONFIG);
|
||||
lettuceConnectionFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnectionFactory.setShareNativeConnection(false);
|
||||
lettuceConnectionFactory.setShutdownTimeout(0);
|
||||
lettuceConnectionFactory.afterPropertiesSet();
|
||||
@@ -94,4 +100,25 @@ public class LettuceSentinelIntegrationTests extends AbstractConnectionIntegrati
|
||||
assertThat(slaves, hasItems(SLAVE_0, SLAVE_1));
|
||||
}
|
||||
|
||||
/**
|
||||
* @see DATAREDIS-462
|
||||
*/
|
||||
@Test
|
||||
public void factoryWorksWithoutClientResources() {
|
||||
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory(SENTINEL_CONFIG);
|
||||
factory.setShutdownTimeout(0);
|
||||
factory.afterPropertiesSet();
|
||||
|
||||
ConnectionFactoryTracker.add(factory);
|
||||
|
||||
StringRedisConnection connection = new DefaultStringRedisConnection(factory.getConnection());
|
||||
|
||||
try {
|
||||
assertThat(connection.ping(), is(equalTo("PONG")));
|
||||
} finally {
|
||||
connection.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.lambdaworks.redis.resource.ClientResources;
|
||||
import com.lambdaworks.redis.resource.DefaultClientResources;
|
||||
|
||||
/**
|
||||
* Client-Resources suitable for testing. Uses {@link TestEventLoopGroupProvider} to preserve the event loop groups
|
||||
* between tests. Every time a new {@link TestClientResources} instance is created, a
|
||||
* {@link Runtime#addShutdownHook(Thread) shutdown hook} is added to close the client resources.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class TestClientResources {
|
||||
|
||||
private ClientResources resources = create();
|
||||
private final static TestClientResources instance = new TestClientResources();
|
||||
|
||||
/**
|
||||
* Prevent instances by others.
|
||||
*/
|
||||
private TestClientResources() {}
|
||||
|
||||
private ClientResources create() {
|
||||
|
||||
final DefaultClientResources resources = new DefaultClientResources.Builder()
|
||||
.eventLoopGroupProvider(new TestEventLoopGroupProvider()).build();
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
resources.shutdown(0, 0, TimeUnit.MILLISECONDS).get(1, TimeUnit.SECONDS);
|
||||
} catch (Exception o_O) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return resources;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the client resources.
|
||||
*/
|
||||
public static ClientResources get() {
|
||||
return instance.resources;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
* Copyright 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.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.data.redis.connection.lettuce;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.lambdaworks.redis.resource.DefaultEventLoopGroupProvider;
|
||||
|
||||
import io.netty.util.concurrent.DefaultPromise;
|
||||
import io.netty.util.concurrent.EventExecutorGroup;
|
||||
import io.netty.util.concurrent.ImmediateEventExecutor;
|
||||
import io.netty.util.concurrent.Promise;
|
||||
|
||||
/**
|
||||
* A {@link com.lambdaworks.redis.resource.EventLoopGroupProvider} suitable for testing. Preserves the event loop groups
|
||||
* between tests. Every time a new {@link TestEventLoopGroupProvider} instance is created, a
|
||||
* {@link Runtime#addShutdownHook(Thread) shutdown hook} is added to close the resources.
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
class TestEventLoopGroupProvider extends DefaultEventLoopGroupProvider {
|
||||
|
||||
public static final int NUMBER_OF_THREADS = 10;
|
||||
|
||||
public TestEventLoopGroupProvider() {
|
||||
|
||||
super(NUMBER_OF_THREADS);
|
||||
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
TestEventLoopGroupProvider.this.shutdown(0, 0, TimeUnit.MILLISECONDS).get(1, TimeUnit.SECONDS);
|
||||
} catch (Exception o_O) {
|
||||
// ignored
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public Promise<Boolean> release(EventExecutorGroup eventLoopGroup, long quietPeriod, long timeout, TimeUnit unit) {
|
||||
|
||||
DefaultPromise<Boolean> result = new DefaultPromise<Boolean>(ImmediateEventExecutor.INSTANCE);
|
||||
result.setSuccess(true);
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -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.
|
||||
@@ -23,6 +23,7 @@ import org.springframework.test.context.ContextConfiguration;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@ContextConfiguration(classes = { LettuceContextConfiguration.class })
|
||||
public class TransactionalLettuceItegrationTests extends AbstractTransactionalTestBase {
|
||||
@@ -35,6 +36,7 @@ public class TransactionalLettuceItegrationTests extends AbstractTransactionalTe
|
||||
public LettuceConnectionFactory redisConnectionFactory() {
|
||||
|
||||
LettuceConnectionFactory factory = new LettuceConnectionFactory();
|
||||
factory.setClientResources(TestClientResources.get());
|
||||
factory.setHostName("localhost");
|
||||
factory.setPort(6379);
|
||||
return factory;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2014-2015 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.
|
||||
@@ -32,11 +32,13 @@ import org.springframework.data.redis.ConnectionFactoryTracker;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
|
||||
/**
|
||||
* @author Artem Bilian
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class MultithreadedRedisTemplateTests {
|
||||
@@ -61,6 +63,7 @@ public class MultithreadedRedisTemplateTests {
|
||||
jedis.afterPropertiesSet();
|
||||
|
||||
LettuceConnectionFactory lettuce = new LettuceConnectionFactory();
|
||||
lettuce.setClientResources(TestClientResources.get());
|
||||
lettuce.setPort(6379);
|
||||
lettuce.afterPropertiesSet();
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2015 the original author or authors.
|
||||
* Copyright 2015-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.
|
||||
@@ -33,6 +33,7 @@ import org.springframework.data.redis.StringObjectFactory;
|
||||
import org.springframework.data.redis.connection.RedisClusterConfiguration;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.serializer.GenericToStringSerializer;
|
||||
import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer;
|
||||
import org.springframework.data.redis.serializer.OxmSerializer;
|
||||
@@ -42,6 +43,7 @@ import org.springframework.oxm.xstream.XStreamMarshaller;
|
||||
|
||||
/**
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class RedisClusterTemplateTests<K, V> extends RedisTemplateTests<K, V> {
|
||||
|
||||
@@ -185,6 +187,7 @@ public class RedisClusterTemplateTests<K, V> extends RedisTemplateTests<K, V> {
|
||||
|
||||
LettuceConnectionFactory lettuceConnectionFactory = new LettuceConnectionFactory(new RedisClusterConfiguration(
|
||||
CLUSTER_NODES));
|
||||
lettuceConnectionFactory.setClientResources(TestClientResources.get());
|
||||
|
||||
lettuceConnectionFactory.afterPropertiesSet();
|
||||
|
||||
|
||||
@@ -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.
|
||||
@@ -20,6 +20,7 @@ import org.junit.Before;
|
||||
import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.core.script.AbstractDefaultScriptExecutorTests;
|
||||
import org.springframework.data.redis.core.script.DefaultScriptExecutor;
|
||||
|
||||
@@ -37,6 +38,7 @@ public class LettuceDefaultScriptExecutorTests extends AbstractDefaultScriptExec
|
||||
public void setup() {
|
||||
|
||||
connectionFactory = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
connectionFactory.setClientResources(TestClientResources.get());
|
||||
connectionFactory.setShutdownTimeout(0);
|
||||
connectionFactory.afterPropertiesSet();
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -109,6 +110,7 @@ public class PubSubResubscribeTests {
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setPort(port);
|
||||
lettuceConnFactory.setHostName(host);
|
||||
lettuceConnFactory.setDatabase(2);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 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.
|
||||
@@ -26,6 +26,7 @@ import org.springframework.data.redis.SettingsUtils;
|
||||
import org.springframework.data.redis.StringObjectFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -33,6 +34,7 @@ import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
/**
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class PubSubTestParams {
|
||||
|
||||
@@ -61,6 +63,7 @@ public class PubSubTestParams {
|
||||
|
||||
// add Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
lettuceConnFactory.setHostName(SettingsUtils.getHost());
|
||||
lettuceConnFactory.afterPropertiesSet();
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.data.redis.connection.RedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.listener.adapter.MessageListenerAdapter;
|
||||
|
||||
@@ -99,6 +100,7 @@ public class SubscriptionConnectionTests {
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setPort(port);
|
||||
lettuceConnFactory.setHostName(host);
|
||||
lettuceConnFactory.setDatabase(2);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 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.
|
||||
@@ -23,6 +23,7 @@ import org.springframework.data.redis.StringObjectFactory;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.data.redis.support.atomic.RedisAtomicInteger;
|
||||
@@ -35,6 +36,7 @@ import org.springframework.data.redis.support.collections.RedisList;
|
||||
/**
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class BoundKeyParams {
|
||||
|
||||
@@ -62,6 +64,7 @@ public class BoundKeyParams {
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
lettuceConnFactory.setHostName(SettingsUtils.getHost());
|
||||
lettuceConnFactory.afterPropertiesSet();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2013 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.
|
||||
@@ -23,11 +23,13 @@ import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisPool;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
|
||||
/**
|
||||
* @author Costin Leau
|
||||
* @author Jennifer Hickey
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public abstract class AtomicCountersParam {
|
||||
|
||||
@@ -46,6 +48,7 @@ public abstract class AtomicCountersParam {
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
lettuceConnFactory.setHostName(SettingsUtils.getHost());
|
||||
lettuceConnFactory.afterPropertiesSet();
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisPool;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -180,6 +181,7 @@ public abstract class CollectionTestParams {
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
lettuceConnFactory.setHostName(SettingsUtils.getHost());
|
||||
lettuceConnFactory.afterPropertiesSet();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2014 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.
|
||||
@@ -32,6 +32,7 @@ import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisPool;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -166,6 +167,7 @@ public class RedisMapTests extends AbstractRedisMapTests<Object, Object> {
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setHostName(SettingsUtils.getHost());
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
lettuceConnFactory.afterPropertiesSet();
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2011-2014 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.
|
||||
@@ -41,6 +41,7 @@ import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisConnectionFactory;
|
||||
import org.springframework.data.redis.connection.jredis.JredisPool;
|
||||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
|
||||
import org.springframework.data.redis.connection.lettuce.TestClientResources;
|
||||
import org.springframework.data.redis.connection.srp.SrpConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
@@ -53,6 +54,7 @@ import org.springframework.oxm.xstream.XStreamMarshaller;
|
||||
* @author Costin Leau
|
||||
* @author Thomas Darimont
|
||||
* @author Christoph Strobl
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
public class RedisPropertiesTests extends RedisMapTests {
|
||||
|
||||
@@ -308,6 +310,7 @@ public class RedisPropertiesTests extends RedisMapTests {
|
||||
|
||||
// Lettuce
|
||||
LettuceConnectionFactory lettuceConnFactory = new LettuceConnectionFactory();
|
||||
lettuceConnFactory.setClientResources(TestClientResources.get());
|
||||
lettuceConnFactory.setPort(SettingsUtils.getPort());
|
||||
lettuceConnFactory.setHostName(SettingsUtils.getHost());
|
||||
lettuceConnFactory.afterPropertiesSet();
|
||||
|
||||
Reference in New Issue
Block a user