Binary scripting API is tested
This commit is contained in:
@@ -3037,9 +3037,9 @@ public class BinaryJedis implements BinaryJedisCommands {
|
||||
return client.getBinaryBulkReply();
|
||||
}
|
||||
|
||||
public List<byte[]> scriptExists(byte[]... sha1){
|
||||
public List<Long> scriptExists(byte[]... sha1){
|
||||
client.scriptExists(sha1);
|
||||
return client.getBinaryMultiBulkReply();
|
||||
return client.getIntegerMultiBulkReply();
|
||||
}
|
||||
|
||||
public byte[] scriptLoad(byte[] script){
|
||||
|
||||
@@ -205,6 +205,13 @@ public class Connection {
|
||||
pipelinedCommands--;
|
||||
return (List<Object>) protocol.read(inputStream);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<Long> getIntegerMultiBulkReply() {
|
||||
flush();
|
||||
pipelinedCommands--;
|
||||
return (List<Long>) protocol.read(inputStream);
|
||||
}
|
||||
|
||||
public List<Object> getAll() {
|
||||
return getAll(0);
|
||||
|
||||
@@ -2749,11 +2749,11 @@ public class Jedis extends BinaryJedis implements JedisCommands {
|
||||
|
||||
public List<Boolean> scriptExists(String... sha1){
|
||||
client.scriptExists(sha1);
|
||||
List<Object> result = client.getObjectMultiBulkReply();
|
||||
List<Long> result = client.getIntegerMultiBulkReply();
|
||||
List<Boolean> exists = new ArrayList<Boolean>();
|
||||
|
||||
for(Object value : result)
|
||||
exists.add(((Long)value) == 1);
|
||||
for(Long value : result)
|
||||
exists.add(value == 1);
|
||||
|
||||
return exists;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.junit.Test;
|
||||
|
||||
import redis.clients.jedis.exceptions.JedisDataException;
|
||||
import redis.clients.jedis.exceptions.JedisException;
|
||||
import redis.clients.util.SafeEncoder;
|
||||
|
||||
public class ScriptingCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
@@ -92,6 +93,15 @@ public class ScriptingCommandsTest extends JedisCommandTestBase {
|
||||
assertTrue(exists.get(1));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void scriptExistsBinary() {
|
||||
jedis.scriptLoad(SafeEncoder.encode("return redis.call('get','foo')"));
|
||||
List<Long> exists = jedis.scriptExists(SafeEncoder.encode("ffffffffffffffffffffffffffffffffffffffff"),SafeEncoder.encode("6b1bf486c81ceb7edf3c093f4c48582e38c0e791"));
|
||||
assertEquals(new Long(0), exists.get(0));
|
||||
assertEquals(new Long(1), exists.get(1));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void scriptLoad() {
|
||||
@@ -99,6 +109,14 @@ public class ScriptingCommandsTest extends JedisCommandTestBase {
|
||||
assertTrue(jedis.scriptExists("6b1bf486c81ceb7edf3c093f4c48582e38c0e791"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void scriptLoadBinary() {
|
||||
jedis.scriptLoad(SafeEncoder.encode("return redis.call('get','foo')"));
|
||||
List<Long> exists = jedis.scriptExists(SafeEncoder.encode("6b1bf486c81ceb7edf3c093f4c48582e38c0e791"));
|
||||
assertEquals(new Long(1), exists.get(0));
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void scriptKill() {
|
||||
|
||||
Reference in New Issue
Block a user