Package redis.reply

Examples of redis.reply.Reply


*/
public class ReplyTest {
  @Test
  public void testReadWrite() throws IOException {
    ByteArrayOutputStream os;
    Reply receive;
    {
      os = new ByteArrayOutputStream();
      String message = "OK";
      new StatusReply(message).write(os);
      receive = RedisProtocol.receive(new ByteArrayInputStream(os.toByteArray()));
      assertTrue(receive instanceof StatusReply);
      assertEquals(message, receive.data());
    }
    {
      os = new ByteArrayOutputStream();
      String message = "OK";
      new ErrorReply(message).write(os);
      receive = RedisProtocol.receive(new ByteArrayInputStream(os.toByteArray()));
      assertTrue(receive instanceof ErrorReply);
      assertEquals(message, receive.data());
    }
    {
      os = new ByteArrayOutputStream();
      String message = "OK";
      new BulkReply(message.getBytes()).write(os);
      receive = RedisProtocol.receive(new ByteArrayInputStream(os.toByteArray()));
      assertTrue(receive instanceof BulkReply);
      assertEquals(message, new String((byte[]) receive.data()));
    }
    {
      os = new ByteArrayOutputStream();
      long integer = 999;
      new IntegerReply(integer).write(os);
      receive = RedisProtocol.receive(new ByteArrayInputStream(os.toByteArray()));
      assertTrue(receive instanceof IntegerReply);
      assertEquals(integer, receive.data());
    }
    {
      os = new ByteArrayOutputStream();
      String message = "OK";
      long integer = 999;
      new MultiBulkReply(new Reply[] {
              new StatusReply(message),
              new ErrorReply(message),
              new MultiBulkReply(new Reply[] { new StatusReply(message)}),
              new BulkReply(message.getBytes()),
              new IntegerReply(integer)}).write(os);
      receive = RedisProtocol.receive(new ByteArrayInputStream(os.toByteArray()));
      assertTrue(receive instanceof MultiBulkReply);
      Reply[] data = (Reply[]) receive.data();
      assertEquals(message, data[0].data());
      assertEquals(message, data[1].data());
      assertTrue(data[2] instanceof MultiBulkReply);
      Reply[] data2 = (Reply[]) data[2].data();
      assertEquals(message, data2[0].data());
View Full Code Here


    es.submit(new Runnable() {
      @Override
      public void run() {
        try {
          latch.countDown();
          Reply reply = client.brpoplpush("popsource", "pushdest", 0);
          ref.set(reply);
        } catch(Exception e) {
          error.set(e);
        }
      }
View Full Code Here

*/
public class Issue21Test {
  @Test
  public void testBRPOPLPUSH() throws IOException {
    RedisClient client = new RedisClient("localhost", 6379);
    Reply brpoplpush = client.brpoplpush("alskdjflksadf", "alksdjflaksdfj", 1);
    assertTrue(brpoplpush instanceof MultiBulkReply);
    assertEquals(null, ((MultiBulkReply) brpoplpush).data());
  }
View Full Code Here

public class Issue25Test {

  private RedisClient client;

  public List scriptExists(String... scripts) {
    Reply reply = client.script_exists(scripts);
    if (reply instanceof MultiBulkReply) {
      MultiBulkReply mbr = (MultiBulkReply) reply;
      return mbr.asStringList(Charsets.UTF_8);
    }
    return new ArrayList();
View Full Code Here

TOP

Related Classes of redis.reply.Reply

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.