Search in sources :

Example 1 with JedisPool

use of io.leopard.redis.JedisPool in project leopard by tanhaichao.

the class JedisPoolTest method JedisPool.

@Test
public void JedisPool() {
    JedisPoolConfig poolConfig = new JedisPoolConfig();
    poolConfig.setMaxTotal(1);
    String host = "172.17.1.236";
    int port = 6311;
    int timeout = 3000;
    JedisPool pool = new JedisPool(poolConfig, host, port, timeout, null);
    {
        Jedis jedis = pool.getResource();
        pool.returnBrokenResource(jedis);
        pool.returnResource(jedis);
    }
    {
        RedisConnectionListener redisConnectionListener = Mockito.mock(RedisConnectionListener.class);
        pool.redisConnectionListener = redisConnectionListener;
        Jedis jedis = pool.getResource();
        pool.returnBrokenResource(jedis);
        pool.returnResource(jedis);
    }
}
Also used : Jedis(redis.clients.jedis.Jedis) RedisConnectionListener(io.leopard.redis.RedisConnectionListener) JedisPool(io.leopard.redis.JedisPool) JedisPoolConfig(redis.clients.jedis.JedisPoolConfig) Test(org.junit.Test)

Example 2 with JedisPool

use of io.leopard.redis.JedisPool in project leopard by tanhaichao.

the class JedisPoolApacheImplTest method JedisPoolApacheImpl.

@Test
public void JedisPoolApacheImpl() throws Exception {
    JedisPool jedisPoolMock = Mockito.mock(JedisPool.class);
    JedisPoolApacheImpl jedisPool = new JedisPoolApacheImpl("host", 6311, 3000, 16, null);
    // LeopardMockito.setProperty(jedisPool, jedisPoolMock, "pool");
    jedisPool.getResource();
    jedisPool.returnBrokenResource(null);
    jedisPool.returnResource(null);
    jedisPool.destroy();
}
Also used : JedisPoolApacheImpl(io.leopard.redis.util.JedisPoolApacheImpl) JedisPool(io.leopard.redis.JedisPool) Test(org.junit.Test)

Aggregations

JedisPool (io.leopard.redis.JedisPool)2 Test (org.junit.Test)2 RedisConnectionListener (io.leopard.redis.RedisConnectionListener)1 JedisPoolApacheImpl (io.leopard.redis.util.JedisPoolApacheImpl)1 Jedis (redis.clients.jedis.Jedis)1 JedisPoolConfig (redis.clients.jedis.JedisPoolConfig)1