New exception management. Less exceptions... assume everything works
This commit is contained in:
@@ -7,7 +7,7 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class JedisTest {
|
||||
@Test(expected = JedisException.class)
|
||||
public void useWithoutConnecting() throws JedisException {
|
||||
public void useWithoutConnecting() {
|
||||
Jedis jedis = new Jedis("localhost");
|
||||
jedis.dbSize();
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Protocol;
|
||||
|
||||
public class ProtocolTest extends Assert {
|
||||
@@ -39,7 +38,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void bulkReply() throws JedisException {
|
||||
public void bulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("$6\r\nfoobar\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = protocol.getBulkReply(is);
|
||||
@@ -47,7 +46,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void nullBulkReply() throws JedisException {
|
||||
public void nullBulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = protocol.getBulkReply(is);
|
||||
@@ -55,7 +54,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void singleLineReply() throws JedisException {
|
||||
public void singleLineReply() {
|
||||
InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
String response = protocol.getStatusCodeReply(is);
|
||||
@@ -63,7 +62,7 @@ public class ProtocolTest extends Assert {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void integerReply() throws JedisException {
|
||||
public void integerReply() {
|
||||
InputStream is = new ByteArrayInputStream(":123\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
int response = protocol.getIntegerReply(is);
|
||||
@@ -72,7 +71,7 @@ public class ProtocolTest extends Assert {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void multiBulkReply() throws JedisException {
|
||||
public void multiBulkReply() {
|
||||
InputStream is = new ByteArrayInputStream(
|
||||
"*4\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$5\r\nHello\r\n$5\r\nWorld\r\n"
|
||||
.getBytes());
|
||||
@@ -106,7 +105,7 @@ public class ProtocolTest extends Assert {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void nullMultiBulkReply() throws JedisException {
|
||||
public void nullMultiBulkReply() {
|
||||
InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes());
|
||||
Protocol protocol = new Protocol();
|
||||
List<String> response = (List<String>) (List<?>) protocol
|
||||
|
||||
@@ -5,13 +5,12 @@ import java.net.UnknownHostException;
|
||||
import java.util.Calendar;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class GetSetBenchmark {
|
||||
private static final int TOTAL_OPERATIONS = 100000;
|
||||
|
||||
public static void main(String[] args) throws UnknownHostException,
|
||||
IOException, JedisException {
|
||||
IOException {
|
||||
Jedis jedis = new Jedis("localhost");
|
||||
jedis.connect();
|
||||
jedis.auth("foobared");
|
||||
|
||||
@@ -9,13 +9,13 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void ping() throws JedisException {
|
||||
public void ping() {
|
||||
String status = jedis.ping();
|
||||
assertEquals("PONG", status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void exists() throws JedisException {
|
||||
public void exists() {
|
||||
String status = jedis.set("foo", "bar");
|
||||
assertEquals("OK", status);
|
||||
|
||||
@@ -30,7 +30,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void del() throws JedisException {
|
||||
public void del() {
|
||||
jedis.set("foo1", "bar1");
|
||||
jedis.set("foo2", "bar2");
|
||||
jedis.set("foo3", "bar3");
|
||||
@@ -55,14 +55,14 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void type() throws JedisException {
|
||||
public void type() {
|
||||
jedis.set("foo", "bar");
|
||||
String status = jedis.type("foo");
|
||||
assertEquals("string", status);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void keys() throws JedisException {
|
||||
public void keys() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.set("foobar", "bar");
|
||||
|
||||
@@ -79,7 +79,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void randomKey() throws JedisException {
|
||||
public void randomKey() {
|
||||
assertEquals(null, jedis.randomKey());
|
||||
|
||||
jedis.set("foo", "bar");
|
||||
@@ -93,7 +93,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rename() throws JedisException {
|
||||
public void rename() {
|
||||
jedis.set("foo", "bar");
|
||||
String status = jedis.rename("foo", "bar");
|
||||
assertEquals("OK", status);
|
||||
@@ -106,13 +106,13 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void renameOldAndNewAreTheSame() throws JedisException {
|
||||
public void renameOldAndNewAreTheSame() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.rename("foo", "foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void renamenx() throws JedisException {
|
||||
public void renamenx() {
|
||||
jedis.set("foo", "bar");
|
||||
int status = jedis.renamenx("foo", "bar");
|
||||
assertEquals(1, status);
|
||||
@@ -123,7 +123,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void dbSize() throws JedisException {
|
||||
public void dbSize() {
|
||||
int size = jedis.dbSize();
|
||||
assertEquals(0, size);
|
||||
|
||||
@@ -133,7 +133,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expire() throws JedisException {
|
||||
public void expire() {
|
||||
int status = jedis.expire("foo", 20);
|
||||
assertEquals(0, status);
|
||||
|
||||
@@ -146,7 +146,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void expireAt() throws JedisException {
|
||||
public void expireAt() {
|
||||
long unixTime = (System.currentTimeMillis() / 1000L) + 20;
|
||||
|
||||
int status = jedis.expireAt("foo", unixTime);
|
||||
@@ -163,7 +163,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ttl() throws JedisException {
|
||||
public void ttl() {
|
||||
int ttl = jedis.ttl("foo");
|
||||
assertEquals(-1, ttl);
|
||||
|
||||
@@ -177,7 +177,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void select() throws JedisException {
|
||||
public void select() {
|
||||
jedis.set("foo", "bar");
|
||||
String status = jedis.select(1);
|
||||
assertEquals("OK", status);
|
||||
@@ -188,7 +188,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void move() throws JedisException {
|
||||
public void move() {
|
||||
int status = jedis.move("foo", 1);
|
||||
assertEquals(0, status);
|
||||
|
||||
@@ -202,7 +202,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flushDB() throws JedisException {
|
||||
public void flushDB() {
|
||||
jedis.set("foo", "bar");
|
||||
assertEquals(1, jedis.dbSize());
|
||||
jedis.set("bar", "foo");
|
||||
@@ -215,7 +215,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void flushAll() throws JedisException {
|
||||
public void flushAll() {
|
||||
jedis.set("foo", "bar");
|
||||
assertEquals(1, jedis.dbSize());
|
||||
jedis.set("bar", "foo");
|
||||
|
||||
@@ -2,11 +2,9 @@ package redis.clients.jedis.tests.commands;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class ConnectionHandlingCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void quit() throws JedisException {
|
||||
public void quit() {
|
||||
jedis.quit();
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,9 @@ import java.util.Map;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void hset() throws JedisException {
|
||||
public void hset() {
|
||||
int status = jedis.hset("foo", "bar", "car");
|
||||
assertEquals(1, status);
|
||||
status = jedis.hset("foo", "bar", "foo");
|
||||
@@ -20,7 +18,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hget() throws JedisException {
|
||||
public void hget() {
|
||||
jedis.hset("foo", "bar", "car");
|
||||
assertEquals(null, jedis.hget("bar", "foo"));
|
||||
assertEquals(null, jedis.hget("foo", "car"));
|
||||
@@ -28,7 +26,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hsetnx() throws JedisException {
|
||||
public void hsetnx() {
|
||||
int status = jedis.hsetnx("foo", "bar", "car");
|
||||
assertEquals(1, status);
|
||||
assertEquals("car", jedis.hget("foo", "bar"));
|
||||
@@ -43,7 +41,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hmset() throws JedisException {
|
||||
public void hmset() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -54,7 +52,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hmget() throws JedisException {
|
||||
public void hmget() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -70,7 +68,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hincrBy() throws JedisException {
|
||||
public void hincrBy() {
|
||||
int value = jedis.hincrBy("foo", "bar", 1);
|
||||
assertEquals(1, value);
|
||||
value = jedis.hincrBy("foo", "bar", -1);
|
||||
@@ -80,7 +78,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hexists() throws JedisException {
|
||||
public void hexists() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -92,7 +90,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hdel() throws JedisException {
|
||||
public void hdel() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -105,7 +103,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hlen() throws JedisException {
|
||||
public void hlen() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -116,7 +114,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hkeys() throws JedisException {
|
||||
public void hkeys() {
|
||||
Map<String, String> hash = new LinkedHashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -130,7 +128,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hvals() throws JedisException {
|
||||
public void hvals() {
|
||||
Map<String, String> hash = new LinkedHashMap<String, String>();
|
||||
hash.put("bar", "car");
|
||||
hash.put("car", "bar");
|
||||
@@ -144,7 +142,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hgetAll() throws JedisException {
|
||||
public void hgetAll() {
|
||||
Map<String, String> h = new HashMap<String, String>();
|
||||
h.put("bar", "car");
|
||||
h.put("car", "bar");
|
||||
|
||||
@@ -7,7 +7,7 @@ import org.junit.Before;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
||||
public class JedisCommandTestBase extends Assert {
|
||||
public abstract class JedisCommandTestBase extends Assert {
|
||||
|
||||
protected Jedis jedis;
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class ListCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void rpush() throws JedisException {
|
||||
public void rpush() {
|
||||
int size = jedis.rpush("foo", "bar");
|
||||
assertEquals(1, size);
|
||||
size = jedis.rpush("foo", "foo");
|
||||
@@ -18,7 +18,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lpush() throws JedisException {
|
||||
public void lpush() {
|
||||
int size = jedis.lpush("foo", "bar");
|
||||
assertEquals(1, size);
|
||||
size = jedis.lpush("foo", "foo");
|
||||
@@ -26,7 +26,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void llen() throws JedisException {
|
||||
public void llen() {
|
||||
assertEquals(0, jedis.llen("foo"));
|
||||
jedis.lpush("foo", "bar");
|
||||
jedis.lpush("foo", "car");
|
||||
@@ -34,13 +34,13 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void llenNotOnList() throws JedisException {
|
||||
public void llenNotOnList() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.llen("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lrange() throws JedisException {
|
||||
public void lrange() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -69,7 +69,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void ltrim() throws JedisException {
|
||||
public void ltrim() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
@@ -85,7 +85,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lindex() throws JedisException {
|
||||
public void lindex() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
@@ -102,7 +102,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lset() throws JedisException {
|
||||
public void lset() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
@@ -112,7 +112,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lrem() throws JedisException {
|
||||
public void lrem() {
|
||||
jedis.lpush("foo", "hello");
|
||||
jedis.lpush("foo", "hello");
|
||||
jedis.lpush("foo", "x");
|
||||
@@ -136,7 +136,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void lpop() throws JedisException {
|
||||
public void lpop() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -157,7 +157,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rpop() throws JedisException {
|
||||
public void rpop() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -178,7 +178,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void rpoplpush() throws JedisException {
|
||||
public void rpoplpush() {
|
||||
jedis.rpush("foo", "a");
|
||||
jedis.rpush("foo", "b");
|
||||
jedis.rpush("foo", "c");
|
||||
@@ -204,7 +204,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void blpop() throws JedisException {
|
||||
public void blpop() {
|
||||
List<String> result = jedis.blpop(2, "foo");
|
||||
assertNull(result);
|
||||
|
||||
@@ -226,7 +226,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void brpop() throws JedisException {
|
||||
public void brpop() {
|
||||
List<String> result = jedis.brpop(2, "foo");
|
||||
assertNull(result);
|
||||
|
||||
|
||||
@@ -5,11 +5,9 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
|
||||
public class SetCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void sadd() throws JedisException {
|
||||
public void sadd() {
|
||||
int status = jedis.sadd("foo", "a");
|
||||
assertEquals(1, status);
|
||||
|
||||
@@ -18,7 +16,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smembers() throws JedisException {
|
||||
public void smembers() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -32,7 +30,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void srem() throws JedisException {
|
||||
public void srem() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -50,7 +48,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void spop() throws JedisException {
|
||||
public void spop() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -64,7 +62,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void smove() throws JedisException {
|
||||
public void smove() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -88,7 +86,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void scard() throws JedisException {
|
||||
public void scard() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -101,7 +99,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sismember() throws JedisException {
|
||||
public void sismember() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -113,7 +111,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sinter() throws JedisException {
|
||||
public void sinter() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -128,7 +126,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sinterstore() throws JedisException {
|
||||
public void sinterstore() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -145,7 +143,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sunion() throws JedisException {
|
||||
public void sunion() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -162,7 +160,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sunionstore() throws JedisException {
|
||||
public void sunionstore() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
@@ -181,7 +179,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sdiff() throws JedisException {
|
||||
public void sdiff() {
|
||||
jedis.sadd("foo", "x");
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
@@ -201,7 +199,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sdiffstore() throws JedisException {
|
||||
public void sdiffstore() {
|
||||
jedis.sadd("foo", "x");
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
@@ -222,7 +220,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void srandmember() throws JedisException {
|
||||
public void srandmember() {
|
||||
jedis.sadd("foo", "a");
|
||||
jedis.sadd("foo", "b");
|
||||
|
||||
|
||||
@@ -5,12 +5,11 @@ import java.util.Set;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Tuple;
|
||||
|
||||
public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void zadd() throws JedisException {
|
||||
public void zadd() {
|
||||
int status = jedis.zadd("foo", 1d, "a");
|
||||
assertEquals(1, status);
|
||||
|
||||
@@ -25,7 +24,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrange() throws JedisException {
|
||||
public void zrange() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -44,7 +43,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrevrange() throws JedisException {
|
||||
public void zrevrange() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -63,7 +62,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrem() throws JedisException {
|
||||
public void zrem() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -81,7 +80,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zincrby() throws JedisException {
|
||||
public void zincrby() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -96,7 +95,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrank() throws JedisException {
|
||||
public void zrank() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -108,7 +107,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrevrank() throws JedisException {
|
||||
public void zrevrank() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 2d, "b");
|
||||
|
||||
@@ -120,7 +119,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrangeWithScores() throws JedisException {
|
||||
public void zrangeWithScores() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -139,7 +138,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zrevrangeWithScores() throws JedisException {
|
||||
public void zrevrangeWithScores() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -158,7 +157,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zcard() throws JedisException {
|
||||
public void zcard() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
@@ -169,7 +168,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void zscore() throws JedisException {
|
||||
public void zscore() {
|
||||
jedis.zadd("foo", 1d, "a");
|
||||
jedis.zadd("foo", 10d, "b");
|
||||
jedis.zadd("foo", 0.1d, "c");
|
||||
|
||||
@@ -5,12 +5,11 @@ import java.util.List;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.SortingParams;
|
||||
|
||||
public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void sort() throws JedisException {
|
||||
public void sort() {
|
||||
jedis.lpush("foo", "3");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "1");
|
||||
@@ -26,7 +25,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortBy() throws JedisException {
|
||||
public void sortBy() {
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "3");
|
||||
jedis.lpush("foo", "1");
|
||||
@@ -49,7 +48,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortDesc() throws JedisException {
|
||||
public void sortDesc() {
|
||||
jedis.lpush("foo", "3");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "1");
|
||||
@@ -68,7 +67,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortLimit() throws JedisException {
|
||||
public void sortLimit() {
|
||||
for (int n = 10; n > 0; n--) {
|
||||
jedis.lpush("foo", String.valueOf(n));
|
||||
}
|
||||
@@ -87,7 +86,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortAlpha() throws JedisException {
|
||||
public void sortAlpha() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "10");
|
||||
@@ -106,7 +105,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortGet() throws JedisException {
|
||||
public void sortGet() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "10");
|
||||
@@ -136,7 +135,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void sortStore() throws JedisException {
|
||||
public void sortStore() {
|
||||
jedis.lpush("foo", "1");
|
||||
jedis.lpush("foo", "2");
|
||||
jedis.lpush("foo", "10");
|
||||
|
||||
@@ -9,7 +9,7 @@ import redis.clients.jedis.JedisException;
|
||||
|
||||
public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void setAndGet() throws JedisException {
|
||||
public void setAndGet() {
|
||||
String status = jedis.set("foo", "bar");
|
||||
assertEquals("OK", status);
|
||||
|
||||
@@ -20,7 +20,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getSet() throws JedisException {
|
||||
public void getSet() {
|
||||
String value = jedis.getSet("foo", "bar");
|
||||
assertEquals(null, value);
|
||||
value = jedis.get("foo");
|
||||
@@ -28,7 +28,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mget() throws JedisException {
|
||||
public void mget() {
|
||||
List<String> values = jedis.mget("foo", "bar");
|
||||
List<String> expected = new ArrayList<String>();
|
||||
expected.add(null);
|
||||
@@ -56,7 +56,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setnx() throws JedisException {
|
||||
public void setnx() {
|
||||
int status = jedis.setnx("foo", "bar");
|
||||
assertEquals(1, status);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -67,7 +67,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setex() throws JedisException {
|
||||
public void setex() {
|
||||
String status = jedis.setex("foo", 20, "bar");
|
||||
assertEquals("OK", status);
|
||||
int ttl = jedis.ttl("foo");
|
||||
@@ -75,7 +75,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void mset() throws JedisException {
|
||||
public void mset() {
|
||||
String status = jedis.mset("foo", "bar", "bar", "foo");
|
||||
assertEquals("OK", status);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -83,7 +83,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void msetnx() throws JedisException {
|
||||
public void msetnx() {
|
||||
int status = jedis.msetnx("foo", "bar", "bar", "foo");
|
||||
assertEquals(1, status);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -96,13 +96,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void incrWrongValue() throws JedisException {
|
||||
public void incrWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.incr("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incr() throws JedisException {
|
||||
public void incr() {
|
||||
int value = jedis.incr("foo");
|
||||
assertEquals(1, value);
|
||||
value = jedis.incr("foo");
|
||||
@@ -110,13 +110,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void incrByWrongValue() throws JedisException {
|
||||
public void incrByWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.incrBy("foo", 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incrBy() throws JedisException {
|
||||
public void incrBy() {
|
||||
int value = jedis.incrBy("foo", 2);
|
||||
assertEquals(2, value);
|
||||
value = jedis.incrBy("foo", 2);
|
||||
@@ -124,13 +124,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void decrWrongValue() throws JedisException {
|
||||
public void decrWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.decr("foo");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decr() throws JedisException {
|
||||
public void decr() {
|
||||
int value = jedis.decr("foo");
|
||||
assertEquals(-1, value);
|
||||
value = jedis.decr("foo");
|
||||
@@ -138,13 +138,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test(expected = JedisException.class)
|
||||
public void decrByWrongValue() throws JedisException {
|
||||
public void decrByWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.decrBy("foo", 2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decrBy() throws JedisException {
|
||||
public void decrBy() {
|
||||
int value = jedis.decrBy("foo", 2);
|
||||
assertEquals(-2, value);
|
||||
value = jedis.decrBy("foo", 2);
|
||||
@@ -152,7 +152,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void append() throws JedisException {
|
||||
public void append() {
|
||||
int value = jedis.append("foo", "bar");
|
||||
assertEquals(3, value);
|
||||
assertEquals("bar", jedis.get("foo"));
|
||||
@@ -162,7 +162,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void substr() throws JedisException {
|
||||
public void substr() {
|
||||
jedis.set("s", "This is a string");
|
||||
assertEquals("This", jedis.substr("s", 0, 3));
|
||||
assertEquals("ing", jedis.substr("s", -3, -1));
|
||||
|
||||
@@ -8,13 +8,12 @@ import java.util.List;
|
||||
import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.Jedis;
|
||||
import redis.clients.jedis.JedisException;
|
||||
import redis.clients.jedis.Transaction;
|
||||
import redis.clients.jedis.TransactionBlock;
|
||||
|
||||
public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
@Test
|
||||
public void multi() throws JedisException {
|
||||
public void multi() {
|
||||
Transaction trans = jedis.multi();
|
||||
|
||||
String status = trans.sadd("foo", "a");
|
||||
@@ -36,9 +35,9 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void multiBlock() throws JedisException {
|
||||
public void multiBlock() {
|
||||
List<Object> response = jedis.multi(new TransactionBlock() {
|
||||
public void execute() throws JedisException {
|
||||
public void execute() {
|
||||
String status = sadd("foo", "a");
|
||||
assertEquals("QUEUED", status);
|
||||
|
||||
@@ -58,8 +57,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void watch() throws JedisException, UnknownHostException,
|
||||
IOException {
|
||||
public void watch() throws UnknownHostException, IOException {
|
||||
jedis.watch("mykey");
|
||||
String val = jedis.get("mykey");
|
||||
val = "foo";
|
||||
@@ -77,8 +75,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void unwatch() throws JedisException, UnknownHostException,
|
||||
IOException {
|
||||
public void unwatch() throws UnknownHostException, IOException {
|
||||
jedis.watch("mykey");
|
||||
String val = jedis.get("mykey");
|
||||
val = "foo";
|
||||
|
||||
Reference in New Issue
Block a user