Skip to content

Commit

Permalink
Reset timeout to initial value (#1739)
Browse files Browse the repository at this point in the history
This is apparently the most probable casue of issue that tempted the fix #1718.
  • Loading branch information
sazzad16 authored Dec 19, 2018
1 parent cfe01e3 commit 3e348da
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions src/test/java/redis/clients/jedis/tests/JedisTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,46 @@ public void connectWithShardInfo() {
jedis.get("foo");
}

@Test(expected = JedisConnectionException.class)
@Test
public void timeoutConnection() throws Exception {
Jedis jedis = new Jedis("localhost", 6379, 15000);
jedis.auth("foobared");
String timeout = jedis.configGet("timeout").get(1);
jedis.configSet("timeout", "1");
Thread.sleep(2000);
jedis.hmget("foobar", "foo");
try {
jedis.hmget("foobar", "foo");
fail("Operation should throw JedisConnectionException");
} catch(JedisConnectionException jce) {
// expected
}
jedis.close();

// reset config
jedis = new Jedis("localhost", 6379);
jedis.auth("foobared");
jedis.configSet("timeout", timeout);
jedis.close();
}

@Test(expected = JedisConnectionException.class)
@Test
public void timeoutConnectionWithURI() throws Exception {
Jedis jedis = new Jedis(new URI("redis://:foobared@localhost:6380/2"), 15000);
String timeout = jedis.configGet("timeout").get(1);
jedis.configSet("timeout", "1");
Thread.sleep(2000);
jedis.hmget("foobar", "foo");
try {
jedis.hmget("foobar", "foo");
fail("Operation should throw JedisConnectionException");
} catch(JedisConnectionException jce) {
// expected
}
jedis.close();

// reset config
jedis = new Jedis(new URI("redis://:foobared@localhost:6380/2"));
jedis.configSet("timeout", timeout);
jedis.close();
}

@Test(expected = JedisDataException.class)
Expand Down

0 comments on commit 3e348da

Please sign in to comment.