Skip to content

Commit 97b3666

Browse files
committed
Fix some broken tests
1 parent 7e09e16 commit 97b3666

File tree

5 files changed

+16
-8
lines changed

5 files changed

+16
-8
lines changed

src/test/java/redis/clients/jedis/ACLJedisPoolTest.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import static org.junit.Assert.assertTrue;
66
import static org.junit.Assert.fail;
77

8+
import java.net.URI;
89
import java.net.URISyntaxException;
910
import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
1011
import org.junit.BeforeClass;
@@ -22,6 +23,8 @@
2223
public class ACLJedisPoolTest {
2324
private static final EndpointConfig endpoint = HostAndPorts.getRedisEndpoint("standalone0-acl");
2425

26+
private static final EndpointConfig endpointWithDefaultUser = HostAndPorts.getRedisEndpoint("standalone0");
27+
2528
@BeforeClass
2629
public static void prepare() throws Exception {
2730
// Use to check if the ACL test should be ran. ACL are available only in 6.0 and later
@@ -194,15 +197,15 @@ public void startWithUrl() throws URISyntaxException {
194197
}
195198

196199
try (JedisPool pool = new JedisPool(
197-
endpoint.getCustomizedURI("default", endpoint.getPassword(), "/2"));
200+
endpointWithDefaultUser.getCustomizedURI(true, "/2"));
198201
Jedis jedis = pool.getResource()) {
199202
assertEquals("bar", jedis.get("foo"));
200203
}
201204
}
202205

203206
@Test(expected = InvalidURIException.class)
204207
public void shouldThrowInvalidURIExceptionForInvalidURI() throws URISyntaxException {
205-
new JedisPool(endpoint.getURI()).close();
208+
new JedisPool(new URI("localhost:6379")).close();
206209
}
207210

208211
@Test
@@ -256,8 +259,9 @@ public void testCloseConnectionOnMakeObject() {
256259
JedisPoolConfig config = new JedisPoolConfig();
257260
config.setTestOnBorrow(true);
258261
try (JedisPool pool = new JedisPool(new JedisPoolConfig(), endpoint.getHost(), endpoint.getPort(), 2000,
259-
endpoint.getUsername(), endpoint.getPassword()); Jedis jedis = new Jedis(endpoint.getCustomizedURI(
260-
"", endpoint.getPassword(), ""))) {
262+
endpoint.getUsername(), "wrongpassword");
263+
Jedis jedis = new Jedis(endpointWithDefaultUser.getCustomizedURI(
264+
"", endpointWithDefaultUser.getPassword(), ""))) {
261265
int currentClientCount = getClientCount(jedis.clientList());
262266
try {
263267
pool.getResource();

src/test/java/redis/clients/jedis/HostAndPorts.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ public final class HostAndPorts {
4343
}
4444

4545
public static EndpointConfig getRedisEndpoint(String endpointName) {
46+
if (!endpointConfigs.containsKey(endpointName)) {
47+
throw new IllegalArgumentException("Unknown Redis endpoint: " + endpointName);
48+
}
49+
4650
return endpointConfigs.get(endpointName);
4751
}
4852

src/test/java/redis/clients/jedis/PipeliningTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ public void waitReplicas() {
323323
p.waitReplicas(1, 10);
324324
p.sync();
325325

326-
EndpointConfig endpoint = HostAndPorts.getRedisEndpoint("standalone4");
326+
EndpointConfig endpoint = HostAndPorts.getRedisEndpoint("standalone4-replica-of-standalone1");
327327

328328
try (Jedis j = new Jedis(endpoint.getHostAndPort())) {
329329
j.auth(endpoint.getPassword());
@@ -338,7 +338,7 @@ public void waitAof() {
338338
p.waitAOF(1L, 0L, 0L);
339339
p.sync();
340340

341-
EndpointConfig endpoint = HostAndPorts.getRedisEndpoint("standalone4");
341+
EndpointConfig endpoint = HostAndPorts.getRedisEndpoint("standalone4-replica-of-standalone1");
342342

343343
try (Jedis j = new Jedis(endpoint.getHostAndPort())) {
344344
j.auth(endpoint.getPassword());

src/test/java/redis/clients/jedis/commands/jedis/ControlCommandsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public void roleMaster() {
143143
public void roleSlave() {
144144
EndpointConfig primaryEndpoint = HostAndPorts.getRedisEndpoint("standalone0");
145145

146-
try (Jedis slave = HostAndPorts.getRedisEndpoint("standalone4").getJedis()) {
146+
try (Jedis slave = HostAndPorts.getRedisEndpoint("standalone4-replica-of-standalone1").getJedis()) {
147147

148148
List<Object> role = slave.role();
149149
assertEquals("slave", role.get(0));

src/test/java/redis/clients/jedis/commands/jedis/FailoverCommandsTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class FailoverCommandsTest {
1818
private static final int INVALID_PORT = 6000;
1919

2020
private static final EndpointConfig node1 = HostAndPorts.getRedisEndpoint("standalone9");
21-
private static final EndpointConfig node2 = HostAndPorts.getRedisEndpoint("standalone10");
21+
private static final EndpointConfig node2 = HostAndPorts.getRedisEndpoint("standalone10-replica-of-standalone9");
2222

2323
private HostAndPort masterAddress;
2424
private HostAndPort replicaAddress;

0 commit comments

Comments
 (0)