Remove passing both connection info and pool to LettuceConnFactory
This commit is contained in:
@@ -32,16 +32,16 @@ import com.lambdaworks.redis.RedisClient;
|
||||
import com.lambdaworks.redis.RedisException;
|
||||
|
||||
/**
|
||||
* Unit test of {@link LettucePool}
|
||||
*
|
||||
* Unit test of {@link DefaultLettucePool}
|
||||
*
|
||||
* @author Jennifer Hickey
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class LettucePoolTests {
|
||||
public class DefaultLettucePoolTests {
|
||||
|
||||
private RedisClient client;
|
||||
|
||||
private LettucePool pool;
|
||||
private DefaultLettucePool pool;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
@@ -57,7 +57,7 @@ public class LettucePoolTests {
|
||||
|
||||
@Test
|
||||
public void testGetResource() {
|
||||
this.pool = new LettucePool(client);
|
||||
this.pool = new DefaultLettucePool(client);
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
client.ping();
|
||||
@@ -68,7 +68,7 @@ public class LettucePoolTests {
|
||||
Config poolConfig = new Config();
|
||||
poolConfig.maxActive = 1;
|
||||
poolConfig.maxWait = 1;
|
||||
this.pool = new LettucePool(client, poolConfig, 0);
|
||||
this.pool = new DefaultLettucePool(client, poolConfig, 0);
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
try {
|
||||
@@ -82,14 +82,14 @@ public class LettucePoolTests {
|
||||
public void testGetResourceValidate() {
|
||||
PoolConfig poolConfig = new PoolConfig();
|
||||
poolConfig.setTestOnBorrow(true);
|
||||
this.pool = new LettucePool(client, poolConfig, 0);
|
||||
this.pool = new DefaultLettucePool(client, poolConfig, 0);
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
}
|
||||
|
||||
@Test(expected = PoolException.class)
|
||||
public void testGetResourceCreationUnsuccessful() {
|
||||
this.pool = new LettucePool(new RedisClient(SettingsUtils.getHost(), 3333));
|
||||
this.pool = new DefaultLettucePool(new RedisClient(SettingsUtils.getHost(), 3333));
|
||||
pool.getResource();
|
||||
}
|
||||
|
||||
@@ -98,7 +98,7 @@ public class LettucePoolTests {
|
||||
Config poolConfig = new Config();
|
||||
poolConfig.maxActive = 1;
|
||||
poolConfig.maxWait = 1;
|
||||
this.pool = new LettucePool(client);
|
||||
this.pool = new DefaultLettucePool(client);
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
pool.returnResource(client);
|
||||
@@ -110,7 +110,7 @@ public class LettucePoolTests {
|
||||
Config poolConfig = new Config();
|
||||
poolConfig.maxActive = 1;
|
||||
poolConfig.maxWait = 1;
|
||||
this.pool = new LettucePool(client, poolConfig, 0);
|
||||
this.pool = new DefaultLettucePool(client, poolConfig, 0);
|
||||
RedisAsyncConnection<byte[], byte[]> client = pool.getResource();
|
||||
assertNotNull(client);
|
||||
pool.returnBrokenResource(client);
|
||||
@@ -125,19 +125,19 @@ public class LettucePoolTests {
|
||||
|
||||
@Test
|
||||
public void testCreateWithHostAndPort() {
|
||||
this.pool = new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort());
|
||||
assertNotNull(pool.getResource());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateWithDbIndex() {
|
||||
this.pool = new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 1, 65000);
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 1, 65000);
|
||||
assertNotNull(pool.getResource());
|
||||
}
|
||||
|
||||
@Test(expected = PoolException.class)
|
||||
public void testCreateWithDbIndexInvalid() {
|
||||
this.pool = new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 17, 65000);
|
||||
this.pool = new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(), 17, 65000);
|
||||
pool.getResource();
|
||||
}
|
||||
}
|
||||
@@ -221,8 +221,7 @@ public class LettuceConnectionFactoryTests {
|
||||
Config poolConfig = new Config();
|
||||
poolConfig.maxActive = 1;
|
||||
poolConfig.maxWait = 1;
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort(), new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(),
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort(),
|
||||
poolConfig));
|
||||
factory2.afterPropertiesSet();
|
||||
factory2.createLettuceConnector(false);
|
||||
@@ -239,8 +238,7 @@ public class LettuceConnectionFactoryTests {
|
||||
@Test
|
||||
public void testLotsOfConnections() throws InterruptedException {
|
||||
// Running a netstat here should show only the 8 conns from the pool (plus 2 from setUp and 1 from factory2 afterPropertiesSet for shared conn)
|
||||
final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort(), new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()));
|
||||
final LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()));
|
||||
factory2.afterPropertiesSet();
|
||||
for(int i=1;i< 1000;i++) {
|
||||
Thread th = new Thread(new Runnable() {
|
||||
|
||||
@@ -127,8 +127,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
|
||||
@Test
|
||||
public void testClosePooledConnectionWithShared() {
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(),
|
||||
new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()));
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort()));
|
||||
factory2.afterPropertiesSet();
|
||||
RedisConnection connection = factory2.getConnection();
|
||||
// Use the connection to make sure the channel is initialized, else nothing happens on close
|
||||
@@ -144,8 +144,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
|
||||
@Test
|
||||
public void testClosePooledConnectionNotShared() {
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(),
|
||||
new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()));
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort()));
|
||||
factory2.setShareNativeConnection(false);
|
||||
factory2.afterPropertiesSet();
|
||||
RedisConnection connection = factory2.getConnection();
|
||||
@@ -178,8 +178,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Test
|
||||
public void testCloseReturnBrokenResourceToPool() {
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(),
|
||||
new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()));
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort()));
|
||||
factory2.setShareNativeConnection(false);
|
||||
factory2.afterPropertiesSet();
|
||||
RedisConnection connection = factory2.getConnection();
|
||||
@@ -202,8 +202,8 @@ public class LettuceConnectionIntegrationTests extends AbstractConnectionIntegra
|
||||
|
||||
@Test
|
||||
public void testSelectNotShared() {
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(SettingsUtils.getHost(), SettingsUtils.getPort(),
|
||||
new LettucePool(SettingsUtils.getHost(), SettingsUtils.getPort()));
|
||||
LettuceConnectionFactory factory2 = new LettuceConnectionFactory(new DefaultLettucePool(SettingsUtils.getHost(),
|
||||
SettingsUtils.getPort()));
|
||||
factory2.setShareNativeConnection(false);
|
||||
factory2.afterPropertiesSet();
|
||||
RedisConnection connection = factory2.getConnection();
|
||||
|
||||
Reference in New Issue
Block a user