Search in sources :

Example 21 with RedisInputStream

use of redis.clients.util.RedisInputStream in project new-cloud by xie-summer.

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) List(java.util.List) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Example 22 with RedisInputStream

use of redis.clients.util.RedisInputStream in project new-cloud by xie-summer.

the class ProtocolBenchmark method measureInputStatus.

private static long measureInputStatus() throws Exception {
    long duration = 0;
    InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
    RedisInputStream in = new RedisInputStream(is);
    for (int n = 0; n <= TOTAL_OPERATIONS; n++) {
        long start = System.nanoTime();
        Protocol.read(in);
        duration += (System.nanoTime() - start);
        in.reset();
    }
    return duration;
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) RedisInputStream(redis.clients.util.RedisInputStream)

Example 23 with RedisInputStream

use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.

the class ProtocolTest method bulkReply.

@Test
public void bulkReply() {
    InputStream is = new ByteArrayInputStream("$6\r\nfoobar\r\n".getBytes());
    byte[] response = (byte[]) Protocol.read(new RedisInputStream(is));
    assertArrayEquals(SafeEncoder.encode("foobar"), response);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Example 24 with RedisInputStream

use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.

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);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) List(java.util.List) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Example 25 with RedisInputStream

use of redis.clients.util.RedisInputStream in project cachecloud by sohutv.

the class ProtocolTest method singleLineReply.

@Test
public void singleLineReply() {
    InputStream is = new ByteArrayInputStream("+OK\r\n".getBytes());
    byte[] response = (byte[]) Protocol.read(new RedisInputStream(is));
    assertArrayEquals(SafeEncoder.encode("OK"), response);
}
Also used : ByteArrayInputStream(java.io.ByteArrayInputStream) RedisInputStream(redis.clients.util.RedisInputStream) BufferedInputStream(java.io.BufferedInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) PipedInputStream(java.io.PipedInputStream) InputStream(java.io.InputStream) RedisInputStream(redis.clients.util.RedisInputStream) Test(org.junit.Test)

Aggregations

RedisInputStream (redis.clients.util.RedisInputStream)27 ByteArrayInputStream (java.io.ByteArrayInputStream)25 InputStream (java.io.InputStream)25 BufferedInputStream (java.io.BufferedInputStream)19 PipedInputStream (java.io.PipedInputStream)19 Test (org.junit.Test)19 ArrayList (java.util.ArrayList)6 List (java.util.List)6 IOException (java.io.IOException)2 InetSocketAddress (java.net.InetSocketAddress)2 Socket (java.net.Socket)2 JedisConnectionException (redis.clients.jedis.exceptions.JedisConnectionException)2 RedisOutputStream (redis.clients.util.RedisOutputStream)2 JedisBusyException (redis.clients.jedis.exceptions.JedisBusyException)1