New exception management. Less exceptions... assume everything works

This commit is contained in:
Jonathan Leibiusky
2010-08-04 20:15:08 -03:00
parent b58ae0692c
commit 1df234153b
19 changed files with 399 additions and 454 deletions

View File

@@ -14,147 +14,143 @@ public class Client extends Connection {
super(host, port); super(host, port);
} }
public void ping() throws JedisException { public void ping() {
sendCommand("PING"); sendCommand("PING");
} }
public void set(String key, String value) throws JedisException { public void set(String key, String value) {
sendCommand("SET", key, value); sendCommand("SET", key, value);
} }
public void get(String key) throws JedisException { public void get(String key) {
sendCommand("GET", key); sendCommand("GET", key);
} }
public void quit() throws JedisException { public void quit() {
sendCommand("QUIT"); sendCommand("QUIT");
} }
public void exists(String key) throws JedisException { public void exists(String key) {
sendCommand("EXISTS", key); sendCommand("EXISTS", key);
} }
public void del(String... keys) throws JedisException { public void del(String... keys) {
sendCommand("DEL", keys); sendCommand("DEL", keys);
} }
public void type(String key) throws JedisException { public void type(String key) {
sendCommand("TYPE", key); sendCommand("TYPE", key);
} }
public void flushDB() throws JedisException { public void flushDB() {
sendCommand("FLUSHDB"); sendCommand("FLUSHDB");
} }
public void keys(String pattern) throws JedisException { public void keys(String pattern) {
sendCommand("KEYS", pattern); sendCommand("KEYS", pattern);
} }
public void randomKey() throws JedisException { public void randomKey() {
sendCommand("RANDOMKEY"); sendCommand("RANDOMKEY");
} }
public void rename(String oldkey, String newkey) throws JedisException { public void rename(String oldkey, String newkey) {
sendCommand("RENAME", oldkey, newkey); sendCommand("RENAME", oldkey, newkey);
} }
public void renamenx(String oldkey, String newkey) throws JedisException { public void renamenx(String oldkey, String newkey) {
sendCommand("RENAMENX", oldkey, newkey); sendCommand("RENAMENX", oldkey, newkey);
} }
public void dbSize() throws JedisException { public void dbSize() {
sendCommand("DBSIZE"); sendCommand("DBSIZE");
} }
public void expire(String key, int seconds) throws JedisException { public void expire(String key, int seconds) {
sendCommand("EXPIRE", key, String.valueOf(seconds)); sendCommand("EXPIRE", key, String.valueOf(seconds));
} }
public void expireAt(String key, long unixTime) throws JedisException { public void expireAt(String key, long unixTime) {
sendCommand("EXPIREAT", key, String.valueOf(unixTime)); sendCommand("EXPIREAT", key, String.valueOf(unixTime));
} }
public void ttl(String key) throws JedisException { public void ttl(String key) {
sendCommand("TTL", key); sendCommand("TTL", key);
} }
public void select(int index) throws JedisException { public void select(int index) {
sendCommand("SELECT", String.valueOf(index)); sendCommand("SELECT", String.valueOf(index));
} }
public void move(String key, int dbIndex) throws JedisException { public void move(String key, int dbIndex) {
sendCommand("MOVE", key, String.valueOf(dbIndex)); sendCommand("MOVE", key, String.valueOf(dbIndex));
} }
public void flushAll() throws JedisException { public void flushAll() {
sendCommand("FLUSHALL"); sendCommand("FLUSHALL");
} }
public void getSet(String key, String value) throws JedisException { public void getSet(String key, String value) {
sendCommand("GETSET", key, value); sendCommand("GETSET", key, value);
} }
public void mget(String... keys) throws JedisException { public void mget(String... keys) {
sendCommand("MGET", keys); sendCommand("MGET", keys);
} }
public void setnx(String key, String value) throws JedisException { public void setnx(String key, String value) {
sendCommand("SETNX", key, value); sendCommand("SETNX", key, value);
} }
public void setex(String key, int seconds, String value) public void setex(String key, int seconds, String value) {
throws JedisException {
sendCommand("SETEX", key, String.valueOf(seconds), value); sendCommand("SETEX", key, String.valueOf(seconds), value);
} }
public void mset(String... keysvalues) throws JedisException { public void mset(String... keysvalues) {
sendCommand("MSET", keysvalues); sendCommand("MSET", keysvalues);
} }
public void msetnx(String... keysvalues) throws JedisException { public void msetnx(String... keysvalues) {
sendCommand("MSETNX", keysvalues); sendCommand("MSETNX", keysvalues);
} }
public void decrBy(String key, int integer) throws JedisException { public void decrBy(String key, int integer) {
sendCommand("DECRBY", key, String.valueOf(integer)); sendCommand("DECRBY", key, String.valueOf(integer));
} }
public void decr(String key) throws JedisException { public void decr(String key) {
sendCommand("DECR", key); sendCommand("DECR", key);
} }
public void incrBy(String key, int integer) throws JedisException { public void incrBy(String key, int integer) {
sendCommand("INCRBY", key, String.valueOf(integer)); sendCommand("INCRBY", key, String.valueOf(integer));
} }
public void incr(String key) throws JedisException { public void incr(String key) {
sendCommand("INCR", key); sendCommand("INCR", key);
} }
public void append(String key, String value) throws JedisException { public void append(String key, String value) {
sendCommand("APPEND", key, value); sendCommand("APPEND", key, value);
} }
public void substr(String key, int start, int end) throws JedisException { public void substr(String key, int start, int end) {
sendCommand("SUBSTR", key, String.valueOf(start), String.valueOf(end)); sendCommand("SUBSTR", key, String.valueOf(start), String.valueOf(end));
} }
public void hset(String key, String field, String value) public void hset(String key, String field, String value) {
throws JedisException {
sendCommand("HSET", key, field, value); sendCommand("HSET", key, field, value);
} }
public void hget(String key, String field) throws JedisException { public void hget(String key, String field) {
sendCommand("HGET", key, field); sendCommand("HGET", key, field);
} }
public void hsetnx(String key, String field, String value) public void hsetnx(String key, String field, String value) {
throws JedisException {
sendCommand("HSETNX", key, field, value); sendCommand("HSETNX", key, field, value);
} }
public void hmset(String key, Map<String, String> hash) public void hmset(String key, Map<String, String> hash) {
throws JedisException {
List<String> params = new ArrayList<String>(); List<String> params = new ArrayList<String>();
params.add(key); params.add(key);
@@ -165,243 +161,233 @@ public class Client extends Connection {
sendCommand("HMSET", params.toArray(new String[params.size()])); sendCommand("HMSET", params.toArray(new String[params.size()]));
} }
public void hmget(String key, String... fields) throws JedisException { public void hmget(String key, String... fields) {
String[] params = new String[fields.length + 1]; String[] params = new String[fields.length + 1];
params[0] = key; params[0] = key;
System.arraycopy(fields, 0, params, 1, fields.length); System.arraycopy(fields, 0, params, 1, fields.length);
sendCommand("HMGET", params); sendCommand("HMGET", params);
} }
public void hincrBy(String key, String field, int value) public void hincrBy(String key, String field, int value) {
throws JedisException {
sendCommand("HINCRBY", key, field, String.valueOf(value)); sendCommand("HINCRBY", key, field, String.valueOf(value));
} }
public void hexists(String key, String field) throws JedisException { public void hexists(String key, String field) {
sendCommand("HEXISTS", key, field); sendCommand("HEXISTS", key, field);
} }
public void hdel(String key, String field) throws JedisException { public void hdel(String key, String field) {
sendCommand("HDEL", key, field); sendCommand("HDEL", key, field);
} }
public void hlen(String key) throws JedisException { public void hlen(String key) {
sendCommand("HLEN", key); sendCommand("HLEN", key);
} }
public void hkeys(String key) throws JedisException { public void hkeys(String key) {
sendCommand("HKEYS", key); sendCommand("HKEYS", key);
} }
public void hvals(String key) throws JedisException { public void hvals(String key) {
sendCommand("HVALS", key); sendCommand("HVALS", key);
} }
public void hgetAll(String key) throws JedisException { public void hgetAll(String key) {
sendCommand("HGETALL", key); sendCommand("HGETALL", key);
} }
public void rpush(String key, String string) throws JedisException { public void rpush(String key, String string) {
sendCommand("RPUSH", key, string); sendCommand("RPUSH", key, string);
} }
public void lpush(String key, String string) throws JedisException { public void lpush(String key, String string) {
sendCommand("LPUSH", key, string); sendCommand("LPUSH", key, string);
} }
public void llen(String key) throws JedisException { public void llen(String key) {
sendCommand("LLEN", key); sendCommand("LLEN", key);
} }
public void lrange(String key, int start, int end) throws JedisException { public void lrange(String key, int start, int end) {
sendCommand("LRANGE", key, String.valueOf(start), String.valueOf(end)); sendCommand("LRANGE", key, String.valueOf(start), String.valueOf(end));
} }
public void ltrim(String key, int start, int end) throws JedisException { public void ltrim(String key, int start, int end) {
sendCommand("LTRIM", key, String.valueOf(start), String.valueOf(end)); sendCommand("LTRIM", key, String.valueOf(start), String.valueOf(end));
} }
public void lindex(String key, int index) throws JedisException { public void lindex(String key, int index) {
sendCommand("LINDEX", key, String.valueOf(index)); sendCommand("LINDEX", key, String.valueOf(index));
} }
public void lset(String key, int index, String value) throws JedisException { public void lset(String key, int index, String value) {
sendCommand("LSET", key, String.valueOf(index), value); sendCommand("LSET", key, String.valueOf(index), value);
} }
public void lrem(String key, int count, String value) throws JedisException { public void lrem(String key, int count, String value) {
sendCommand("LREM", key, String.valueOf(count), value); sendCommand("LREM", key, String.valueOf(count), value);
} }
public void lpop(String key) throws JedisException { public void lpop(String key) {
sendCommand("LPOP", key); sendCommand("LPOP", key);
} }
public void rpop(String key) throws JedisException { public void rpop(String key) {
sendCommand("RPOP", key); sendCommand("RPOP", key);
} }
public void rpoplpush(String srckey, String dstkey) throws JedisException { public void rpoplpush(String srckey, String dstkey) {
sendCommand("RPOPLPUSH", srckey, dstkey); sendCommand("RPOPLPUSH", srckey, dstkey);
} }
public void sadd(String key, String member) throws JedisException { public void sadd(String key, String member) {
sendCommand("SADD", key, member); sendCommand("SADD", key, member);
} }
public void smembers(String key) throws JedisException { public void smembers(String key) {
sendCommand("SMEMBERS", key); sendCommand("SMEMBERS", key);
} }
public void srem(String key, String member) throws JedisException { public void srem(String key, String member) {
sendCommand("SREM", key, member); sendCommand("SREM", key, member);
} }
public void spop(String key) throws JedisException { public void spop(String key) {
sendCommand("SPOP", key); sendCommand("SPOP", key);
} }
public void smove(String srckey, String dstkey, String member) public void smove(String srckey, String dstkey, String member) {
throws JedisException {
sendCommand("SMOVE", srckey, dstkey, member); sendCommand("SMOVE", srckey, dstkey, member);
} }
public void scard(String key) throws JedisException { public void scard(String key) {
sendCommand("SCARD", key); sendCommand("SCARD", key);
} }
public void sismember(String key, String member) throws JedisException { public void sismember(String key, String member) {
sendCommand("SISMEMBER", key, member); sendCommand("SISMEMBER", key, member);
} }
public void sinter(String... keys) throws JedisException { public void sinter(String... keys) {
sendCommand("SINTER", keys); sendCommand("SINTER", keys);
} }
public void sinterstore(String dstkey, String... keys) public void sinterstore(String dstkey, String... keys) {
throws JedisException {
String[] params = new String[keys.length + 1]; String[] params = new String[keys.length + 1];
params[0] = dstkey; params[0] = dstkey;
System.arraycopy(keys, 0, params, 1, keys.length); System.arraycopy(keys, 0, params, 1, keys.length);
sendCommand("SINTERSTORE", params); sendCommand("SINTERSTORE", params);
} }
public void sunion(String... keys) throws JedisException { public void sunion(String... keys) {
sendCommand("SUNION", keys); sendCommand("SUNION", keys);
} }
public void sunionstore(String dstkey, String... keys) public void sunionstore(String dstkey, String... keys) {
throws JedisException {
String[] params = new String[keys.length + 1]; String[] params = new String[keys.length + 1];
params[0] = dstkey; params[0] = dstkey;
System.arraycopy(keys, 0, params, 1, keys.length); System.arraycopy(keys, 0, params, 1, keys.length);
sendCommand("SUNIONSTORE", params); sendCommand("SUNIONSTORE", params);
} }
public void sdiff(String... keys) throws JedisException { public void sdiff(String... keys) {
sendCommand("SDIFF", keys); sendCommand("SDIFF", keys);
} }
public void sdiffstore(String dstkey, String... keys) throws JedisException { public void sdiffstore(String dstkey, String... keys) {
String[] params = new String[keys.length + 1]; String[] params = new String[keys.length + 1];
params[0] = dstkey; params[0] = dstkey;
System.arraycopy(keys, 0, params, 1, keys.length); System.arraycopy(keys, 0, params, 1, keys.length);
sendCommand("SDIFFSTORE", params); sendCommand("SDIFFSTORE", params);
} }
public void srandmember(String key) throws JedisException { public void srandmember(String key) {
sendCommand("SRANDMEMBER", key); sendCommand("SRANDMEMBER", key);
} }
public void zadd(String key, double score, String member) public void zadd(String key, double score, String member) {
throws JedisException {
sendCommand("ZADD", key, String.valueOf(score), member); sendCommand("ZADD", key, String.valueOf(score), member);
} }
public void zrange(String key, int start, int end) throws JedisException { public void zrange(String key, int start, int end) {
sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end)); sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end));
} }
public void zrem(String key, String member) throws JedisException { public void zrem(String key, String member) {
sendCommand("ZREM", key, member); sendCommand("ZREM", key, member);
} }
public void zincrby(String key, double score, String member) public void zincrby(String key, double score, String member) {
throws JedisException {
sendCommand("ZINCRBY", key, String.valueOf(score), member); sendCommand("ZINCRBY", key, String.valueOf(score), member);
} }
public void zrank(String key, String member) throws JedisException { public void zrank(String key, String member) {
sendCommand("ZRANK", key, member); sendCommand("ZRANK", key, member);
} }
public void zrevrank(String key, String member) throws JedisException { public void zrevrank(String key, String member) {
sendCommand("ZREVRANK", key, member); sendCommand("ZREVRANK", key, member);
} }
public void zrevrange(String key, int start, int end) throws JedisException { public void zrevrange(String key, int start, int end) {
sendCommand("ZREVRANGE", key, String.valueOf(start), String sendCommand("ZREVRANGE", key, String.valueOf(start), String
.valueOf(end)); .valueOf(end));
} }
public void zrangeWithScores(String key, int start, int end) public void zrangeWithScores(String key, int start, int end) {
throws JedisException {
sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end), sendCommand("ZRANGE", key, String.valueOf(start), String.valueOf(end),
"WITHSCORES"); "WITHSCORES");
} }
public void zrevrangeWithScores(String key, int start, int end) public void zrevrangeWithScores(String key, int start, int end) {
throws JedisException {
sendCommand("ZREVRANGE", key, String.valueOf(start), String sendCommand("ZREVRANGE", key, String.valueOf(start), String
.valueOf(end), "WITHSCORES"); .valueOf(end), "WITHSCORES");
} }
public void zcard(String key) throws JedisException { public void zcard(String key) {
sendCommand("ZCARD", key); sendCommand("ZCARD", key);
} }
public void zscore(String key, String member) throws JedisException { public void zscore(String key, String member) {
sendCommand("ZSCORE", key, member); sendCommand("ZSCORE", key, member);
} }
public void multi() throws JedisException { public void multi() {
sendCommand("MULTI"); sendCommand("MULTI");
} }
public void discard() throws JedisException { public void discard() {
sendCommand("MULTI"); sendCommand("MULTI");
} }
public void exec() throws JedisException { public void exec() {
sendCommand("EXEC"); sendCommand("EXEC");
} }
public void watch(String key) throws JedisException { public void watch(String key) {
sendCommand("WATCH", key); sendCommand("WATCH", key);
} }
public void unwatch() throws JedisException { public void unwatch() {
sendCommand("UNWATCH"); sendCommand("UNWATCH");
} }
public void sort(String key) throws JedisException { public void sort(String key) {
sendCommand("SORT", key); sendCommand("SORT", key);
} }
public void sort(String key, SortingParams sortingParameters) public void sort(String key, SortingParams sortingParameters) {
throws JedisException {
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>();
args.add(key); args.add(key);
args.addAll(sortingParameters.getParams()); args.addAll(sortingParameters.getParams());
sendCommand("SORT", args.toArray(new String[args.size()])); sendCommand("SORT", args.toArray(new String[args.size()]));
} }
public void blpop(String[] args) throws JedisException { public void blpop(String[] args) {
sendCommand("BLPOP", args); sendCommand("BLPOP", args);
} }
public void sort(String key, SortingParams sortingParameters, String dstkey) public void sort(String key, SortingParams sortingParameters, String dstkey) {
throws JedisException {
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>();
args.add(key); args.add(key);
args.addAll(sortingParameters.getParams()); args.addAll(sortingParameters.getParams());
@@ -410,15 +396,15 @@ public class Client extends Connection {
sendCommand("SORT", args.toArray(new String[args.size()])); sendCommand("SORT", args.toArray(new String[args.size()]));
} }
public void sort(String key, String dstkey) throws JedisException { public void sort(String key, String dstkey) {
sendCommand("SORT", key, "STORE", dstkey); sendCommand("SORT", key, "STORE", dstkey);
} }
public void brpop(String[] args) throws JedisException { public void brpop(String[] args) {
sendCommand("BRPOP", args); sendCommand("BRPOP", args);
} }
public void auth(String password) throws JedisException { public void auth(String password) {
sendCommand("AUTH", password); sendCommand("AUTH", password);
} }
} }

View File

@@ -21,8 +21,7 @@ public class Connection {
this.host = host; this.host = host;
} }
protected Connection sendCommand(String name, String... args) protected Connection sendCommand(String name, String... args) {
throws JedisException {
if (!isConnected()) { if (!isConnected()) {
throw new JedisException("Please connect Jedis before using it."); throw new JedisException("Please connect Jedis before using it.");
} }
@@ -79,24 +78,24 @@ public class Connection {
return connected; return connected;
} }
protected String getStatusCodeReply() throws JedisException { protected String getStatusCodeReply() {
return protocol.getStatusCodeReply(inputStream); return protocol.getStatusCodeReply(inputStream);
} }
public String getBulkReply() throws JedisException { public String getBulkReply() {
return protocol.getBulkReply(inputStream); return protocol.getBulkReply(inputStream);
} }
public int getIntegerReply() throws JedisException { public int getIntegerReply() {
return protocol.getIntegerReply(inputStream); return protocol.getIntegerReply(inputStream);
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<String> getMultiBulkReply() throws JedisException { public List<String> getMultiBulkReply() {
return (List<String>) (List<?>) protocol.getMultiBulkReply(inputStream); return (List<String>) (List<?>) protocol.getMultiBulkReply(inputStream);
} }
public List<Object> getObjectMultiBulkReply() throws JedisException { public List<Object> getObjectMultiBulkReply() {
return protocol.getMultiBulkReply(inputStream); return protocol.getMultiBulkReply(inputStream);
} }

View File

@@ -21,222 +21,216 @@ public class Jedis {
client = new Client(host, port); client = new Client(host, port);
} }
public String ping() throws JedisException { public String ping() {
client.ping(); client.ping();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String set(String key, String value) throws JedisException { public String set(String key, String value) {
client.set(key, value); client.set(key, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String get(String key) throws JedisException { public String get(String key) {
client.sendCommand("GET", key); client.sendCommand("GET", key);
return client.getBulkReply(); return client.getBulkReply();
} }
public void quit() throws JedisException { public void quit() {
client.quit(); client.quit();
} }
public int exists(String key) throws JedisException { public int exists(String key) {
client.exists(key); client.exists(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int del(String... keys) throws JedisException { public int del(String... keys) {
client.del(keys); client.del(keys);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String type(String key) throws JedisException { public String type(String key) {
client.type(key); client.type(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String flushDB() throws JedisException { public String flushDB() {
client.flushDB(); client.flushDB();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public List<String> keys(String pattern) throws JedisException { public List<String> keys(String pattern) {
client.keys(pattern); client.keys(pattern);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public String randomKey() throws JedisException { public String randomKey() {
client.randomKey(); client.randomKey();
return client.getBulkReply(); return client.getBulkReply();
} }
public String rename(String oldkey, String newkey) throws JedisException { public String rename(String oldkey, String newkey) {
client.rename(oldkey, newkey); client.rename(oldkey, newkey);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int renamenx(String oldkey, String newkey) throws JedisException { public int renamenx(String oldkey, String newkey) {
client.renamenx(oldkey, newkey); client.renamenx(oldkey, newkey);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int dbSize() throws JedisException { public int dbSize() {
client.dbSize(); client.dbSize();
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int expire(String key, int seconds) throws JedisException { public int expire(String key, int seconds) {
client.expire(key, seconds); client.expire(key, seconds);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int expireAt(String key, long unixTime) throws JedisException { public int expireAt(String key, long unixTime) {
client.expireAt(key, unixTime); client.expireAt(key, unixTime);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int ttl(String key) throws JedisException { public int ttl(String key) {
client.ttl(key); client.ttl(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String select(int index) throws JedisException { public String select(int index) {
client.select(index); client.select(index);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int move(String key, int dbIndex) throws JedisException { public int move(String key, int dbIndex) {
client.move(key, dbIndex); client.move(key, dbIndex);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String flushAll() throws JedisException { public String flushAll() {
client.flushAll(); client.flushAll();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String getSet(String key, String value) throws JedisException { public String getSet(String key, String value) {
client.getSet(key, value); client.getSet(key, value);
return client.getBulkReply(); return client.getBulkReply();
} }
public List<String> mget(String... keys) throws JedisException { public List<String> mget(String... keys) {
client.mget(keys); client.mget(keys);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public int setnx(String key, String value) throws JedisException { public int setnx(String key, String value) {
client.setnx(key, value); client.setnx(key, value);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String setex(String key, int seconds, String value) public String setex(String key, int seconds, String value) {
throws JedisException {
client.setex(key, seconds, value); client.setex(key, seconds, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String mset(String... keysvalues) throws JedisException { public String mset(String... keysvalues) {
client.mset(keysvalues); client.mset(keysvalues);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int msetnx(String... keysvalues) throws JedisException { public int msetnx(String... keysvalues) {
client.msetnx(keysvalues); client.msetnx(keysvalues);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int decrBy(String key, int integer) throws JedisException { public int decrBy(String key, int integer) {
client.decrBy(key, integer); client.decrBy(key, integer);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int decr(String key) throws JedisException { public int decr(String key) {
client.decr(key); client.decr(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int incrBy(String key, int integer) throws JedisException { public int incrBy(String key, int integer) {
client.incrBy(key, integer); client.incrBy(key, integer);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int incr(String key) throws JedisException { public int incr(String key) {
client.incr(key); client.incr(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int append(String key, String value) throws JedisException { public int append(String key, String value) {
client.append(key, value); client.append(key, value);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String substr(String key, int start, int end) throws JedisException { public String substr(String key, int start, int end) {
client.substr(key, start, end); client.substr(key, start, end);
return client.getBulkReply(); return client.getBulkReply();
} }
public int hset(String key, String field, String value) public int hset(String key, String field, String value) {
throws JedisException {
client.hset(key, field, value); client.hset(key, field, value);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String hget(String key, String field) throws JedisException { public String hget(String key, String field) {
client.hget(key, field); client.hget(key, field);
return client.getBulkReply(); return client.getBulkReply();
} }
public int hsetnx(String key, String field, String value) public int hsetnx(String key, String field, String value) {
throws JedisException {
client.hsetnx(key, field, value); client.hsetnx(key, field, value);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String hmset(String key, Map<String, String> hash) public String hmset(String key, Map<String, String> hash) {
throws JedisException {
client.hmset(key, hash); client.hmset(key, hash);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public List<String> hmget(String key, String... fields) public List<String> hmget(String key, String... fields) {
throws JedisException {
client.hmget(key, fields); client.hmget(key, fields);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public int hincrBy(String key, String field, int value) public int hincrBy(String key, String field, int value) {
throws JedisException {
client.hincrBy(key, field, value); client.hincrBy(key, field, value);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int hexists(String key, String field) throws JedisException { public int hexists(String key, String field) {
client.hexists(key, field); client.hexists(key, field);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int hdel(String key, String field) throws JedisException { public int hdel(String key, String field) {
client.hdel(key, field); client.hdel(key, field);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int hlen(String key) throws JedisException { public int hlen(String key) {
client.hlen(key); client.hlen(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public List<String> hkeys(String key) throws JedisException { public List<String> hkeys(String key) {
client.hkeys(key); client.hkeys(key);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public List<String> hvals(String key) throws JedisException { public List<String> hvals(String key) {
client.hvals(key); client.hvals(key);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public Map<String, String> hgetAll(String key) throws JedisException { public Map<String, String> hgetAll(String key) {
client.hgetAll(key); client.hgetAll(key);
List<String> flatHash = client.getMultiBulkReply(); List<String> flatHash = client.getMultiBulkReply();
Map<String, String> hash = new HashMap<String, String>(); Map<String, String> hash = new HashMap<String, String>();
@@ -248,182 +242,174 @@ public class Jedis {
return hash; return hash;
} }
public int rpush(String key, String string) throws JedisException { public int rpush(String key, String string) {
client.rpush(key, string); client.rpush(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int lpush(String key, String string) throws JedisException { public int lpush(String key, String string) {
client.lpush(key, string); client.lpush(key, string);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int llen(String key) throws JedisException { public int llen(String key) {
client.llen(key); client.llen(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public List<String> lrange(String key, int start, int end) public List<String> lrange(String key, int start, int end) {
throws JedisException {
client.lrange(key, start, end); client.lrange(key, start, end);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public String ltrim(String key, int start, int end) throws JedisException { public String ltrim(String key, int start, int end) {
client.ltrim(key, start, end); client.ltrim(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String lindex(String key, int index) throws JedisException { public String lindex(String key, int index) {
client.lindex(key, index); client.lindex(key, index);
return client.getBulkReply(); return client.getBulkReply();
} }
public String lset(String key, int index, String value) public String lset(String key, int index, String value) {
throws JedisException {
client.lset(key, index, value); client.lset(key, index, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public int lrem(String key, int count, String value) throws JedisException { public int lrem(String key, int count, String value) {
client.lrem(key, count, value); client.lrem(key, count, value);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String lpop(String key) throws JedisException { public String lpop(String key) {
client.lpop(key); client.lpop(key);
return client.getBulkReply(); return client.getBulkReply();
} }
public String rpop(String key) throws JedisException { public String rpop(String key) {
client.rpop(key); client.rpop(key);
return client.getBulkReply(); return client.getBulkReply();
} }
public String rpoplpush(String srckey, String dstkey) throws JedisException { public String rpoplpush(String srckey, String dstkey) {
client.rpoplpush(srckey, dstkey); client.rpoplpush(srckey, dstkey);
return client.getBulkReply(); return client.getBulkReply();
} }
public int sadd(String key, String member) throws JedisException { public int sadd(String key, String member) {
client.sadd(key, member); client.sadd(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Set<String> smembers(String key) throws JedisException { public Set<String> smembers(String key) {
client.smembers(key); client.smembers(key);
List<String> members = client.getMultiBulkReply(); List<String> members = client.getMultiBulkReply();
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int srem(String key, String member) throws JedisException { public int srem(String key, String member) {
client.srem(key, member); client.srem(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String spop(String key) throws JedisException { public String spop(String key) {
client.spop(key); client.spop(key);
return client.getBulkReply(); return client.getBulkReply();
} }
public int smove(String srckey, String dstkey, String member) public int smove(String srckey, String dstkey, String member) {
throws JedisException {
client.smove(srckey, dstkey, member); client.smove(srckey, dstkey, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int scard(String key) throws JedisException { public int scard(String key) {
client.scard(key); client.scard(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int sismember(String key, String member) throws JedisException { public int sismember(String key, String member) {
client.sismember(key, member); client.sismember(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Set<String> sinter(String... keys) throws JedisException { public Set<String> sinter(String... keys) {
client.sinter(keys); client.sinter(keys);
List<String> members = client.getMultiBulkReply(); List<String> members = client.getMultiBulkReply();
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int sinterstore(String dstkey, String... keys) throws JedisException { public int sinterstore(String dstkey, String... keys) {
client.sinterstore(dstkey, keys); client.sinterstore(dstkey, keys);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Set<String> sunion(String... keys) throws JedisException { public Set<String> sunion(String... keys) {
client.sunion(keys); client.sunion(keys);
List<String> members = client.getMultiBulkReply(); List<String> members = client.getMultiBulkReply();
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int sunionstore(String dstkey, String... keys) throws JedisException { public int sunionstore(String dstkey, String... keys) {
client.sunionstore(dstkey, keys); client.sunionstore(dstkey, keys);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Set<String> sdiff(String... keys) throws JedisException { public Set<String> sdiff(String... keys) {
client.sdiff(keys); client.sdiff(keys);
List<String> members = client.getMultiBulkReply(); List<String> members = client.getMultiBulkReply();
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int sdiffstore(String dstkey, String... keys) throws JedisException { public int sdiffstore(String dstkey, String... keys) {
client.sdiffstore(dstkey, keys); client.sdiffstore(dstkey, keys);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public String srandmember(String key) throws JedisException { public String srandmember(String key) {
client.srandmember(key); client.srandmember(key);
return client.getBulkReply(); return client.getBulkReply();
} }
public int zadd(String key, double score, String member) public int zadd(String key, double score, String member) {
throws JedisException {
client.zadd(key, score, member); client.zadd(key, score, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Set<String> zrange(String key, int start, int end) public Set<String> zrange(String key, int start, int end) {
throws JedisException {
client.zrange(key, start, end); client.zrange(key, start, end);
List<String> members = client.getMultiBulkReply(); List<String> members = client.getMultiBulkReply();
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public int zrem(String key, String member) throws JedisException { public int zrem(String key, String member) {
client.zrem(key, member); client.zrem(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public double zincrby(String key, double score, String member) public double zincrby(String key, double score, String member) {
throws JedisException {
client.zincrby(key, score, member); client.zincrby(key, score, member);
String newscore = client.getBulkReply(); String newscore = client.getBulkReply();
return Double.valueOf(newscore); return Double.valueOf(newscore);
} }
public int zrank(String key, String member) throws JedisException { public int zrank(String key, String member) {
client.zrank(key, member); client.zrank(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int zrevrank(String key, String member) throws JedisException { public int zrevrank(String key, String member) {
client.zrevrank(key, member); client.zrevrank(key, member);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public Set<String> zrevrange(String key, int start, int end) public Set<String> zrevrange(String key, int start, int end) {
throws JedisException {
client.zrevrange(key, start, end); client.zrevrange(key, start, end);
List<String> members = client.getMultiBulkReply(); List<String> members = client.getMultiBulkReply();
return new LinkedHashSet<String>(members); return new LinkedHashSet<String>(members);
} }
public Set<Tuple> zrangeWithScores(String key, int start, int end) public Set<Tuple> zrangeWithScores(String key, int start, int end) {
throws JedisException {
client.zrangeWithScores(key, start, end); client.zrangeWithScores(key, start, end);
List<String> membersWithScores = client.getMultiBulkReply(); List<String> membersWithScores = client.getMultiBulkReply();
Set<Tuple> set = new LinkedHashSet<Tuple>(); Set<Tuple> set = new LinkedHashSet<Tuple>();
@@ -436,8 +422,7 @@ public class Jedis {
return set; return set;
} }
public Set<Tuple> zrevrangeWithScores(String key, int start, int end) public Set<Tuple> zrevrangeWithScores(String key, int start, int end) {
throws JedisException {
client.zrevrangeWithScores(key, start, end); client.zrevrangeWithScores(key, start, end);
List<String> membersWithScores = client.getMultiBulkReply(); List<String> membersWithScores = client.getMultiBulkReply();
Set<Tuple> set = new LinkedHashSet<Tuple>(); Set<Tuple> set = new LinkedHashSet<Tuple>();
@@ -450,25 +435,24 @@ public class Jedis {
return set; return set;
} }
public int zcard(String key) throws JedisException { public int zcard(String key) {
client.zcard(key); client.zcard(key);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public double zscore(String key, String member) throws JedisException { public double zscore(String key, String member) {
client.zscore(key, member); client.zscore(key, member);
String score = client.getBulkReply(); String score = client.getBulkReply();
return Double.valueOf(score); return Double.valueOf(score);
} }
public Transaction multi() throws JedisException { public Transaction multi() {
client.multi(); client.multi();
client.getStatusCodeReply(); client.getStatusCodeReply();
return new Transaction(client); return new Transaction(client);
} }
public List<Object> multi(TransactionBlock jedisTransaction) public List<Object> multi(TransactionBlock jedisTransaction) {
throws JedisException {
try { try {
jedisTransaction.setClient(client); jedisTransaction.setClient(client);
multi(); multi();
@@ -487,29 +471,27 @@ public class Jedis {
client.disconnect(); client.disconnect();
} }
public String watch(String key) throws JedisException { public String watch(String key) {
client.watch(key); client.watch(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String unwatch() throws JedisException { public String unwatch() {
client.unwatch(); client.unwatch();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public List<String> sort(String key) throws JedisException { public List<String> sort(String key) {
client.sort(key); client.sort(key);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public List<String> sort(String key, SortingParams sortingParameters) public List<String> sort(String key, SortingParams sortingParameters) {
throws JedisException {
client.sort(key, sortingParameters); client.sort(key, sortingParameters);
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public List<String> blpop(int timeout, String... keys) public List<String> blpop(int timeout, String... keys) {
throws JedisException {
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>();
for (String arg : keys) { for (String arg : keys) {
args.add(arg); args.add(arg);
@@ -520,19 +502,17 @@ public class Jedis {
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public int sort(String key, SortingParams sortingParameters, String dstkey) public int sort(String key, SortingParams sortingParameters, String dstkey) {
throws JedisException {
client.sort(key, sortingParameters, dstkey); client.sort(key, sortingParameters, dstkey);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public int sort(String key, String dstkey) throws JedisException { public int sort(String key, String dstkey) {
client.sort(key, dstkey); client.sort(key, dstkey);
return client.getIntegerReply(); return client.getIntegerReply();
} }
public List<String> brpop(int timeout, String... keys) public List<String> brpop(int timeout, String... keys) {
throws JedisException {
List<String> args = new ArrayList<String>(); List<String> args = new ArrayList<String>();
for (String arg : keys) { for (String arg : keys) {
args.add(arg); args.add(arg);
@@ -543,7 +523,7 @@ public class Jedis {
return client.getMultiBulkReply(); return client.getMultiBulkReply();
} }
public String auth(String password) throws JedisException { public String auth(String password) {
client.auth(password); client.auth(password);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }

View File

@@ -1,6 +1,8 @@
package redis.clients.jedis; package redis.clients.jedis;
public class JedisException extends Exception { import java.io.IOException;
public class JedisException extends RuntimeException {
/** /**
* *
*/ */
@@ -9,4 +11,8 @@ public class JedisException extends Exception {
public JedisException(String message) { public JedisException(String message) {
super(message); super(message);
} }
public JedisException(IOException e) {
super(e);
}
} }

View File

@@ -32,11 +32,11 @@ public class Protocol {
try { try {
os.write(builder.toString().getBytes()); os.write(builder.toString().getBytes());
} catch (IOException e) { } catch (IOException e) {
// TODO don't know what to do here! throw new JedisException(e);
} }
} }
public void processError(InputStream is) throws JedisException { public void processError(InputStream is) {
String message = readLine(is); String message = readLine(is);
throw new JedisException(message); throw new JedisException(message);
} }
@@ -60,27 +60,27 @@ public class Protocol {
} }
} }
} catch (IOException e) { } catch (IOException e) {
// TODO Dont know what to do here! throw new JedisException(e);
} }
return sb.toString(); return sb.toString();
} }
public String getBulkReply(InputStream is) throws JedisException { public String getBulkReply(InputStream is) {
Object reply = process(is); Object reply = process(is);
return (String) reply; return (String) reply;
} }
public String getStatusCodeReply(InputStream is) throws JedisException { public String getStatusCodeReply(InputStream is) {
Object reply = process(is); Object reply = process(is);
return (String) reply; return (String) reply;
} }
public int getIntegerReply(InputStream is) throws JedisException { public int getIntegerReply(InputStream is) {
Object reply = process(is); Object reply = process(is);
return (Integer) reply; return (Integer) reply;
} }
private Object process(InputStream is) throws JedisException { private Object process(InputStream is) {
try { try {
byte b = (byte) is.read(); byte b = (byte) is.read();
if (b == MINUS_BYTE) { if (b == MINUS_BYTE) {
@@ -95,8 +95,7 @@ public class Protocol {
return processStatusCodeReply(is); return processStatusCodeReply(is);
} }
} catch (IOException e) { } catch (IOException e) {
// TODO check what to do here throw new JedisException(e);
throw new JedisException(e.getMessage());
} }
return null; return null;
} }
@@ -107,16 +106,20 @@ public class Protocol {
return ret; return ret;
} }
private Object processBulkReply(InputStream is) throws IOException { private Object processBulkReply(InputStream is) {
int len = Integer.parseInt(readLine(is)); int len = Integer.parseInt(readLine(is));
if (len == -1) { if (len == -1) {
return null; return null;
} }
byte[] read = new byte[len]; byte[] read = new byte[len];
is.read(read); try {
// read 2 more bytes for the command delimiter is.read(read);
is.read(); // read 2 more bytes for the command delimiter
is.read(); is.read();
is.read();
} catch (IOException e) {
throw new JedisException(e);
}
return new String(read); return new String(read);
} }
@@ -128,7 +131,7 @@ public class Protocol {
return ret; return ret;
} }
private Object processMultiBulkReply(InputStream is) throws JedisException { private Object processMultiBulkReply(InputStream is) {
int num = Integer.parseInt(readLine(is)); int num = Integer.parseInt(readLine(is));
if (num == -1) { if (num == -1) {
return null; return null;
@@ -141,7 +144,7 @@ public class Protocol {
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<Object> getMultiBulkReply(InputStream is) throws JedisException { public List<Object> getMultiBulkReply(InputStream is) {
Object reply = process(is); Object reply = process(is);
List<Object> ret = (List<Object>) reply; List<Object> ret = (List<Object>) reply;
return ret; return ret;

View File

@@ -13,413 +13,397 @@ public class Transaction {
this.client = client; this.client = client;
} }
public String ping() throws JedisException { public String ping() {
client.ping(); client.ping();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String set(String key, String value) throws JedisException { public String set(String key, String value) {
client.set(key, value); client.set(key, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String get(String key) throws JedisException { public String get(String key) {
client.sendCommand("GET", key); client.sendCommand("GET", key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String exists(String key) throws JedisException { public String exists(String key) {
client.exists(key); client.exists(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String del(String... keys) throws JedisException { public String del(String... keys) {
client.del(keys); client.del(keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String type(String key) throws JedisException { public String type(String key) {
client.type(key); client.type(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String flushDB() throws JedisException { public String flushDB() {
client.flushDB(); client.flushDB();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String keys(String pattern) throws JedisException { public String keys(String pattern) {
client.keys(pattern); client.keys(pattern);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String randomKey() throws JedisException { public String randomKey() {
client.randomKey(); client.randomKey();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String rename(String oldkey, String newkey) throws JedisException { public String rename(String oldkey, String newkey) {
client.rename(oldkey, newkey); client.rename(oldkey, newkey);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String renamenx(String oldkey, String newkey) throws JedisException { public String renamenx(String oldkey, String newkey) {
client.renamenx(oldkey, newkey); client.renamenx(oldkey, newkey);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String dbSize() throws JedisException { public String dbSize() {
client.dbSize(); client.dbSize();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String expire(String key, int seconds) throws JedisException { public String expire(String key, int seconds) {
client.expire(key, seconds); client.expire(key, seconds);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String expireAt(String key, long unixTime) throws JedisException { public String expireAt(String key, long unixTime) {
client.expireAt(key, unixTime); client.expireAt(key, unixTime);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String ttl(String key) throws JedisException { public String ttl(String key) {
client.ttl(key); client.ttl(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String select(int index) throws JedisException { public String select(int index) {
client.select(index); client.select(index);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String move(String key, int dbIndex) throws JedisException { public String move(String key, int dbIndex) {
client.move(key, dbIndex); client.move(key, dbIndex);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String flushAll() throws JedisException { public String flushAll() {
client.flushAll(); client.flushAll();
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String getSet(String key, String value) throws JedisException { public String getSet(String key, String value) {
client.getSet(key, value); client.getSet(key, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String mget(String... keys) throws JedisException { public String mget(String... keys) {
client.mget(keys); client.mget(keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String setnx(String key, String value) throws JedisException { public String setnx(String key, String value) {
client.setnx(key, value); client.setnx(key, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String setex(String key, int seconds, String value) public String setex(String key, int seconds, String value) {
throws JedisException {
client.setex(key, seconds, value); client.setex(key, seconds, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String mset(String... keysvalues) throws JedisException { public String mset(String... keysvalues) {
client.mset(keysvalues); client.mset(keysvalues);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String msetnx(String... keysvalues) throws JedisException { public String msetnx(String... keysvalues) {
client.msetnx(keysvalues); client.msetnx(keysvalues);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String decrBy(String key, int integer) throws JedisException { public String decrBy(String key, int integer) {
client.decrBy(key, integer); client.decrBy(key, integer);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String decr(String key) throws JedisException { public String decr(String key) {
client.decr(key); client.decr(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String incrBy(String key, int integer) throws JedisException { public String incrBy(String key, int integer) {
client.incrBy(key, integer); client.incrBy(key, integer);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String incr(String key) throws JedisException { public String incr(String key) {
client.incr(key); client.incr(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String append(String key, String value) throws JedisException { public String append(String key, String value) {
client.append(key, value); client.append(key, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String substr(String key, int start, int end) throws JedisException { public String substr(String key, int start, int end) {
client.substr(key, start, end); client.substr(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hset(String key, String field, String value) public String hset(String key, String field, String value) {
throws JedisException {
client.hset(key, field, value); client.hset(key, field, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hget(String key, String field) throws JedisException { public String hget(String key, String field) {
client.hget(key, field); client.hget(key, field);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hsetnx(String key, String field, String value) public String hsetnx(String key, String field, String value) {
throws JedisException {
client.hsetnx(key, field, value); client.hsetnx(key, field, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hmset(String key, Map<String, String> hash) public String hmset(String key, Map<String, String> hash) {
throws JedisException {
client.hmset(key, hash); client.hmset(key, hash);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hmget(String key, String... fields) throws JedisException { public String hmget(String key, String... fields) {
client.hmget(key, fields); client.hmget(key, fields);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hincrBy(String key, String field, int value) public String hincrBy(String key, String field, int value) {
throws JedisException {
client.hincrBy(key, field, value); client.hincrBy(key, field, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hexists(String key, String field) throws JedisException { public String hexists(String key, String field) {
client.hexists(key, field); client.hexists(key, field);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hdel(String key, String field) throws JedisException { public String hdel(String key, String field) {
client.hdel(key, field); client.hdel(key, field);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hlen(String key) throws JedisException { public String hlen(String key) {
client.hlen(key); client.hlen(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hkeys(String key) throws JedisException { public String hkeys(String key) {
client.hkeys(key); client.hkeys(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hvals(String key) throws JedisException { public String hvals(String key) {
client.hvals(key); client.hvals(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String hgetAll(String key) throws JedisException { public String hgetAll(String key) {
client.hgetAll(key); client.hgetAll(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String rpush(String key, String string) throws JedisException { public String rpush(String key, String string) {
client.rpush(key, string); client.rpush(key, string);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String lpush(String key, String string) throws JedisException { public String lpush(String key, String string) {
client.lpush(key, string); client.lpush(key, string);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String llen(String key) throws JedisException { public String llen(String key) {
client.llen(key); client.llen(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String lrange(String key, int start, int end) throws JedisException { public String lrange(String key, int start, int end) {
client.lrange(key, start, end); client.lrange(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String ltrim(String key, int start, int end) throws JedisException { public String ltrim(String key, int start, int end) {
client.ltrim(key, start, end); client.ltrim(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String lindex(String key, int index) throws JedisException { public String lindex(String key, int index) {
client.lindex(key, index); client.lindex(key, index);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String lset(String key, int index, String value) public String lset(String key, int index, String value) {
throws JedisException {
client.lset(key, index, value); client.lset(key, index, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String lrem(String key, int count, String value) public String lrem(String key, int count, String value) {
throws JedisException {
client.lrem(key, count, value); client.lrem(key, count, value);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String lpop(String key) throws JedisException { public String lpop(String key) {
client.lpop(key); client.lpop(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String rpop(String key) throws JedisException { public String rpop(String key) {
client.rpop(key); client.rpop(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String rpoplpush(String srckey, String dstkey) throws JedisException { public String rpoplpush(String srckey, String dstkey) {
client.rpoplpush(srckey, dstkey); client.rpoplpush(srckey, dstkey);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sadd(String key, String member) throws JedisException { public String sadd(String key, String member) {
client.sadd(key, member); client.sadd(key, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String smembers(String key) throws JedisException { public String smembers(String key) {
client.smembers(key); client.smembers(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String srem(String key, String member) throws JedisException { public String srem(String key, String member) {
client.srem(key, member); client.srem(key, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String spop(String key) throws JedisException { public String spop(String key) {
client.spop(key); client.spop(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String smove(String srckey, String dstkey, String member) public String smove(String srckey, String dstkey, String member) {
throws JedisException {
client.smove(srckey, dstkey, member); client.smove(srckey, dstkey, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String scard(String key) throws JedisException { public String scard(String key) {
client.scard(key); client.scard(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sismember(String key, String member) throws JedisException { public String sismember(String key, String member) {
client.sismember(key, member); client.sismember(key, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sinter(String... keys) throws JedisException { public String sinter(String... keys) {
client.sinter(keys); client.sinter(keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sinterstore(String dstkey, String... keys) public String sinterstore(String dstkey, String... keys) {
throws JedisException {
client.sinterstore(dstkey, keys); client.sinterstore(dstkey, keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sunion(String... keys) throws JedisException { public String sunion(String... keys) {
client.sunion(keys); client.sunion(keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sunionstore(String dstkey, String... keys) public String sunionstore(String dstkey, String... keys) {
throws JedisException {
client.sunionstore(dstkey, keys); client.sunionstore(dstkey, keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sdiff(String... keys) throws JedisException { public String sdiff(String... keys) {
client.sdiff(keys); client.sdiff(keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String sdiffstore(String dstkey, String... keys) public String sdiffstore(String dstkey, String... keys) {
throws JedisException {
client.sdiffstore(dstkey, keys); client.sdiffstore(dstkey, keys);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String srandmember(String key) throws JedisException { public String srandmember(String key) {
client.srandmember(key); client.srandmember(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zadd(String key, double score, String member) public String zadd(String key, double score, String member) {
throws JedisException {
client.zadd(key, score, member); client.zadd(key, score, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zrange(String key, int start, int end) throws JedisException { public String zrange(String key, int start, int end) {
client.zrange(key, start, end); client.zrange(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zrem(String key, String member) throws JedisException { public String zrem(String key, String member) {
client.zrem(key, member); client.zrem(key, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zincrby(String key, double score, String member) public String zincrby(String key, double score, String member) {
throws JedisException {
client.zincrby(key, score, member); client.zincrby(key, score, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zrank(String key, String member) throws JedisException { public String zrank(String key, String member) {
client.zrank(key, member); client.zrank(key, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zrevrank(String key, String member) throws JedisException { public String zrevrank(String key, String member) {
client.zrevrank(key, member); client.zrevrank(key, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zrevrange(String key, int start, int end) public String zrevrange(String key, int start, int end) {
throws JedisException {
client.zrevrange(key, start, end); client.zrevrange(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zrangeWithScores(String key, int start, int end) public String zrangeWithScores(String key, int start, int end) {
throws JedisException {
client.zrangeWithScores(key, start, end); client.zrangeWithScores(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zrevrangeWithScores(String key, int start, int end) public String zrevrangeWithScores(String key, int start, int end) {
throws JedisException {
client.zrevrangeWithScores(key, start, end); client.zrevrangeWithScores(key, start, end);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zcard(String key) throws JedisException { public String zcard(String key) {
client.zcard(key); client.zcard(key);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public String zscore(String key, String member) throws JedisException { public String zscore(String key, String member) {
client.zscore(key, member); client.zscore(key, member);
return client.getStatusCodeReply(); return client.getStatusCodeReply();
} }
public List<Object> exec() throws JedisException { public List<Object> exec() {
client.exec(); client.exec();
return client.getObjectMultiBulkReply(); return client.getObjectMultiBulkReply();
} }

View File

@@ -7,7 +7,7 @@ import redis.clients.jedis.JedisException;
public class JedisTest { public class JedisTest {
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
public void useWithoutConnecting() throws JedisException { public void useWithoutConnecting() {
Jedis jedis = new Jedis("localhost"); Jedis jedis = new Jedis("localhost");
jedis.dbSize(); jedis.dbSize();
} }

View File

@@ -13,7 +13,6 @@ import junit.framework.Assert;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.JedisException;
import redis.clients.jedis.Protocol; import redis.clients.jedis.Protocol;
public class ProtocolTest extends Assert { public class ProtocolTest extends Assert {
@@ -39,7 +38,7 @@ public class ProtocolTest extends Assert {
} }
@Test @Test
public void bulkReply() throws JedisException { public void bulkReply() {
InputStream is = new ByteArrayInputStream("$6\r\nfoobar\r\n".getBytes()); InputStream is = new ByteArrayInputStream("$6\r\nfoobar\r\n".getBytes());
Protocol protocol = new Protocol(); Protocol protocol = new Protocol();
String response = protocol.getBulkReply(is); String response = protocol.getBulkReply(is);
@@ -47,7 +46,7 @@ public class ProtocolTest extends Assert {
} }
@Test @Test
public void nullBulkReply() throws JedisException { public void nullBulkReply() {
InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes()); InputStream is = new ByteArrayInputStream("$-1\r\n".getBytes());
Protocol protocol = new Protocol(); Protocol protocol = new Protocol();
String response = protocol.getBulkReply(is); String response = protocol.getBulkReply(is);
@@ -55,7 +54,7 @@ public class ProtocolTest extends Assert {
} }
@Test @Test
public void singleLineReply() throws JedisException { public void singleLineReply() {
InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes()); InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
Protocol protocol = new Protocol(); Protocol protocol = new Protocol();
String response = protocol.getStatusCodeReply(is); String response = protocol.getStatusCodeReply(is);
@@ -63,7 +62,7 @@ public class ProtocolTest extends Assert {
} }
@Test @Test
public void integerReply() throws JedisException { public void integerReply() {
InputStream is = new ByteArrayInputStream(":123\r\n".getBytes()); InputStream is = new ByteArrayInputStream(":123\r\n".getBytes());
Protocol protocol = new Protocol(); Protocol protocol = new Protocol();
int response = protocol.getIntegerReply(is); int response = protocol.getIntegerReply(is);
@@ -72,7 +71,7 @@ public class ProtocolTest extends Assert {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void multiBulkReply() throws JedisException { public void multiBulkReply() {
InputStream is = new ByteArrayInputStream( 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" "*4\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$5\r\nHello\r\n$5\r\nWorld\r\n"
.getBytes()); .getBytes());
@@ -106,7 +105,7 @@ public class ProtocolTest extends Assert {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Test @Test
public void nullMultiBulkReply() throws JedisException { public void nullMultiBulkReply() {
InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes()); InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes());
Protocol protocol = new Protocol(); Protocol protocol = new Protocol();
List<String> response = (List<String>) (List<?>) protocol List<String> response = (List<String>) (List<?>) protocol

View File

@@ -5,13 +5,12 @@ import java.net.UnknownHostException;
import java.util.Calendar; import java.util.Calendar;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisException;
public class GetSetBenchmark { public class GetSetBenchmark {
private static final int TOTAL_OPERATIONS = 100000; private static final int TOTAL_OPERATIONS = 100000;
public static void main(String[] args) throws UnknownHostException, public static void main(String[] args) throws UnknownHostException,
IOException, JedisException { IOException {
Jedis jedis = new Jedis("localhost"); Jedis jedis = new Jedis("localhost");
jedis.connect(); jedis.connect();
jedis.auth("foobared"); jedis.auth("foobared");

View File

@@ -9,13 +9,13 @@ import redis.clients.jedis.JedisException;
public class AllKindOfValuesCommandsTest extends JedisCommandTestBase { public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
@Test @Test
public void ping() throws JedisException { public void ping() {
String status = jedis.ping(); String status = jedis.ping();
assertEquals("PONG", status); assertEquals("PONG", status);
} }
@Test @Test
public void exists() throws JedisException { public void exists() {
String status = jedis.set("foo", "bar"); String status = jedis.set("foo", "bar");
assertEquals("OK", status); assertEquals("OK", status);
@@ -30,7 +30,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void del() throws JedisException { public void del() {
jedis.set("foo1", "bar1"); jedis.set("foo1", "bar1");
jedis.set("foo2", "bar2"); jedis.set("foo2", "bar2");
jedis.set("foo3", "bar3"); jedis.set("foo3", "bar3");
@@ -55,14 +55,14 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void type() throws JedisException { public void type() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
String status = jedis.type("foo"); String status = jedis.type("foo");
assertEquals("string", status); assertEquals("string", status);
} }
@Test @Test
public void keys() throws JedisException { public void keys() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
jedis.set("foobar", "bar"); jedis.set("foobar", "bar");
@@ -79,7 +79,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void randomKey() throws JedisException { public void randomKey() {
assertEquals(null, jedis.randomKey()); assertEquals(null, jedis.randomKey());
jedis.set("foo", "bar"); jedis.set("foo", "bar");
@@ -93,7 +93,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void rename() throws JedisException { public void rename() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
String status = jedis.rename("foo", "bar"); String status = jedis.rename("foo", "bar");
assertEquals("OK", status); assertEquals("OK", status);
@@ -106,13 +106,13 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
public void renameOldAndNewAreTheSame() throws JedisException { public void renameOldAndNewAreTheSame() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
jedis.rename("foo", "foo"); jedis.rename("foo", "foo");
} }
@Test @Test
public void renamenx() throws JedisException { public void renamenx() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
int status = jedis.renamenx("foo", "bar"); int status = jedis.renamenx("foo", "bar");
assertEquals(1, status); assertEquals(1, status);
@@ -123,7 +123,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void dbSize() throws JedisException { public void dbSize() {
int size = jedis.dbSize(); int size = jedis.dbSize();
assertEquals(0, size); assertEquals(0, size);
@@ -133,7 +133,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void expire() throws JedisException { public void expire() {
int status = jedis.expire("foo", 20); int status = jedis.expire("foo", 20);
assertEquals(0, status); assertEquals(0, status);
@@ -146,7 +146,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void expireAt() throws JedisException { public void expireAt() {
long unixTime = (System.currentTimeMillis() / 1000L) + 20; long unixTime = (System.currentTimeMillis() / 1000L) + 20;
int status = jedis.expireAt("foo", unixTime); int status = jedis.expireAt("foo", unixTime);
@@ -163,7 +163,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void ttl() throws JedisException { public void ttl() {
int ttl = jedis.ttl("foo"); int ttl = jedis.ttl("foo");
assertEquals(-1, ttl); assertEquals(-1, ttl);
@@ -177,7 +177,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void select() throws JedisException { public void select() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
String status = jedis.select(1); String status = jedis.select(1);
assertEquals("OK", status); assertEquals("OK", status);
@@ -188,7 +188,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void move() throws JedisException { public void move() {
int status = jedis.move("foo", 1); int status = jedis.move("foo", 1);
assertEquals(0, status); assertEquals(0, status);
@@ -202,7 +202,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void flushDB() throws JedisException { public void flushDB() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
assertEquals(1, jedis.dbSize()); assertEquals(1, jedis.dbSize());
jedis.set("bar", "foo"); jedis.set("bar", "foo");
@@ -215,7 +215,7 @@ public class AllKindOfValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void flushAll() throws JedisException { public void flushAll() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
assertEquals(1, jedis.dbSize()); assertEquals(1, jedis.dbSize());
jedis.set("bar", "foo"); jedis.set("bar", "foo");

View File

@@ -2,11 +2,9 @@ package redis.clients.jedis.tests.commands;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.JedisException;
public class ConnectionHandlingCommandsTest extends JedisCommandTestBase { public class ConnectionHandlingCommandsTest extends JedisCommandTestBase {
@Test @Test
public void quit() throws JedisException { public void quit() {
jedis.quit(); jedis.quit();
} }
} }

View File

@@ -8,11 +8,9 @@ import java.util.Map;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.JedisException;
public class HashesCommandsTest extends JedisCommandTestBase { public class HashesCommandsTest extends JedisCommandTestBase {
@Test @Test
public void hset() throws JedisException { public void hset() {
int status = jedis.hset("foo", "bar", "car"); int status = jedis.hset("foo", "bar", "car");
assertEquals(1, status); assertEquals(1, status);
status = jedis.hset("foo", "bar", "foo"); status = jedis.hset("foo", "bar", "foo");
@@ -20,7 +18,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hget() throws JedisException { public void hget() {
jedis.hset("foo", "bar", "car"); jedis.hset("foo", "bar", "car");
assertEquals(null, jedis.hget("bar", "foo")); assertEquals(null, jedis.hget("bar", "foo"));
assertEquals(null, jedis.hget("foo", "car")); assertEquals(null, jedis.hget("foo", "car"));
@@ -28,7 +26,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hsetnx() throws JedisException { public void hsetnx() {
int status = jedis.hsetnx("foo", "bar", "car"); int status = jedis.hsetnx("foo", "bar", "car");
assertEquals(1, status); assertEquals(1, status);
assertEquals("car", jedis.hget("foo", "bar")); assertEquals("car", jedis.hget("foo", "bar"));
@@ -43,7 +41,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hmset() throws JedisException { public void hmset() {
Map<String, String> hash = new HashMap<String, String>(); Map<String, String> hash = new HashMap<String, String>();
hash.put("bar", "car"); hash.put("bar", "car");
hash.put("car", "bar"); hash.put("car", "bar");
@@ -54,7 +52,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hmget() throws JedisException { public void hmget() {
Map<String, String> hash = new HashMap<String, String>(); Map<String, String> hash = new HashMap<String, String>();
hash.put("bar", "car"); hash.put("bar", "car");
hash.put("car", "bar"); hash.put("car", "bar");
@@ -70,7 +68,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hincrBy() throws JedisException { public void hincrBy() {
int value = jedis.hincrBy("foo", "bar", 1); int value = jedis.hincrBy("foo", "bar", 1);
assertEquals(1, value); assertEquals(1, value);
value = jedis.hincrBy("foo", "bar", -1); value = jedis.hincrBy("foo", "bar", -1);
@@ -80,7 +78,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hexists() throws JedisException { public void hexists() {
Map<String, String> hash = new HashMap<String, String>(); Map<String, String> hash = new HashMap<String, String>();
hash.put("bar", "car"); hash.put("bar", "car");
hash.put("car", "bar"); hash.put("car", "bar");
@@ -92,7 +90,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hdel() throws JedisException { public void hdel() {
Map<String, String> hash = new HashMap<String, String>(); Map<String, String> hash = new HashMap<String, String>();
hash.put("bar", "car"); hash.put("bar", "car");
hash.put("car", "bar"); hash.put("car", "bar");
@@ -105,7 +103,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hlen() throws JedisException { public void hlen() {
Map<String, String> hash = new HashMap<String, String>(); Map<String, String> hash = new HashMap<String, String>();
hash.put("bar", "car"); hash.put("bar", "car");
hash.put("car", "bar"); hash.put("car", "bar");
@@ -116,7 +114,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hkeys() throws JedisException { public void hkeys() {
Map<String, String> hash = new LinkedHashMap<String, String>(); Map<String, String> hash = new LinkedHashMap<String, String>();
hash.put("bar", "car"); hash.put("bar", "car");
hash.put("car", "bar"); hash.put("car", "bar");
@@ -130,7 +128,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hvals() throws JedisException { public void hvals() {
Map<String, String> hash = new LinkedHashMap<String, String>(); Map<String, String> hash = new LinkedHashMap<String, String>();
hash.put("bar", "car"); hash.put("bar", "car");
hash.put("car", "bar"); hash.put("car", "bar");
@@ -144,7 +142,7 @@ public class HashesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void hgetAll() throws JedisException { public void hgetAll() {
Map<String, String> h = new HashMap<String, String>(); Map<String, String> h = new HashMap<String, String>();
h.put("bar", "car"); h.put("bar", "car");
h.put("car", "bar"); h.put("car", "bar");

View File

@@ -7,7 +7,7 @@ import org.junit.Before;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
public class JedisCommandTestBase extends Assert { public abstract class JedisCommandTestBase extends Assert {
protected Jedis jedis; protected Jedis jedis;

View File

@@ -10,7 +10,7 @@ import redis.clients.jedis.JedisException;
public class ListCommandsTest extends JedisCommandTestBase { public class ListCommandsTest extends JedisCommandTestBase {
@Test @Test
public void rpush() throws JedisException { public void rpush() {
int size = jedis.rpush("foo", "bar"); int size = jedis.rpush("foo", "bar");
assertEquals(1, size); assertEquals(1, size);
size = jedis.rpush("foo", "foo"); size = jedis.rpush("foo", "foo");
@@ -18,7 +18,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void lpush() throws JedisException { public void lpush() {
int size = jedis.lpush("foo", "bar"); int size = jedis.lpush("foo", "bar");
assertEquals(1, size); assertEquals(1, size);
size = jedis.lpush("foo", "foo"); size = jedis.lpush("foo", "foo");
@@ -26,7 +26,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void llen() throws JedisException { public void llen() {
assertEquals(0, jedis.llen("foo")); assertEquals(0, jedis.llen("foo"));
jedis.lpush("foo", "bar"); jedis.lpush("foo", "bar");
jedis.lpush("foo", "car"); jedis.lpush("foo", "car");
@@ -34,13 +34,13 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
public void llenNotOnList() throws JedisException { public void llenNotOnList() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
jedis.llen("foo"); jedis.llen("foo");
} }
@Test @Test
public void lrange() throws JedisException { public void lrange() {
jedis.rpush("foo", "a"); jedis.rpush("foo", "a");
jedis.rpush("foo", "b"); jedis.rpush("foo", "b");
jedis.rpush("foo", "c"); jedis.rpush("foo", "c");
@@ -69,7 +69,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void ltrim() throws JedisException { public void ltrim() {
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "3"); jedis.lpush("foo", "3");
@@ -85,7 +85,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void lindex() throws JedisException { public void lindex() {
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "3"); jedis.lpush("foo", "3");
@@ -102,7 +102,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void lset() throws JedisException { public void lset() {
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "3"); jedis.lpush("foo", "3");
@@ -112,7 +112,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void lrem() throws JedisException { public void lrem() {
jedis.lpush("foo", "hello"); jedis.lpush("foo", "hello");
jedis.lpush("foo", "hello"); jedis.lpush("foo", "hello");
jedis.lpush("foo", "x"); jedis.lpush("foo", "x");
@@ -136,7 +136,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void lpop() throws JedisException { public void lpop() {
jedis.rpush("foo", "a"); jedis.rpush("foo", "a");
jedis.rpush("foo", "b"); jedis.rpush("foo", "b");
jedis.rpush("foo", "c"); jedis.rpush("foo", "c");
@@ -157,7 +157,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void rpop() throws JedisException { public void rpop() {
jedis.rpush("foo", "a"); jedis.rpush("foo", "a");
jedis.rpush("foo", "b"); jedis.rpush("foo", "b");
jedis.rpush("foo", "c"); jedis.rpush("foo", "c");
@@ -178,7 +178,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void rpoplpush() throws JedisException { public void rpoplpush() {
jedis.rpush("foo", "a"); jedis.rpush("foo", "a");
jedis.rpush("foo", "b"); jedis.rpush("foo", "b");
jedis.rpush("foo", "c"); jedis.rpush("foo", "c");
@@ -204,7 +204,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void blpop() throws JedisException { public void blpop() {
List<String> result = jedis.blpop(2, "foo"); List<String> result = jedis.blpop(2, "foo");
assertNull(result); assertNull(result);
@@ -226,7 +226,7 @@ public class ListCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void brpop() throws JedisException { public void brpop() {
List<String> result = jedis.brpop(2, "foo"); List<String> result = jedis.brpop(2, "foo");
assertNull(result); assertNull(result);

View File

@@ -5,11 +5,9 @@ import java.util.Set;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.JedisException;
public class SetCommandsTest extends JedisCommandTestBase { public class SetCommandsTest extends JedisCommandTestBase {
@Test @Test
public void sadd() throws JedisException { public void sadd() {
int status = jedis.sadd("foo", "a"); int status = jedis.sadd("foo", "a");
assertEquals(1, status); assertEquals(1, status);
@@ -18,7 +16,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void smembers() throws JedisException { public void smembers() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -32,7 +30,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void srem() throws JedisException { public void srem() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -50,7 +48,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void spop() throws JedisException { public void spop() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -64,7 +62,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void smove() throws JedisException { public void smove() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -88,7 +86,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void scard() throws JedisException { public void scard() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -101,7 +99,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sismember() throws JedisException { public void sismember() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -113,7 +111,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sinter() throws JedisException { public void sinter() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -128,7 +126,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sinterstore() throws JedisException { public void sinterstore() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -145,7 +143,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sunion() throws JedisException { public void sunion() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -162,7 +160,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sunionstore() throws JedisException { public void sunionstore() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -181,7 +179,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sdiff() throws JedisException { public void sdiff() {
jedis.sadd("foo", "x"); jedis.sadd("foo", "x");
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -201,7 +199,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sdiffstore() throws JedisException { public void sdiffstore() {
jedis.sadd("foo", "x"); jedis.sadd("foo", "x");
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");
@@ -222,7 +220,7 @@ public class SetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void srandmember() throws JedisException { public void srandmember() {
jedis.sadd("foo", "a"); jedis.sadd("foo", "a");
jedis.sadd("foo", "b"); jedis.sadd("foo", "b");

View File

@@ -5,12 +5,11 @@ import java.util.Set;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.JedisException;
import redis.clients.jedis.Tuple; import redis.clients.jedis.Tuple;
public class SortedSetCommandsTest extends JedisCommandTestBase { public class SortedSetCommandsTest extends JedisCommandTestBase {
@Test @Test
public void zadd() throws JedisException { public void zadd() {
int status = jedis.zadd("foo", 1d, "a"); int status = jedis.zadd("foo", 1d, "a");
assertEquals(1, status); assertEquals(1, status);
@@ -25,7 +24,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zrange() throws JedisException { public void zrange() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b"); jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c"); jedis.zadd("foo", 0.1d, "c");
@@ -44,7 +43,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zrevrange() throws JedisException { public void zrevrange() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b"); jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c"); jedis.zadd("foo", 0.1d, "c");
@@ -63,7 +62,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zrem() throws JedisException { public void zrem() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 2d, "b"); jedis.zadd("foo", 2d, "b");
@@ -81,7 +80,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zincrby() throws JedisException { public void zincrby() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 2d, "b"); jedis.zadd("foo", 2d, "b");
@@ -96,7 +95,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zrank() throws JedisException { public void zrank() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 2d, "b"); jedis.zadd("foo", 2d, "b");
@@ -108,7 +107,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zrevrank() throws JedisException { public void zrevrank() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 2d, "b"); jedis.zadd("foo", 2d, "b");
@@ -120,7 +119,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zrangeWithScores() throws JedisException { public void zrangeWithScores() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b"); jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c"); jedis.zadd("foo", 0.1d, "c");
@@ -139,7 +138,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zrevrangeWithScores() throws JedisException { public void zrevrangeWithScores() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b"); jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c"); jedis.zadd("foo", 0.1d, "c");
@@ -158,7 +157,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zcard() throws JedisException { public void zcard() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b"); jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c"); jedis.zadd("foo", 0.1d, "c");
@@ -169,7 +168,7 @@ public class SortedSetCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void zscore() throws JedisException { public void zscore() {
jedis.zadd("foo", 1d, "a"); jedis.zadd("foo", 1d, "a");
jedis.zadd("foo", 10d, "b"); jedis.zadd("foo", 10d, "b");
jedis.zadd("foo", 0.1d, "c"); jedis.zadd("foo", 0.1d, "c");

View File

@@ -5,12 +5,11 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.JedisException;
import redis.clients.jedis.SortingParams; import redis.clients.jedis.SortingParams;
public class SortingCommandsTest extends JedisCommandTestBase { public class SortingCommandsTest extends JedisCommandTestBase {
@Test @Test
public void sort() throws JedisException { public void sort() {
jedis.lpush("foo", "3"); jedis.lpush("foo", "3");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
@@ -26,7 +25,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sortBy() throws JedisException { public void sortBy() {
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "3"); jedis.lpush("foo", "3");
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
@@ -49,7 +48,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sortDesc() throws JedisException { public void sortDesc() {
jedis.lpush("foo", "3"); jedis.lpush("foo", "3");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
@@ -68,7 +67,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sortLimit() throws JedisException { public void sortLimit() {
for (int n = 10; n > 0; n--) { for (int n = 10; n > 0; n--) {
jedis.lpush("foo", String.valueOf(n)); jedis.lpush("foo", String.valueOf(n));
} }
@@ -87,7 +86,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sortAlpha() throws JedisException { public void sortAlpha() {
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "10"); jedis.lpush("foo", "10");
@@ -106,7 +105,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sortGet() throws JedisException { public void sortGet() {
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "10"); jedis.lpush("foo", "10");
@@ -136,7 +135,7 @@ public class SortingCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void sortStore() throws JedisException { public void sortStore() {
jedis.lpush("foo", "1"); jedis.lpush("foo", "1");
jedis.lpush("foo", "2"); jedis.lpush("foo", "2");
jedis.lpush("foo", "10"); jedis.lpush("foo", "10");

View File

@@ -9,7 +9,7 @@ import redis.clients.jedis.JedisException;
public class StringValuesCommandsTest extends JedisCommandTestBase { public class StringValuesCommandsTest extends JedisCommandTestBase {
@Test @Test
public void setAndGet() throws JedisException { public void setAndGet() {
String status = jedis.set("foo", "bar"); String status = jedis.set("foo", "bar");
assertEquals("OK", status); assertEquals("OK", status);
@@ -20,7 +20,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void getSet() throws JedisException { public void getSet() {
String value = jedis.getSet("foo", "bar"); String value = jedis.getSet("foo", "bar");
assertEquals(null, value); assertEquals(null, value);
value = jedis.get("foo"); value = jedis.get("foo");
@@ -28,7 +28,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void mget() throws JedisException { public void mget() {
List<String> values = jedis.mget("foo", "bar"); List<String> values = jedis.mget("foo", "bar");
List<String> expected = new ArrayList<String>(); List<String> expected = new ArrayList<String>();
expected.add(null); expected.add(null);
@@ -56,7 +56,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void setnx() throws JedisException { public void setnx() {
int status = jedis.setnx("foo", "bar"); int status = jedis.setnx("foo", "bar");
assertEquals(1, status); assertEquals(1, status);
assertEquals("bar", jedis.get("foo")); assertEquals("bar", jedis.get("foo"));
@@ -67,7 +67,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void setex() throws JedisException { public void setex() {
String status = jedis.setex("foo", 20, "bar"); String status = jedis.setex("foo", 20, "bar");
assertEquals("OK", status); assertEquals("OK", status);
int ttl = jedis.ttl("foo"); int ttl = jedis.ttl("foo");
@@ -75,7 +75,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void mset() throws JedisException { public void mset() {
String status = jedis.mset("foo", "bar", "bar", "foo"); String status = jedis.mset("foo", "bar", "bar", "foo");
assertEquals("OK", status); assertEquals("OK", status);
assertEquals("bar", jedis.get("foo")); assertEquals("bar", jedis.get("foo"));
@@ -83,7 +83,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void msetnx() throws JedisException { public void msetnx() {
int status = jedis.msetnx("foo", "bar", "bar", "foo"); int status = jedis.msetnx("foo", "bar", "bar", "foo");
assertEquals(1, status); assertEquals(1, status);
assertEquals("bar", jedis.get("foo")); assertEquals("bar", jedis.get("foo"));
@@ -96,13 +96,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
public void incrWrongValue() throws JedisException { public void incrWrongValue() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
jedis.incr("foo"); jedis.incr("foo");
} }
@Test @Test
public void incr() throws JedisException { public void incr() {
int value = jedis.incr("foo"); int value = jedis.incr("foo");
assertEquals(1, value); assertEquals(1, value);
value = jedis.incr("foo"); value = jedis.incr("foo");
@@ -110,13 +110,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
public void incrByWrongValue() throws JedisException { public void incrByWrongValue() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
jedis.incrBy("foo", 2); jedis.incrBy("foo", 2);
} }
@Test @Test
public void incrBy() throws JedisException { public void incrBy() {
int value = jedis.incrBy("foo", 2); int value = jedis.incrBy("foo", 2);
assertEquals(2, value); assertEquals(2, value);
value = jedis.incrBy("foo", 2); value = jedis.incrBy("foo", 2);
@@ -124,13 +124,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
public void decrWrongValue() throws JedisException { public void decrWrongValue() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
jedis.decr("foo"); jedis.decr("foo");
} }
@Test @Test
public void decr() throws JedisException { public void decr() {
int value = jedis.decr("foo"); int value = jedis.decr("foo");
assertEquals(-1, value); assertEquals(-1, value);
value = jedis.decr("foo"); value = jedis.decr("foo");
@@ -138,13 +138,13 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test(expected = JedisException.class) @Test(expected = JedisException.class)
public void decrByWrongValue() throws JedisException { public void decrByWrongValue() {
jedis.set("foo", "bar"); jedis.set("foo", "bar");
jedis.decrBy("foo", 2); jedis.decrBy("foo", 2);
} }
@Test @Test
public void decrBy() throws JedisException { public void decrBy() {
int value = jedis.decrBy("foo", 2); int value = jedis.decrBy("foo", 2);
assertEquals(-2, value); assertEquals(-2, value);
value = jedis.decrBy("foo", 2); value = jedis.decrBy("foo", 2);
@@ -152,7 +152,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void append() throws JedisException { public void append() {
int value = jedis.append("foo", "bar"); int value = jedis.append("foo", "bar");
assertEquals(3, value); assertEquals(3, value);
assertEquals("bar", jedis.get("foo")); assertEquals("bar", jedis.get("foo"));
@@ -162,7 +162,7 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void substr() throws JedisException { public void substr() {
jedis.set("s", "This is a string"); jedis.set("s", "This is a string");
assertEquals("This", jedis.substr("s", 0, 3)); assertEquals("This", jedis.substr("s", 0, 3));
assertEquals("ing", jedis.substr("s", -3, -1)); assertEquals("ing", jedis.substr("s", -3, -1));

View File

@@ -8,13 +8,12 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import redis.clients.jedis.Jedis; import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisException;
import redis.clients.jedis.Transaction; import redis.clients.jedis.Transaction;
import redis.clients.jedis.TransactionBlock; import redis.clients.jedis.TransactionBlock;
public class TransactionCommandsTest extends JedisCommandTestBase { public class TransactionCommandsTest extends JedisCommandTestBase {
@Test @Test
public void multi() throws JedisException { public void multi() {
Transaction trans = jedis.multi(); Transaction trans = jedis.multi();
String status = trans.sadd("foo", "a"); String status = trans.sadd("foo", "a");
@@ -36,9 +35,9 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void multiBlock() throws JedisException { public void multiBlock() {
List<Object> response = jedis.multi(new TransactionBlock() { List<Object> response = jedis.multi(new TransactionBlock() {
public void execute() throws JedisException { public void execute() {
String status = sadd("foo", "a"); String status = sadd("foo", "a");
assertEquals("QUEUED", status); assertEquals("QUEUED", status);
@@ -58,8 +57,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void watch() throws JedisException, UnknownHostException, public void watch() throws UnknownHostException, IOException {
IOException {
jedis.watch("mykey"); jedis.watch("mykey");
String val = jedis.get("mykey"); String val = jedis.get("mykey");
val = "foo"; val = "foo";
@@ -77,8 +75,7 @@ public class TransactionCommandsTest extends JedisCommandTestBase {
} }
@Test @Test
public void unwatch() throws JedisException, UnknownHostException, public void unwatch() throws UnknownHostException, IOException {
IOException {
jedis.watch("mykey"); jedis.watch("mykey");
String val = jedis.get("mykey"); String val = jedis.get("mykey");
val = "foo"; val = "foo";