use of redis.clients.jedis.JedisPool in project jedis by xetorthio.
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.JedisPool in project jedis by xetorthio.
the class JedisPoolTest method allowUrlWithNoDBAndNoPassword.
@Test
public void allowUrlWithNoDBAndNoPassword() throws URISyntaxException {
new JedisPool("redis://localhost:6380");
new JedisPool(new URI("redis://localhost:6380"));
}
use of redis.clients.jedis.JedisPool in project jedis by xetorthio.
the class JedisPoolTest method checkPoolOverflow.
@Test(expected = JedisExhaustedPoolException.class)
public void checkPoolOverflow() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
JedisPool pool = new JedisPool(config, hnp.getHost(), hnp.getPort());
Jedis jedis = pool.getResource();
jedis.auth("foobared");
jedis.set("foo", "0");
Jedis newJedis = pool.getResource();
newJedis.auth("foobared");
newJedis.incr("foo");
}
use of redis.clients.jedis.JedisPool in project jedis by xetorthio.
the class JedisPoolTest method startWithUrlString.
@Test
public void startWithUrlString() {
Jedis j = new Jedis("localhost", 6380);
j.auth("foobared");
j.select(2);
j.set("foo", "bar");
JedisPool pool = new JedisPool("redis://:foobared@localhost:6380/2");
Jedis jedis = pool.getResource();
assertEquals("PONG", jedis.ping());
assertEquals("bar", jedis.get("foo"));
}
use of redis.clients.jedis.JedisPool in project jedis by xetorthio.
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());
}
Aggregations