Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oscar-besga-panel committed Sep 3, 2023
1 parent 64c14bd commit 993f16d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 20 deletions.
16 changes: 8 additions & 8 deletions src/test/java/redis/clients/jedis/JedisPoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -460,23 +460,23 @@ 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());
});
}
}

@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<String> 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());
Expand Down
21 changes: 9 additions & 12 deletions src/test/java/redis/clients/jedis/JedisPooledTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -257,34 +257,31 @@ 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());
});
}
}

@Test
public void testWithJedisGet() {
HostAndPort hostAndPortTest = HostAndPorts.getRedisServers().get(0);
try (JedisPooled pool = new JedisPooled(hostAndPortTest)) {
try (JedisPooled pool = new JedisPooled(hnp)) {
List<String> 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());
Expand Down

0 comments on commit 993f16d

Please sign in to comment.