Package redis.reply

Examples of redis.reply.BulkReply


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


  @Test
  public void testIt() throws IOException, ExecutionException, InterruptedException {
    RedisClient redisClient = new RedisClient("localhost", 6379);
    redisClient.set("test", "value");
    BulkReply test = redisClient.get("test");
    assertEquals("value", test.asAsciiString());
    assertEquals("value", test.asUTF8String());
    RedisClient.Pipeline p = redisClient.pipeline();
    p.set("increment", 0);
    p.incr("increment");
    p.incr("increment");
    assertEquals(3, (long) redisClient.incr("increment").data());
View Full Code Here

      }
      case IntegerReply.MARKER: {
        return new IntegerReply(readLong(is));
      }
      case BulkReply.MARKER: {
        return new BulkReply(readBytes(is));
      }
      case MultiBulkReply.MARKER: {
        return new MultiBulkReply(is);
      }
      default: {
View Full Code Here

  /**
   * @see DATAREDIS-268
   */
  @Test
  public void convertingNullReplyToListOfRedisClientInfoShouldReturnEmptyList() {
    assertThat(SrpConverters.toListOfRedisClientInformation(new BulkReply(null)),
        equalTo(Collections.<RedisClientInfo> emptyList()));
  }
View Full Code Here

  /**
   * @see DATAREDIS-268
   */
  @Test
  public void convertingEmptyReplyToListOfRedisClientInfoShouldReturnEmptyList() {
    assertThat(SrpConverters.toListOfRedisClientInformation(new BulkReply(new byte[0])),
        equalTo(Collections.<RedisClientInfo> emptyList()));
  }
View Full Code Here

    StringBuilder sb = new StringBuilder();
    sb.append(CLIENT_ALL_SINGLE_LINE_RESPONSE);
    sb.append("\r\n");
    sb.append(CLIENT_ALL_SINGLE_LINE_RESPONSE);

    assertThat(SrpConverters.toListOfRedisClientInformation(new BulkReply(sb.toString().getBytes())).size(), equalTo(2));
  }
View Full Code Here

   * @see DATAREDIS-206
   */
  @Test
  public void testConverterShouldCreateMillisecondsCorrectlyWhenGivenValidReplyArray() {

    Reply<?> seconds = new BulkReply("1392183718".getBytes(Charset.forName("UTF-8")));
    Reply<?> microseconds = new BulkReply("555122".getBytes(Charset.forName("UTF-8")));

    Assert.assertThat(converter.convert(new Reply[] { seconds, microseconds }), IsEqual.equalTo(1392183718555L));
  }
View Full Code Here

   * @see DATAREDIS-206
   */
  @Test(expected = IllegalArgumentException.class)
  public void testConverterShouldThrowExceptionWhenGivenReplyArrayHasOnlyOneItem() {

    converter.convert(new Reply[] { new BulkReply(null) });
  }
View Full Code Here

   * @see DATAREDIS-206
   */
  @Test(expected = IllegalArgumentException.class)
  public void testConverterShouldThrowExceptionWhenGivenReplyArrayMoreThanTwoItems() {

    converter.convert(new Reply[] { new BulkReply(null), new BulkReply(null), new BulkReply(null) });
  }
View Full Code Here

   * @see DATAREDIS-206
   */
  @Test(expected = NumberFormatException.class)
  public void testConverterShouldThrowExecptionForNonParsableReply() {

    Reply<?> invalidDataBlock = new BulkReply("123-not-a-number".getBytes(Charset.forName("UTF-8")));
    Reply<?> microseconds = new BulkReply("555122".getBytes(Charset.forName("UTF-8")));

    converter.convert(new Reply[] { invalidDataBlock, microseconds });
  }
View Full Code Here

TOP

Related Classes of redis.reply.BulkReply

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.