Skip to content

Commit

Permalink
Fix name of endpoint variable in JedisPooledTest
Browse files Browse the repository at this point in the history
  • Loading branch information
uglide committed May 17, 2024
1 parent 8c0a4a3 commit 4f81b20
Showing 1 changed file with 17 additions and 11 deletions.
28 changes: 17 additions & 11 deletions src/test/java/redis/clients/jedis/JedisPooledTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,15 @@

public class JedisPooledTest {

private static final EndpointConfig endpoint1 = HostAndPorts.getRedisEndpoint("standalone7-with-lfu-policy");
private static final EndpointConfig endpointStandalone1 = HostAndPorts.getRedisEndpoint("standalone1"); // password protected
private static final EndpointConfig endpointStandalone7 = HostAndPorts.getRedisEndpoint(
"standalone7-with-lfu-policy");
private static final EndpointConfig endpointStandalone1 = HostAndPorts.getRedisEndpoint(
"standalone1"); // password protected

@Test
public void checkCloseableConnections() {
JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(), endpoint1.getHost(), endpoint1.getPort(), 2000);
JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(), endpointStandalone7.getHost(),
endpointStandalone7.getPort(), 2000);
pool.set("foo", "bar");
assertEquals("bar", pool.get("foo"));
pool.close();
Expand All @@ -35,7 +38,7 @@ public void checkCloseableConnections() {

@Test
public void checkResourceWithConfig() {
try (JedisPooled pool = new JedisPooled(endpoint1.getHostAndPort(),
try (JedisPooled pool = new JedisPooled(endpointStandalone7.getHostAndPort(),
DefaultJedisClientConfig.builder().socketTimeoutMillis(5000).build())) {

try (Connection jedis = pool.getPool().getResource()) {
Expand All @@ -50,7 +53,7 @@ public void checkPoolOverflow() {
GenericObjectPoolConfig<Connection> config = new GenericObjectPoolConfig<>();
config.setMaxTotal(1);
config.setBlockWhenExhausted(false);
try (JedisPooled pool = new JedisPooled(endpoint1.getHostAndPort(), config);
try (JedisPooled pool = new JedisPooled(endpointStandalone7.getHostAndPort(), config);
Connection jedis = pool.getPool().getResource()) {

try (Connection jedis2 = pool.getPool().getResource()) {
Expand Down Expand Up @@ -100,7 +103,7 @@ public void allowUrlWithNoDBAndNoPassword() throws URISyntaxException {

@Test
public void customClientName() {
try (JedisPooled pool = new JedisPooled(endpoint1.getHostAndPort(), DefaultJedisClientConfig.builder()
try (JedisPooled pool = new JedisPooled(endpointStandalone7.getHostAndPort(), DefaultJedisClientConfig.builder()
.clientName("my_shiny_client_name").build());
Connection jedis = pool.getPool().getResource()) {
assertEquals("my_shiny_client_name", new Jedis(jedis).clientGetname());
Expand All @@ -109,7 +112,7 @@ public void customClientName() {

@Test
public void invalidClientName() {
try (JedisPooled pool = new JedisPooled(endpoint1.getHostAndPort(), DefaultJedisClientConfig.builder()
try (JedisPooled pool = new JedisPooled(endpointStandalone7.getHostAndPort(), DefaultJedisClientConfig.builder()
.clientName("invalid client name").build());
Connection jedis = pool.getPool().getResource()) {
} catch (Exception e) {
Expand All @@ -121,7 +124,7 @@ public void invalidClientName() {

@Test
public void getNumActiveWhenPoolIsClosed() {
JedisPooled pool = new JedisPooled(endpoint1.getHostAndPort());
JedisPooled pool = new JedisPooled(endpointStandalone7.getHostAndPort());

try (Connection j = pool.getPool().getResource()) {
j.ping();
Expand All @@ -133,7 +136,8 @@ public void getNumActiveWhenPoolIsClosed() {

@Test
public void getNumActiveReturnsTheCorrectNumber() {
try (JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(), endpoint1.getHost(), endpoint1.getPort(), 2000)) {
try (JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(),
endpointStandalone7.getHost(), endpointStandalone7.getPort(), 2000)) {

Connection jedis = pool.getPool().getResource();
assertEquals(1, pool.getPool().getNumActive());
Expand All @@ -151,7 +155,8 @@ public void getNumActiveReturnsTheCorrectNumber() {

@Test
public void closeResourceTwice() {
try (JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(), endpoint1.getHost(), endpoint1.getPort(), 2000)) {
try (JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(),
endpointStandalone7.getHost(), endpointStandalone7.getPort(), 2000)) {
Connection j = pool.getPool().getResource();
j.ping();
j.close();
Expand All @@ -161,7 +166,8 @@ public void closeResourceTwice() {

@Test
public void closeBrokenResourceTwice() {
try (JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(), endpoint1.getHost(), endpoint1.getPort(), 2000)) {
try (JedisPooled pool = new JedisPooled(new ConnectionPoolConfig(),
endpointStandalone7.getHost(), endpointStandalone7.getPort(), 2000)) {
Connection j = pool.getPool().getResource();
try {
// make connection broken
Expand Down

0 comments on commit 4f81b20

Please sign in to comment.