diff --git a/pom.xml b/pom.xml
index 9d50773..a3348ac 100644
--- a/pom.xml
+++ b/pom.xml
@@ -12,6 +12,12 @@
compile
+
+
+ localhost
+ 6379
+
+
@@ -23,6 +29,17 @@
1.6
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 2.6
+
+
+ ${redis-host}
+ ${redis-port}
+
+
+
diff --git a/src/test/java/redis/clients/jedis/tests/JedisPoolTest.java b/src/test/java/redis/clients/jedis/tests/JedisPoolTest.java
index 4444ee6..a57e922 100644
--- a/src/test/java/redis/clients/jedis/tests/JedisPoolTest.java
+++ b/src/test/java/redis/clients/jedis/tests/JedisPoolTest.java
@@ -4,6 +4,7 @@ import java.io.IOException;
import java.util.concurrent.TimeoutException;
import org.junit.Assert;
+import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
@@ -11,83 +12,101 @@ import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Protocol;
public class JedisPoolTest extends Assert {
- @Test
- public void checkConnections() throws TimeoutException {
- JedisPool pool = new JedisPool("localhost", Protocol.DEFAULT_PORT, 2000);
- pool.setResourcesNumber(10);
- pool.init();
+ private static String host = "localhost";
+ private 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);
+ }
+
+ @Test
+ public void checkConnections() throws TimeoutException {
+ JedisPool pool = new JedisPool(host, port, 2000);
+ pool.setResourcesNumber(10);
+ pool.init();
- Jedis jedis = pool.getResource(200);
- jedis.auth("foobared");
- jedis.set("foo", "bar");
- assertEquals("bar", jedis.get("foo"));
- pool.returnResource(jedis);
- pool.destroy();
- }
+ Jedis jedis = pool.getResource(200);
+ jedis.auth("foobared");
+ jedis.set("foo", "bar");
+ assertEquals("bar", jedis.get("foo"));
+ pool.returnResource(jedis);
+ pool.destroy();
+ }
- @Test
- public void checkConnectionWithDefaultPort() throws TimeoutException {
- JedisPool pool = new JedisPool("localhost");
- pool.setResourcesNumber(10);
- pool.init();
+ @Test
+ public void checkConnectionWithDefaultPort() throws TimeoutException {
+ JedisPool pool = new JedisPool(host, port);
+ pool.setResourcesNumber(10);
+ pool.init();
- Jedis jedis = pool.getResource(200);
- jedis.auth("foobared");
- jedis.set("foo", "bar");
- assertEquals("bar", jedis.get("foo"));
- pool.returnResource(jedis);
- pool.destroy();
- }
+ Jedis jedis = pool.getResource(200);
+ jedis.auth("foobared");
+ jedis.set("foo", "bar");
+ assertEquals("bar", jedis.get("foo"));
+ pool.returnResource(jedis);
+ pool.destroy();
+ }
- @Test
- public void checkJedisIsReusedWhenReturned() throws TimeoutException {
- JedisPool pool = new JedisPool("localhost");
- pool.setResourcesNumber(1);
- pool.init();
+ @Test
+ public void checkJedisIsReusedWhenReturned() throws TimeoutException {
+ JedisPool pool = new JedisPool(host, port);
+ pool.setResourcesNumber(1);
+ pool.init();
- Jedis jedis = pool.getResource(200);
- jedis.auth("foobared");
- jedis.set("foo", "0");
- pool.returnResource(jedis);
+ Jedis jedis = pool.getResource(200);
+ jedis.auth("foobared");
+ jedis.set("foo", "0");
+ pool.returnResource(jedis);
- jedis = pool.getResource(200);
- jedis.auth("foobared");
- jedis.incr("foo");
- pool.returnResource(jedis);
- pool.destroy();
- }
+ jedis = pool.getResource(200);
+ jedis.auth("foobared");
+ jedis.incr("foo");
+ pool.returnResource(jedis);
+ pool.destroy();
+ }
- @Test
- public void checkPoolRepairedWhenJedisIsBroken() throws TimeoutException,
- IOException {
- JedisPool pool = new JedisPool("localhost");
- pool.setResourcesNumber(1);
- pool.init();
+ @Test
+ public void checkPoolRepairedWhenJedisIsBroken() throws TimeoutException,
+ IOException {
+ JedisPool pool = new JedisPool(host, port);
+ pool.setResourcesNumber(1);
+ pool.init();
- Jedis jedis = pool.getResource(200);
- jedis.auth("foobared");
- jedis.quit();
- pool.returnBrokenResource(jedis);
+ Jedis jedis = pool.getResource(200);
+ jedis.auth("foobared");
+ jedis.quit();
+ pool.returnBrokenResource(jedis);
- jedis = pool.getResource(200);
- jedis.auth("foobared");
- jedis.incr("foo");
- pool.returnResource(jedis);
- pool.destroy();
- }
+ jedis = pool.getResource(200);
+ jedis.auth("foobared");
+ jedis.incr("foo");
+ pool.returnResource(jedis);
+ pool.destroy();
+ }
- @Test(expected = TimeoutException.class)
- public void checkPoolOverflow() throws TimeoutException {
- JedisPool pool = new JedisPool("localhost");
- pool.setResourcesNumber(1);
- pool.init();
+ @Test(expected = TimeoutException.class)
+ public void checkPoolOverflow() throws TimeoutException {
+ JedisPool pool = new JedisPool(host, port);
+ pool.setResourcesNumber(1);
+ pool.init();
- Jedis jedis = pool.getResource(200);
- jedis.auth("foobared");
- jedis.set("foo", "0");
+ Jedis jedis = pool.getResource(200);
+ jedis.auth("foobared");
+ jedis.set("foo", "0");
- Jedis newJedis = pool.getResource(200);
- newJedis.auth("foobared");
- newJedis.incr("foo");
- }
+ Jedis newJedis = pool.getResource(200);
+ newJedis.auth("foobared");
+ newJedis.incr("foo");
+ }
}
\ No newline at end of file
diff --git a/src/test/java/redis/clients/jedis/tests/PipeliningTest.java b/src/test/java/redis/clients/jedis/tests/PipeliningTest.java
index 8816555..d596dac 100644
--- a/src/test/java/redis/clients/jedis/tests/PipeliningTest.java
+++ b/src/test/java/redis/clients/jedis/tests/PipeliningTest.java
@@ -6,19 +6,45 @@ import java.util.List;
import junit.framework.Assert;
+import org.junit.Before;
import org.junit.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPipeline;
+import redis.clients.jedis.Protocol;
public class PipeliningTest extends Assert {
+ private static String host = "localhost";
+ private 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);
+ }
+
+ private Jedis jedis;
+
+ @Before
+ public void setUp() throws Exception {
+ jedis = new Jedis(host, port, 500);
+ jedis.connect();
+ jedis.auth("foobared");
+ jedis.flushAll();
+ }
+
@Test
public void pipeline() throws UnknownHostException, IOException {
- Jedis jedis = new Jedis("localhost");
- jedis.connect();
- jedis.auth("foobared");
- jedis.flushAll();
-
List