use of redis.clients.jedis.JedisPoolConfig 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.JedisPoolConfig 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.JedisPoolConfig 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());
}
use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.
the class JedisPoolTest method nonDefaultDatabase.
@Test
public void nonDefaultDatabase() {
JedisPool pool0 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared");
Jedis jedis0 = pool0.getResource();
jedis0.set("foo", "bar");
assertEquals("bar", jedis0.get("foo"));
jedis0.close();
pool0.destroy();
assertTrue(pool0.isClosed());
JedisPool pool1 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared", 1);
Jedis jedis1 = pool1.getResource();
assertNull(jedis1.get("foo"));
jedis1.close();
pool1.destroy();
assertTrue(pool1.isClosed());
}
use of redis.clients.jedis.JedisPoolConfig in project cachecloud by sohutv.
the class JedisPoolTest method customClientName.
@Test
public void customClientName() {
JedisPool pool0 = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(), 2000, "foobared", 0, "my_shiny_client_name");
Jedis jedis = pool0.getResource();
assertEquals("my_shiny_client_name", jedis.clientGetname());
jedis.close();
pool0.destroy();
assertTrue(pool0.isClosed());
}
Aggregations