use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.
the class JedisPoolTest method selectDatabaseOnActivation.
@Test
public void selectDatabaseOnActivation() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared");
Jedis jedis0 = pool.getResource();
assertEquals(0, jedis0.getDB());
jedis0.select(1);
assertEquals(1, jedis0.getDB());
jedis0.close();
Jedis jedis1 = pool.getResource();
assertTrue("Jedis instance was not reused", jedis1 == jedis0);
assertEquals(0, jedis1.getDB());
jedis1.close();
pool.destroy();
assertTrue(pool.isClosed());
}
use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.
the class JedisPoolTest method checkPoolRepairedWhenJedisIsBroken.
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
Jedis jedis = pool.getResource();
jedis.auth("foobared");
jedis.quit();
jedis.close();
jedis = pool.getResource();
jedis.auth("foobared");
jedis.incr("foo");
jedis.close();
pool.destroy();
assertTrue(pool.isClosed());
}
use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.
the class JedisPoolTest method securePool.
@Test
public void securePool() {
JedisPoolConfig config = new JedisPoolConfig();
config.setTestOnBorrow(true);
JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared");
Jedis jedis = pool.getResource();
jedis.set("foo", "bar");
jedis.close();
pool.destroy();
assertTrue(pool.isClosed());
}
use of redis.clients.jedis.JedisPoolConfig in project jedis by xetorthio.
the class JedisClusterTest method testReturnConnectionOnRedirection.
@Test(expected = JedisClusterMaxRedirectionsException.class, timeout = DEFAULT_TIMEOUT)
public void testReturnConnectionOnRedirection() {
Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
JedisPoolConfig config = DEFAULT_CONFIG;
config.setMaxTotal(1);
JedisCluster jc = new JedisCluster(jedisClusterNode, 0, 2, DEFAULT_REDIRECTIONS, "cluster", config);
// This will cause an infinite redirection between node 2 and 3
node3.clusterSetSlotMigrating(15363, JedisClusterTestUtil.getNodeId(node2.clusterNodes()));
jc.get("e");
}
use of redis.clients.jedis.JedisPoolConfig in project jedis by xetorthio.
the class JedisPoolTest method checkConnections.
@Test
public void checkConnections() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000);
Jedis jedis = pool.getResource();
jedis.auth("foobared");
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
jedis.close();
pool.destroy();
assertTrue(pool.isClosed());
}
Aggregations