Add "closeable" unit tests to JedisSentinelPool, ShardedJedisPoolTest
This commit is contained in:
@@ -35,6 +35,22 @@ public class JedisSentinelPoolTest extends JedisTestBase {
|
|||||||
sentinelJedis1 = new Jedis(sentinel1.getHost(), sentinel1.getPort());
|
sentinelJedis1 = new Jedis(sentinel1.getHost(), sentinel1.getPort());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkCloseableConnections() throws Exception {
|
||||||
|
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
|
||||||
|
|
||||||
|
Closer closer = new Closer();
|
||||||
|
JedisSentinelPool pool = closer.register(new JedisSentinelPool(
|
||||||
|
MASTER_NAME, sentinels, config, 1000, "foobared", 2));
|
||||||
|
Jedis jedis = pool.getResource();
|
||||||
|
jedis.auth("foobared");
|
||||||
|
jedis.set("foo", "bar");
|
||||||
|
assertEquals("bar", jedis.get("foo"));
|
||||||
|
pool.returnResource(jedis);
|
||||||
|
closer.close();
|
||||||
|
assertTrue(pool.isClosed());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void ensureSafeTwiceFailover() throws InterruptedException {
|
public void ensureSafeTwiceFailover() throws InterruptedException {
|
||||||
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels,
|
JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels,
|
||||||
|
|||||||
@@ -54,6 +54,19 @@ public class ShardedJedisPoolTest extends Assert {
|
|||||||
pool.destroy();
|
pool.destroy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void checkCloseableConnections() throws Exception {
|
||||||
|
Closer closer = new Closer();
|
||||||
|
ShardedJedisPool pool = closer.register(new ShardedJedisPool(
|
||||||
|
new GenericObjectPoolConfig(), shards));
|
||||||
|
ShardedJedis jedis = pool.getResource();
|
||||||
|
jedis.set("foo", "bar");
|
||||||
|
assertEquals("bar", jedis.get("foo"));
|
||||||
|
pool.returnResource(jedis);
|
||||||
|
closer.close();
|
||||||
|
assertTrue(pool.isClosed());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void checkConnectionWithDefaultPort() {
|
public void checkConnectionWithDefaultPort() {
|
||||||
ShardedJedisPool pool = new ShardedJedisPool(
|
ShardedJedisPool pool = new ShardedJedisPool(
|
||||||
|
|||||||
Reference in New Issue
Block a user