Package redis.reply

Examples of redis.reply.StatusReply


    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();
View Full Code Here


    if (code == -1) {
      throw new EOFException();
    }
    switch (code) {
      case StatusReply.MARKER: {
        return new StatusReply(new DataInputStream(is).readLine());
      }
      case ErrorReply.MARKER: {
        return new ErrorReply(new DataInputStream(is).readLine());
      }
      case IntegerReply.MARKER: {
View Full Code Here

    client = new RedisClient("localhost", 6379);
  }

  @Test
  public void testMultiDiscard() throws Exception {
    StatusReply set = client.set("testitnow", "willdo");
    StatusReply multi = client.multi();
    ListenableFuture<StatusReply> set1 = client.pipeline().set("testitnow", "notok");
    client.discard();
    assertEquals("willdo", new String(client.get("testitnow").data()));
    // Ensure we can run a new tx after discarding previous one
    testMultiExec();
View Full Code Here

    testMultiExec();
  }

  @Test
  public void testMultiExec() throws Exception {
    StatusReply multi = client.multi();
    ListenableFuture<StatusReply> reply = client.pipeline().set("key", "value");
    Future<Boolean> exec = client.exec();
    assertEquals("OK", reply.get().data());
  }
View Full Code Here

TOP

Related Classes of redis.reply.StatusReply

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.