Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/test/java/redis/clients/jedis/ACLJedisPoolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,16 @@ public void testCloseConnectionOnMakeObject() {
}
}

@Test
public void checkConnectionWithURIAndTimeout() {
try (JedisPool pool = new JedisPool(endpoint.getURIBuilder().defaultCredentials().build(), Protocol.DEFAULT_TIMEOUT);
Jedis jedis = pool.getResource()) {
jedis.auth(endpoint.getUsername(), endpoint.getPassword());
jedis.set("foo", "bar");
assertEquals("bar", jedis.get("foo"));
}
}

private int getClientCount(final String clientList) {
return clientList.split("\n").length;
}
Expand Down
110 changes: 110 additions & 0 deletions src/test/java/redis/clients/jedis/ACLJedisTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,114 @@ public void startWithUri() throws URISyntaxException {
}
}

@Test
public void startWithHostPortStringAndSsl() {
try (Jedis j = new Jedis(endpoint.getHost(), endpoint.getPort(), false)) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
try (Jedis j1 = new Jedis(endpoint.getURIBuilder().defaultCredentials().path("/2").build())) {
assertEquals("PONG", j1.ping());
assertEquals("bar", j1.get("foo"));
}
}

@Test
public void startWithHostPortStringAndTimeout() {
try (Jedis j = new Jedis(endpoint.getHost(), endpoint.getPort(), Protocol.DEFAULT_TIMEOUT)) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
try (Jedis j1 = new Jedis(endpoint.getURIBuilder().defaultCredentials().path("/2").build())) {
assertEquals("PONG", j1.ping());
assertEquals("bar", j1.get("foo"));
}
}

@Test
public void startWithHostPortStringAndTimeoutAndSsl() {
try (Jedis j = new Jedis(endpoint.getHost(), endpoint.getPort(), Protocol.DEFAULT_TIMEOUT, false)) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
try (Jedis j1 = new Jedis(endpoint.getURIBuilder().defaultCredentials().path("/2").build())) {
assertEquals("PONG", j1.ping());
assertEquals("bar", j1.get("foo"));
}
}

@Test
public void startWithHostPortStringAndTimeouts() {
try (Jedis j = new Jedis(endpoint.getHost(), endpoint.getPort(), Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT, Protocol.DEFAULT_TIMEOUT)) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
try (Jedis j1 = new Jedis(endpoint.getURIBuilder().defaultCredentials().path("/2").build())) {
assertEquals("PONG", j1.ping());
assertEquals("bar", j1.get("foo"));
}
}

@Test
public void startWithURI() throws URISyntaxException {
try (Jedis j = new Jedis(endpoint.getURIBuilder().defaultCredentials().build())) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
try (Jedis j1 = new Jedis(endpoint.getURIBuilder().defaultCredentials().path("/2").build())) {
assertEquals("PONG", j1.ping());
assertEquals("bar", j1.get("foo"));
}
}

@Test
public void startWithURIAndTimeout() throws URISyntaxException {
try (Jedis j = new Jedis(endpoint.getURIBuilder().defaultCredentials().build(), Protocol.DEFAULT_TIMEOUT)) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
try (Jedis j1 = new Jedis(endpoint.getURIBuilder().defaultCredentials().path("/2").build())) {
assertEquals("PONG", j1.ping());
assertEquals("bar", j1.get("foo"));
}
}

@Test
public void startWithFactory() {
JedisSocketFactory socketFactory = new DefaultJedisSocketFactory(endpoint.getHostAndPort(), endpoint.getClientConfigBuilder().build());

try(Jedis j = new Jedis(socketFactory)) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
}

@Test
public void startWithFactoryAndConfig() {
JedisSocketFactory socketFactory = new DefaultJedisSocketFactory(endpoint.getHostAndPort(), endpoint.getClientConfigBuilder().build());

try(Jedis j = new Jedis(socketFactory, DefaultJedisClientConfig.builder().build())) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
}

@Test
public void startWithConnection() {
JedisSocketFactory socketFactory = new DefaultJedisSocketFactory(endpoint.getHostAndPort(), endpoint.getClientConfigBuilder().build());
Connection connection = new Connection(socketFactory);
try(Jedis j = new Jedis(connection)) {
assertEquals("OK", j.auth(endpoint.getUsername(), endpoint.getPassword()));
assertEquals("OK", j.select(2));
j.set("foo", "bar");
}
}
}
Loading
Loading