Package net.rubyeye.xmemcached.command

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


  public void testSetEncodeAndDecode() {

    Command command = this.commandFactory.createSetCommand(this.key, this.keyBytes,
        0, this.value, this.noreply, this.transcoder);

    command.encode();
    ByteBuffer encodeBuffer = command.getIoBuffer().buf();
    assertNotNull(encodeBuffer);
    assertEquals(42, encodeBuffer.capacity());

    byte opCode = encodeBuffer.get(1);
View Full Code Here


  public void testGetManyEncode() {
    Command command = this.commandFactory.createGetMultiCommand(keys,
        new CountDownLatch(1), CommandType.GET_MANY, transcoder);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "get test1 test2 test3 test4\r\n");

  }
View Full Code Here

  public void testDeleteEncodeAndDecode() {

    Command command = this.commandFactory.createDeleteCommand(this.key,
        this.keyBytes, 0, 999L, this.noreply);
    command.encode();
    ByteBuffer encodeBuffer = command.getIoBuffer().buf();
    assertNotNull(encodeBuffer);
    assertEquals(29, encodeBuffer.capacity());

    byte opCode = encodeBuffer.get(1);
View Full Code Here

  public void testGetsManyEncode() {
    Command command = this.commandFactory.createGetMultiCommand(keys,
        new CountDownLatch(1), CommandType.GETS_MANY, transcoder);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "gets test1 test2 test3 test4\r\n");
  }

  public void testGetManyDecode() {
View Full Code Here

  public void testGetEncodeAndDecode() {

    Command command = this.commandFactory.createGetAndTouchCommand(
        this.key, this.keyBytes, null, 10, false);

    command.encode();
    ByteBuffer encodeBuffer = command.getIoBuffer().buf();
    assertNotNull(encodeBuffer);
    assertEquals(24 + 4 + 5, encodeBuffer.capacity());

    byte opCode = encodeBuffer.get(1);
View Full Code Here

public class TextVerbositylCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncode() {
    Command command = this.commandFactory.createVerbosityCommand(
        new CountDownLatch(1), 1, false);
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals("verbosity 1\r\n", new String(command.getIoBuffer()
        .buf().array()));

    command = this.commandFactory.createVerbosityCommand(
        new CountDownLatch(1), 1, true);
View Full Code Here

    assertEquals("verbosity 1\r\n", new String(command.getIoBuffer()
        .buf().array()));

    command = this.commandFactory.createVerbosityCommand(
        new CountDownLatch(1), 1, true);
    command.encode();
    assertEquals("verbosity 1 noreply\r\n", new String(command
        .getIoBuffer().buf().array()));

  }
View Full Code Here

    String key = "test";
    byte[] keyBytes = ByteUtils.getBytes(key);
    int time = 10;
    Command deleteCmd = this.commandFactory.createDeleteCommand("test",
        keyBytes, time, 0, false);
    deleteCmd.encode();
    assertEquals(CommandType.DELETE, deleteCmd.getCommandType());
    String commandStr = new String(deleteCmd.getIoBuffer().buf()
        .array());

    String expectedStr = "delete test\r\n";
View Full Code Here

public class BinaryStatsCommandUnitTest extends BaseBinaryCommandUnitTest {
  public void testEncodeDecode() {
    Command command = this.commandFactory.createStatsCommand(
        new InetSocketAddress("localhost", 80), new CountDownLatch(1),
        null);
    command.encode();
    ByteBuffer encodeBuffer = command.getIoBuffer().buf();
    assertEquals(24, encodeBuffer.capacity());
    byte opCode = encodeBuffer.get(1);
    assertEquals(OpCode.STAT.fieldValue(), opCode);
View Full Code Here

    assertEquals(expectedStr, commandStr);
  }

  public void testCreateVersionCommand() {
    Command versionCmd = this.commandFactory.createVersionCommand(new CountDownLatch(1),null);
    versionCmd.encode();
    String commandStr = new String(versionCmd.getIoBuffer().buf()
        .array());
    assertEquals("version\r\n", commandStr);
    assertEquals(CommandType.VERSION, versionCmd.getCommandType());
  }
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.