Package org.apache.commons.pool2

Examples of org.apache.commons.pool2.TestKeyedObjectPool


  assertTrue(pool.isClosed());
    }

    @Test(expected = JedisConnectionException.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");
View Full Code Here


  assertTrue(pool0.isClosed());
    }

    @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 {
View Full Code Here

  assertTrue(pool.isClosed());
    }

    @Test
    public void checkResourceIsCloseable() {
  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 {
View Full Code Here

    public JedisCluster(Set<HostAndPort> nodes) {
  this(nodes, DEFAULT_TIMEOUT);
    }

    public JedisCluster(Set<HostAndPort> nodes, int timeout, int maxRedirections) {
  this(nodes, timeout, maxRedirections, new GenericObjectPoolConfig());
    }
View Full Code Here

  assertEquals("foo", jc.get("51"));
    }

    @Test(expected = JedisConnectionException.class)
    public void testIfPoolConfigAppliesToClusterPools() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(0);
  config.setMaxWaitMillis(2000);
  Set<HostAndPort> jedisClusterNode = new HashSet<HostAndPort>();
  jedisClusterNode.add(new HostAndPort("127.0.0.1", 7379));
  JedisCluster jc = new JedisCluster(jedisClusterNode, config);
  jc.set("52", "poolTestValue");
    }
View Full Code Here

  pool.destroy();
    }

    @Test
    public void checkCloseableConnections() throws Exception {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();

  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels,
    config, 1000, "foobared", 2);
  Jedis jedis = pool.getResource();
  jedis.auth("foobared");
View Full Code Here

    }

    @Test
    public void ensureSafeTwiceFailover() throws InterruptedException {
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels,
    new GenericObjectPoolConfig(), 1000, "foobared", 2);

  forceFailover(pool);
  // after failover sentinel needs a bit of time to stabilize before a new
  // failover
  Thread.sleep(100);
View Full Code Here

  // you can test failover as much as possible
    }

    @Test
    public void returnResourceShouldResetState() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels,
    config, 1000, "foobared", 2);

  Jedis jedis = pool.getResource();
  Jedis jedis2 = null;
View Full Code Here

  }
    }

    @Test
    public void checkResourceIsCloseable() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels,
    config, 1000, "foobared", 2);

  Jedis jedis = pool.getResource();
  try {
View Full Code Here

  }
    }

    @Test
    public void returnResourceWithNullResource() {
  GenericObjectPoolConfig config = new GenericObjectPoolConfig();
  config.setMaxTotal(1);
  config.setBlockWhenExhausted(false);
  JedisSentinelPool pool = new JedisSentinelPool(MASTER_NAME, sentinels,
    config, 1000, "foobared", 2);

  Jedis nullJedis = null;
  pool.returnResource(nullJedis);
View Full Code Here

TOP

Related Classes of org.apache.commons.pool2.TestKeyedObjectPool

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.