Skip to content

Commit

Permalink
Adding one test in JedisPoolWithCompleteCredentialsTest
Browse files Browse the repository at this point in the history
  • Loading branch information
sazzad16 committed Dec 23, 2020
1 parent 406dfa1 commit 96312ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 9 deletions.
19 changes: 10 additions & 9 deletions src/test/java/redis/clients/jedis/tests/JedisPoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public void checkConnectionWithDefaultPort() {
}

@Test
public void checkResourceIsClosebleAndReusable() {
public void checkResourceIsClosableAndReusable() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
Expand All @@ -88,15 +88,16 @@ public void checkResourceIsClosebleAndReusable() {
@Test
public void checkPoolRepairedWhenJedisIsBroken() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort());
Jedis jedis = pool.getResource();
jedis.auth("foobared");
jedis.quit();
jedis.close();
try (Jedis jedis = pool.getResource()) {
jedis.auth("foobared");
jedis.set("foo", "0");
jedis.quit();
}

jedis = pool.getResource();
jedis.auth("foobared");
jedis.incr("foo");
jedis.close();
try (Jedis jedis = pool.getResource()) {
jedis.auth("foobared");
jedis.incr("foo");
}
pool.destroy();
assertTrue(pool.isClosed());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,23 @@ public void checkResourceIsClosableAndReusable() {
}
}

@Test
public void checkPoolRepairedWhenJedisIsBroken() {
JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort(),
Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, 0 /*infinite*/, "acljedis", "fizzbuzz",
Protocol.DEFAULT_DATABASE, "repairable-pool");
try (Jedis jedis = pool.getResource()) {
jedis.set("foo", "0");
jedis.quit();
}

try (Jedis jedis = pool.getResource()) {
jedis.incr("foo");
}
pool.destroy();
assertTrue(pool.isClosed());
}

@Test(expected = JedisExhaustedPoolException.class)
public void checkPoolOverflow() {
GenericObjectPoolConfig config = new GenericObjectPoolConfig();
Expand Down

0 comments on commit 96312ea

Please sign in to comment.