use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolTest method busyReply.
@Test
public void busyReply() {
final String busyMessage = "BUSY Redis is busy running a script.";
final InputStream is = new ByteArrayInputStream(('-' + busyMessage + "\r\n").getBytes());
try {
Protocol.read(new RedisInputStream(is));
} catch (final JedisBusyException e) {
assertEquals(busyMessage, e.getMessage());
return;
}
fail("Expected a JedisBusyException to be thrown.");
}
use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolTest method nullMultiBulkReply.
@SuppressWarnings("unchecked")
@Test
public void nullMultiBulkReply() {
InputStream is = new ByteArrayInputStream("*-1\r\n".getBytes());
List<String> response = (List<String>) Protocol.read(new RedisInputStream(is));
assertNull(response);
}
use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolTest method integerReply.
@Test
public void integerReply() {
InputStream is = new ByteArrayInputStream(":123\r\n".getBytes());
long response = (Long) Protocol.read(new RedisInputStream(is));
assertEquals(123, response);
}
use of redis.clients.util.RedisInputStream in project jedis by xetorthio.
the class ProtocolTest method multiBulkReply.
@SuppressWarnings("unchecked")
@Test
public void multiBulkReply() {
InputStream is = new ByteArrayInputStream("*4\r\n$3\r\nfoo\r\n$3\r\nbar\r\n$5\r\nHello\r\n$5\r\nWorld\r\n".getBytes());
List<byte[]> response = (List<byte[]>) Protocol.read(new RedisInputStream(is));
List<byte[]> expected = new ArrayList<byte[]>();
expected.add(SafeEncoder.encode("foo"));
expected.add(SafeEncoder.encode("bar"));
expected.add(SafeEncoder.encode("Hello"));
expected.add(SafeEncoder.encode("World"));
assertByteArrayListEquals(expected, response);
}
use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.
the class ProtocolTest method integerReply.
@Test
public void integerReply() {
InputStream is = new ByteArrayInputStream(":123\r\n".getBytes());
long response = (Long) Protocol.read(new RedisInputStream(is));
assertEquals(123, response);
}
Aggregations