Merge branch 'master' of http://github.com/yaourt/jedis
This commit is contained in:
@@ -9,34 +9,36 @@ 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 HostAndPort hnp = HostAndPortUtil.getRedisServers().get(0);
|
||||
|
||||
protected Jedis jedis;
|
||||
protected Jedis jedis;
|
||||
|
||||
public JedisCommandTestBase() {
|
||||
super();
|
||||
}
|
||||
public JedisCommandTestBase() {
|
||||
super();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis("localhost", Protocol.DEFAULT_PORT, 500);
|
||||
jedis.connect();
|
||||
jedis.auth("foobared");
|
||||
jedis.flushAll();
|
||||
}
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
jedis = new Jedis(hnp.host, hnp.port, 500);
|
||||
jedis.connect();
|
||||
jedis.auth("foobared");
|
||||
jedis.flushAll();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.disconnect();
|
||||
}
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
jedis.disconnect();
|
||||
}
|
||||
|
||||
protected Jedis createJedis() throws UnknownHostException, IOException {
|
||||
Jedis j = new Jedis("localhost");
|
||||
j.connect();
|
||||
j.auth("foobared");
|
||||
j.flushAll();
|
||||
return j;
|
||||
}
|
||||
protected Jedis createJedis() throws UnknownHostException, IOException {
|
||||
Jedis j = new Jedis(hnp.host, hnp.port);
|
||||
j.connect();
|
||||
j.auth("foobared");
|
||||
j.flushAll();
|
||||
return j;
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import java.net.UnknownHostException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
@@ -13,6 +14,17 @@ import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.TransactionBlock;
|
||||
|
||||
public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
Jedis nj;
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
|
||||
nj = new Jedis(hnp.host, hnp.port, 500);
|
||||
nj.connect();
|
||||
nj.auth("foobared");
|
||||
nj.flushAll();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multi() {
|
||||
Transaction trans = jedis.multi();
|
||||
@@ -62,7 +74,6 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
jedis.watch("mykey");
|
||||
Transaction t = jedis.multi();
|
||||
|
||||
Jedis nj = new Jedis("localhost");
|
||||
nj.connect();
|
||||
nj.auth("foobared");
|
||||
nj.set("mykey", "bar");
|
||||
@@ -83,7 +94,6 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals("OK", status);
|
||||
Transaction t = jedis.multi();
|
||||
|
||||
Jedis nj = new Jedis("localhost");
|
||||
nj.connect();
|
||||
nj.auth("foobared");
|
||||
nj.set("mykey", "bar");
|
||||
|
||||
Reference in New Issue
Block a user