Search in sources :

Example 1 with BinaryJedis

use of redis.clients.jedis.BinaryJedis in project cachecloud by sohutv.

the class ScriptingCommandsTest method evalMultiBulkWithBinaryJedis.

@SuppressWarnings("unchecked")
@Test
public void evalMultiBulkWithBinaryJedis() {
    String script = "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2],ARGV[3]}";
    List<byte[]> keys = new ArrayList<byte[]>();
    keys.add("key1".getBytes());
    keys.add("key2".getBytes());
    List<byte[]> args = new ArrayList<byte[]>();
    args.add("first".getBytes());
    args.add("second".getBytes());
    args.add("third".getBytes());
    BinaryJedis binaryJedis = new BinaryJedis(hnp.getHost(), hnp.getPort(), 500);
    binaryJedis.connect();
    binaryJedis.auth("foobared");
    List<byte[]> responses = (List<byte[]>) binaryJedis.eval(script.getBytes(), keys, args);
    assertEquals(5, responses.size());
    assertEquals("key1", new String(responses.get(0)));
    assertEquals("key2", new String(responses.get(1)));
    assertEquals("first", new String(responses.get(2)));
    assertEquals("second", new String(responses.get(3)));
    assertEquals("third", new String(responses.get(4)));
    binaryJedis.close();
}
Also used : BinaryJedis(redis.clients.jedis.BinaryJedis) ArrayList(java.util.ArrayList) List(java.util.List) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 2 with BinaryJedis

use of redis.clients.jedis.BinaryJedis in project cachecloud by sohutv.

the class JedisTest method checkCloseable.

@Test
public void checkCloseable() {
    jedis.close();
    BinaryJedis bj = new BinaryJedis("localhost");
    bj.connect();
    bj.close();
}
Also used : BinaryJedis(redis.clients.jedis.BinaryJedis) Test(org.junit.Test)

Example 3 with BinaryJedis

use of redis.clients.jedis.BinaryJedis in project cachecloud by sohutv.

the class ConnectionHandlingCommandsTest method binary_quit.

@Test
public void binary_quit() {
    BinaryJedis bj = new BinaryJedis(hnp.getHost());
    assertEquals("OK", bj.quit());
}
Also used : BinaryJedis(redis.clients.jedis.BinaryJedis) Test(org.junit.Test)

Example 4 with BinaryJedis

use of redis.clients.jedis.BinaryJedis in project jedis by xetorthio.

the class ConnectionHandlingCommandsTest method binary_quit.

@Test
public void binary_quit() {
    BinaryJedis bj = new BinaryJedis(hnp.getHost());
    assertEquals("OK", bj.quit());
}
Also used : BinaryJedis(redis.clients.jedis.BinaryJedis) Test(org.junit.Test)

Example 5 with BinaryJedis

use of redis.clients.jedis.BinaryJedis in project jedis by xetorthio.

the class ScriptingCommandsTest method evalMultiBulkWithBinaryJedis.

@SuppressWarnings("unchecked")
@Test
public void evalMultiBulkWithBinaryJedis() {
    String script = "return {KEYS[1],KEYS[2],ARGV[1],ARGV[2],ARGV[3]}";
    List<byte[]> keys = new ArrayList<byte[]>();
    keys.add("key1".getBytes());
    keys.add("key2".getBytes());
    List<byte[]> args = new ArrayList<byte[]>();
    args.add("first".getBytes());
    args.add("second".getBytes());
    args.add("third".getBytes());
    BinaryJedis binaryJedis = new BinaryJedis(hnp.getHost(), hnp.getPort(), 500);
    binaryJedis.connect();
    binaryJedis.auth("foobared");
    List<byte[]> responses = (List<byte[]>) binaryJedis.eval(script.getBytes(), keys, args);
    assertEquals(5, responses.size());
    assertEquals("key1", new String(responses.get(0)));
    assertEquals("key2", new String(responses.get(1)));
    assertEquals("first", new String(responses.get(2)));
    assertEquals("second", new String(responses.get(3)));
    assertEquals("third", new String(responses.get(4)));
    binaryJedis.close();
}
Also used : BinaryJedis(redis.clients.jedis.BinaryJedis) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)6 BinaryJedis (redis.clients.jedis.BinaryJedis)6 ArrayList (java.util.ArrayList)2 List (java.util.List)2