Skip to content

Commit 0f80e12

Browse files
author
Simon Prickett
committed
Adds password support to sliding rate limiter tests.
1 parent 8b1fe41 commit 0f80e12

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/test/java/com/redislabs/university/RU102J/dao/RateLimiterSlidingDaoRedisImplTest.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import org.junit.rules.ExpectedException;
77
import redis.clients.jedis.Jedis;
88
import redis.clients.jedis.JedisPool;
9+
import redis.clients.jedis.JedisPoolConfig;
910

1011
import static org.hamcrest.Matchers.is;
1112
import static org.junit.Assert.*;
@@ -21,8 +22,17 @@ public class RateLimiterSlidingDaoRedisImplTest {
2122

2223
@BeforeClass
2324
public static void setUp() throws Exception {
24-
jedisPool = new JedisPool(HostPort.getRedisHost(), HostPort.getRedisPort());
25-
jedis = new Jedis(HostPort.getRedisHost(), HostPort.getRedisPort());
25+
String password = HostPort.getRedisPassword();
26+
27+
if (password.length() > 0) {
28+
jedisPool = new JedisPool(new JedisPoolConfig(), HostPort.getRedisHost(), HostPort.getRedisPort(), 2000, password);
29+
jedis = new Jedis(HostPort.getRedisHost(), HostPort.getRedisPort());
30+
31+
jedis.auth(password);
32+
} else {
33+
jedisPool = new JedisPool(HostPort.getRedisHost(), HostPort.getRedisPort());
34+
jedis = new Jedis(HostPort.getRedisHost(), HostPort.getRedisPort());
35+
}
2636
keyManager = new TestKeyManager("test");
2737
}
2838

0 commit comments

Comments
 (0)