add url support

This commit is contained in:
Jonathan Leibiusky
2012-08-01 16:49:44 -03:00
parent 35a7677eb9
commit 8f9763a7e9
8 changed files with 231 additions and 53 deletions

View File

@@ -1,5 +1,8 @@
package redis.clients.jedis.tests;
import java.net.URI;
import java.net.URISyntaxException;
import org.apache.commons.pool.impl.GenericObjectPool;
import org.apache.commons.pool.impl.GenericObjectPool.Config;
import org.junit.Assert;
@@ -123,4 +126,28 @@ public class JedisPoolTest extends Assert {
pool.returnResource(jedis);
pool.destroy();
}
@Test
public void startWithUrlString() {
Jedis j = new Jedis("localhost", 6380);
j.auth("foobared");
j.select(2);
j.set("foo", "bar");
JedisPool pool = new JedisPool("redis://:foobared@localhost:6380/2");
Jedis jedis = pool.getResource();
assertEquals("PONG", jedis.ping());
assertEquals("bar", jedis.get("foo"));
}
@Test
public void startWithUrl() throws URISyntaxException {
Jedis j = new Jedis("localhost", 6380);
j.auth("foobared");
j.select(2);
j.set("foo", "bar");
JedisPool pool = new JedisPool(new URI("redis://:foobared@localhost:6380/2"));
Jedis jedis = pool.getResource();
assertEquals("PONG", jedis.ping());
assertEquals("bar", jedis.get("foo"));
}
}