diff --git a/src/test/java/redis/clients/jedis/JedisPoolTest.java b/src/test/java/redis/clients/jedis/JedisPoolTest.java index 2d24331d8e..5484e6658a 100644 --- a/src/test/java/redis/clients/jedis/JedisPoolTest.java +++ b/src/test/java/redis/clients/jedis/JedisPoolTest.java @@ -460,11 +460,11 @@ public void testResetValidCredentials() { @Test public void testWithJedisDo() { - HostAndPort hpTest = HostAndPorts.getRedisServers().get(0); - try (JedisPool pool = new JedisPool(new JedisPoolConfig(), hpTest.getHost(), hpTest.getPort())) { + try (JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort())) { pool.withJedisDo(jedis -> { - assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hpTest.getHost())); - assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hpTest.getPort())); + jedis.auth("foobared"); + assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hnp.getHost())); + assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hnp.getPort())); assertThat(jedis.time(), notNullValue()); }); } @@ -472,11 +472,11 @@ public void testWithJedisDo() { @Test public void testWithJedisGet() { - HostAndPort hpTest = HostAndPorts.getRedisServers().get(0); - try (JedisPool pool = new JedisPool(new JedisPoolConfig(), hpTest.getHost(), hpTest.getPort())) { + try (JedisPool pool = new JedisPool(new JedisPoolConfig(), hnp.getHost(), hnp.getPort())) { List result = pool.withJedisGet(jedis -> { - assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hpTest.getHost())); - assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hpTest.getPort())); + jedis.auth("foobared"); + assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hnp.getHost())); + assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hnp.getPort())); return jedis.time(); }); assertThat(result,notNullValue()); diff --git a/src/test/java/redis/clients/jedis/JedisPooledTest.java b/src/test/java/redis/clients/jedis/JedisPooledTest.java index 27e0d146b0..c8ce3585f9 100644 --- a/src/test/java/redis/clients/jedis/JedisPooledTest.java +++ b/src/test/java/redis/clients/jedis/JedisPooledTest.java @@ -257,22 +257,20 @@ public void cleanUp() { @Test public void testNewJedis() { - HostAndPort hostAndPortTest = HostAndPorts.getRedisServers().get(0); - try (JedisPooled pool = new JedisPooled(hostAndPortTest)) { + try (JedisPooled pool = new JedisPooled(hnp)) { Jedis jedis = pool.newJedis(); - assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hostAndPortTest.getHost())); - assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hostAndPortTest.getPort())); + assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hnp.getHost())); + assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hnp.getPort())); assertThat(jedis.time(), notNullValue()); } } @Test public void testWithJedisDo() { - HostAndPort hostAndPortTest = HostAndPorts.getRedisServers().get(0); - try (JedisPooled pool = new JedisPooled(hostAndPortTest)) { + try (JedisPooled pool = new JedisPooled(hnp)) { pool.withJedisDo(jedis -> { - assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hostAndPortTest.getHost())); - assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hostAndPortTest.getPort())); + assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hnp.getHost())); + assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hnp.getPort())); assertThat(jedis.time(), notNullValue()); }); } @@ -280,11 +278,10 @@ public void testWithJedisDo() { @Test public void testWithJedisGet() { - HostAndPort hostAndPortTest = HostAndPorts.getRedisServers().get(0); - try (JedisPooled pool = new JedisPooled(hostAndPortTest)) { + try (JedisPooled pool = new JedisPooled(hnp)) { List result = pool.withJedisGet(jedis -> { - assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hostAndPortTest.getHost())); - assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hostAndPortTest.getPort())); + assertThat(jedis.getClient().getHostAndPort().getHost(), equalTo(hnp.getHost())); + assertThat(jedis.getClient().getHostAndPort().getPort(), equalTo(hnp.getPort())); return jedis.time(); }); assertThat(result,notNullValue());