From 3e348da5a767657e74630963a6017b64b7846330 Mon Sep 17 00:00:00 2001 From: M Sazzadul Hoque Date: Wed, 19 Dec 2018 10:56:18 +0600 Subject: [PATCH] Reset timeout to initial value (#1739) This is apparently the most probable casue of issue that tempted the fix #1718. --- .../redis/clients/jedis/tests/JedisTest.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/src/test/java/redis/clients/jedis/tests/JedisTest.java b/src/test/java/redis/clients/jedis/tests/JedisTest.java index 72b1cd3ae7..54b617ea08 100644 --- a/src/test/java/redis/clients/jedis/tests/JedisTest.java +++ b/src/test/java/redis/clients/jedis/tests/JedisTest.java @@ -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)