Update the way the Redis host(s) can be configured for the tests.

There is now a single property : redis-hosts.
This property must contain at least 2 host definitions of the form "host:port" (comma separated).
Sharding tests need 2 hosts ...

If this is not the case, the default value used is "localhost:6379,localhost:6380".
Tests that required one host are using the first definition.
This commit is contained in:
Yaourt
2010-09-15 10:49:36 +02:00
27 changed files with 2051 additions and 420 deletions

View File

@@ -9,26 +9,11 @@ import org.junit.After;
import org.junit.Before;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.Protocol;
import redis.clients.jedis.tests.HostAndPortUtil;
import redis.clients.jedis.tests.HostAndPortUtil.HostAndPort;
public abstract class JedisCommandTestBase extends Assert {
protected static String host = "localhost";
protected static int port = Protocol.DEFAULT_PORT;
static {
final String envHost = System.getProperty("redis-host");
final String envPort = System.getProperty("redis-port");
if (null != envHost && 0 < envHost.length()) {
host = envHost;
}
if (null != envPort && 0 < envPort.length()) {
try {
port = Integer.parseInt(envPort);
} catch (final NumberFormatException e) {
}
}
System.out.println("Redis host to be used : " + host + ":" + port);
}
protected static HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);
protected Jedis jedis;
@@ -38,7 +23,7 @@ public abstract class JedisCommandTestBase extends Assert {
@Before
public void setUp() throws Exception {
jedis = new Jedis(host, port, 500);
jedis = new Jedis(hnp.host, hnp.port, 500);
jedis.connect();
jedis.auth("foobared");
jedis.flushAll();
@@ -50,7 +35,7 @@ public abstract class JedisCommandTestBase extends Assert {
}
protected Jedis createJedis() throws UnknownHostException, IOException {
Jedis j = new Jedis(host, port);
Jedis j = new Jedis(hnp.host, hnp.port);
j.connect();
j.auth("foobared");
j.flushAll();