Package net.rubyeye.xmemcached.command

Examples of net.rubyeye.xmemcached.command.Command


        .buf().array()));

  }
 
  public void testEncodeWithDelay(){
    Command command = this.commandFactory.createFlushAllCommand(
        new CountDownLatch(1), 10, false);
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals("flush_all 10\r\n", new String(command.getIoBuffer()
        .buf().array()));

    command = this.commandFactory.createFlushAllCommand(new CountDownLatch(
        1), 10, true);
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals("flush_all 10 noreply\r\n", new String(command.getIoBuffer()
        .buf().array()));
  }
View Full Code Here


    assertEquals("flush_all 10 noreply\r\n", new String(command.getIoBuffer()
        .buf().array()));
  }

  public void testDecode() {
    Command command = this.commandFactory.createFlushAllCommand(
        new CountDownLatch(1), 0, false);
    checkDecodeNullAndNotLineByteBuffer(command);
    checkDecodeInvalidLine(command, "END\r\n");
    checkDecodeInvalidLine(command, "STORED\r\n");
    checkDecodeValidLine(command, "OK\r\n");
View Full Code Here

* @author dennis
*
*/
public class TextStatsCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncode() {
    Command command = this.commandFactory.createStatsCommand(null,
        new CountDownLatch(1), null);
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals(TextStatsCommand.STATS, command.getIoBuffer().buf());
  }
View Full Code Here

    command.encode();
    assertEquals(TextStatsCommand.STATS, command.getIoBuffer().buf());
  }

  public void testItemEncode() {
    Command command = this.commandFactory.createStatsCommand(null,
        new CountDownLatch(1), "items");
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals(ByteBuffer.wrap("stats items\r\n".getBytes()), command
        .getIoBuffer().buf());
  }
View Full Code Here

    assertEquals(ByteBuffer.wrap("stats items\r\n".getBytes()), command
        .getIoBuffer().buf());
  }

  public void testDecode() {
    Command command = this.commandFactory.createStatsCommand(null,
        new CountDownLatch(1), null);
    checkDecodeNullAndNotLineByteBuffer(command);
    checkDecodeInvalidLine(command, "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");
    assertEquals(3, result.size());
    assertEquals("5", result.get("connections"));
View Full Code Here

import net.rubyeye.xmemcached.command.Command;

public class TextDeleteCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncode() {
    Command command = this.commandFactory.createDeleteCommand("test",
        "test".getBytes(), 10,false);
    assertNull(command.getIoBuffer());
    command.encode();
    checkByteBufferEquals(command, "delete test 10\r\n");
   
     command = this.commandFactory.createDeleteCommand("test",
          "test".getBytes(), 10,true);
      assertNull(command.getIoBuffer());
      command.encode();
      checkByteBufferEquals(command, "delete test 10 noreply\r\n");
  }
View Full Code Here

      command.encode();
      checkByteBufferEquals(command, "delete test 10 noreply\r\n");
  }

  public void testDecode() {
    Command command = this.commandFactory.createDeleteCommand("test",
        "test".getBytes(), 10,false);
    checkDecodeNullAndNotLineByteBuffer(command);
    checkDecodeInvalidLine(command, "STORED\r\n");
    checkDecodeInvalidLine(command, "VALUE test 4 5 1\r\n");
    checkDecodeInvalidLine(command, "END\r\n");
    checkDecodeValidLine(command, "NOT_FOUND\r\n");
    assertFalse((Boolean) command.getResult());
    command.setResult(null);
    checkDecodeValidLine(command, "DELETED\r\n");
    assertTrue((Boolean) command.getResult());
  }
View Full Code Here

import net.rubyeye.xmemcached.command.Command;
import net.rubyeye.xmemcached.command.ServerAddressAware;

public class TextVersionCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncode() {
    Command versionCommand = this.commandFactory.createVersionCommand(new CountDownLatch(1),null);
    assertNull(versionCommand.getIoBuffer());
    versionCommand.encode();
    assertEquals(ServerAddressAware.VERSION, versionCommand.getIoBuffer()
        .buf());
  }
View Full Code Here

    assertEquals(ServerAddressAware.VERSION, versionCommand.getIoBuffer()
        .buf());
  }

  public void testDecode() {
    Command versionCommand = this.commandFactory.createVersionCommand(new CountDownLatch(1),null);
    checkDecodeNullAndNotLineByteBuffer(versionCommand);
    checkDecodeInvalidLine(versionCommand, "test\r\n");

    checkDecodeValidLine(versionCommand, "VERSION\r\n");
    assertEquals("unknown version", versionCommand.getResult());

    checkDecodeValidLine(versionCommand, "VERSION 1.2.5\r\n");
    assertEquals("1.2.5", versionCommand.getResult());
  }
View Full Code Here

  static final int exp = 0;
  static final long cas = 999;
  static final Transcoder transcoder = new StringTranscoder();

  public void testCASEncode() {
    Command command = this.commandFactory.createCASCommand(key, key
        .getBytes(), exp, value, cas, false, transcoder);
    assertNull(command.getIoBuffer());
    command.encode();
    checkByteBufferEquals(command, "cas test 0 0 2 999\r\n10\r\n");
    command = this.commandFactory.createCASCommand(key, key.getBytes(),
        exp, value, cas, true, transcoder);
    command.encode();
    checkByteBufferEquals(command, "cas test 0 0 2 999 noreply\r\n10\r\n");
  }
View Full Code Here

TOP

Related Classes of net.rubyeye.xmemcached.command.Command

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.