Merge branch 'pool-closeable-support' of https://github.com/HeartSaVioR/jedis into HeartSaVioR-pool-closeable-support

This commit is contained in:
Jungtaek Lim
2014-09-11 11:00:39 +09:00
5 changed files with 106 additions and 1 deletions

View File

@@ -40,6 +40,21 @@ public class JedisSentinelPoolTest extends JedisTestBase {
sentinelJedis1 = new Jedis(sentinel1.getHost(), sentinel1.getPort());
sentinelJedis2 = new Jedis(sentinel2.getHost(), sentinel2.getPort());
}
@Test
public void checkCloseableConnections() throws Exception {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
JedisSentinelPool pool = 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);
pool.close();
assertTrue(pool.isClosed());
}
@Test
public void ensureSafeTwiceFailover() throws InterruptedException {