use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method returnResourceShouldResetState.
@Test
public void returnResourceShouldResetState() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort(), 2000, "foobared");
Jedis jedis = pool.getResource();
try {
jedis.set("hello", "jedis");
Transaction t = jedis.multi();
t.set("hello", "world");
} finally {
jedis.close();
}
Jedis jedis2 = pool.getResource();
try {
assertTrue(jedis == jedis2);
assertEquals("jedis", jedis2.get("hello"));
} finally {
jedis2.close();
}
pool.destroy();
assertTrue(pool.isClosed());
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method getNumActiveIsNegativeWhenPoolIsClosed.
@Test
public void getNumActiveIsNegativeWhenPoolIsClosed() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared", 0, "my_shiny_client_name");
pool.destroy();
assertTrue(pool.getNumActive() < 0);
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
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());
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method getNumActiveReturnsTheCorrectNumber.
@Test
public void getNumActiveReturnsTheCorrectNumber() {
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"));
assertEquals(1, pool.getNumActive());
Jedis jedis2 = pool.getResource();
jedis.auth("foobared");
jedis.set("foo", "bar");
assertEquals(2, pool.getNumActive());
jedis.close();
assertEquals(1, pool.getNumActive());
jedis2.close();
assertEquals(0, pool.getNumActive());
pool.destroy();
}
use of redis.clients.jedis.JedisPool in project cachecloud by sohutv.
the class JedisPoolTest method checkCloseableConnections.
@Test
public void checkCloseableConnections() throws Exception {
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.close();
assertTrue(pool.isClosed());
}
Aggregations