Package net.rubyeye.xmemcached.command

Examples of net.rubyeye.xmemcached.command.Command.decode()


    assertNull(command.getResult());
    assertEquals(0, command.getLatch().getCount());

    command = this.commandFactory.createGetCommand("test", "test"
        .getBytes(), CommandType.GET_ONE, null);
    assertFalse(command.decode(null, ByteBuffer
        .wrap("VALUE test 0 2 999\r\n10\r\n".getBytes())));
    assertNull(command.getResult());
    checkDecodeValidLine(command, "VALUE test 0 2 999\r\n10\r\nEND\r\n");

    assertEquals("10", new String(((CachedData) command.getResult())
View Full Code Here


    ByteBuffer buffer = constructResponse(OpCode.DELETE.fieldValue(),
        (short) 0, (byte) 0, (byte) 0, (short) 0, 0, 0, 1L, null, null,
        null);

    assertTrue(command.decode(null, buffer));
    assertTrue((Boolean) command.getResult());
    assertEquals(0, buffer.remaining());

    buffer = constructResponse(OpCode.DELETE.fieldValue(), (short) 0,
        (byte) 0, (byte) 0, (short) 0x0005, 0, 0, 1L, null, null, null);
View Full Code Here

    buffer = constructResponse(OpCode.DELETE.fieldValue(), (short) 0,
        (byte) 0, (byte) 0, (short) 0x0005, 0, 0, 1L, null, null, null);
    command = this.commandFactory.createDeleteCommand(this.key, this.keyBytes, 0,
        this.noreply);
    assertTrue(command.decode(null, buffer));
    assertFalse((Boolean) command.getResult());
    assertEquals(0, buffer.remaining());
  }

}
View Full Code Here

    for(ByteBuffer buffer:buffers){
      totalBuffer.put(buffer);
    }
    totalBuffer.flip();
   
    assertTrue(command.decode(null,totalBuffer));
    Map<String,CachedData> result=(Map<String, CachedData>)command.getResult();
   
    assertNotNull(result);
    assertEquals(5,result.size());
   
View Full Code Here

    Command command = this.commandFactory.createStatsCommand(null,
        new CountDownLatch(1), null);
    checkDecodeNullAndNotLineByteBuffer(command);
    checkDecodeInvalidLine(command,"stats", "OK\r\n");
    checkDecodeValidLine(command, "END\r\n");
    assertFalse(command.decode(null, ByteBuffer
        .wrap("STAT bytes 100\r\nSTAT threads 1\r\n".getBytes())));
    Map<String, String> result = (Map<String, String>) command.getResult();
    assertEquals("100", result.get("bytes"));
    assertEquals("1", result.get("threads"));
    checkDecodeValidLine(command, "STAT connections 5\r\nEND\r\n");
View Full Code Here

    ByteBuffer buffer = constructResponse(OpCode.GET.fieldValue(),
        (short) 0, (byte) 0x04, (byte) 0, (short) 0, 0x00000009, 0, 1L,
        this.transcoderUtils.encodeInt(0), null, "world".getBytes());

    assertEquals(33, buffer.capacity());
    assertTrue(command.decode(null, buffer));
    assertEquals("world", this.transcoder.decode((CachedData) command
        .getResult()));
    assertEquals(0, buffer.remaining());

    buffer = constructResponse(OpCode.GET.fieldValue(), (short) 0,
View Full Code Here

        (byte) 0x04, (byte) 0, (short) 0, 0x00000004, 0, 1L,
        this.transcoderUtils.encodeInt(0), null, null);
    assertEquals(28, buffer.capacity());
    command = this.commandFactory.createGetCommand(this.key, this.keyBytes,
        CommandType.GET_ONE, this.transcoder);
    assertTrue(command.decode(null, buffer));
    assertEquals(0, ((CachedData) command.getResult()).getData().length);
    assertEquals(0, buffer.remaining());
  }

}
View Full Code Here

    ByteBuffer buffer = constructResponse(OpCode.INCREMENT.fieldValue(), (short) 0,
        (byte) 0, (byte) 0, (short) 0, 0x00000008, 0, 5L, null, null,
        this.transcoderUtils.encodeLong(0L));
    assertEquals(32,buffer.capacity());
    assertTrue(command.decode(null, buffer));
    assertEquals(0L,command.getResult());
    assertEquals(0,buffer.remaining());
   
    command = this.commandFactory.createIncrDecrCommand(this.key, this.keyBytes,
        this.delta, this.initial, this.exp, CommandType.INCR, false);
View Full Code Here

        this.delta, this.initial, this.exp, CommandType.INCR, false);
    buffer = constructResponse(OpCode.INCREMENT.fieldValue(), (short) 0,
        (byte) 0, (byte) 0, (short) 0, 0x00000008, 0, 5L, null, null,
        this.transcoderUtils.encodeLong(9999L));
    assertEquals(32,buffer.capacity());
    assertTrue(command.decode(null, buffer));
    assertEquals(9999L,command.getResult());
    assertEquals(0,buffer.remaining());

  }
 
View Full Code Here

    ByteBuffer buffer = constructResponse(OpCode.DECREMENT.fieldValue(), (short) 0,
        (byte) 0, (byte) 0, (short) 0, 0x00000008, 0, 5L, null, null,
        this.transcoderUtils.encodeLong(0L));
    assertEquals(32,buffer.capacity());
    assertTrue(command.decode(null, buffer));
    assertEquals(0L,command.getResult());
    assertEquals(0,buffer.remaining());
   
    command = this.commandFactory.createIncrDecrCommand(this.key, this.keyBytes,
        this.delta, this.initial, this.exp, CommandType.DECR, false);
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.