Package net.rubyeye.xmemcached.command

Examples of net.rubyeye.xmemcached.command.Command


    command.encode();
    checkByteBufferEquals(command, "append test 0 0 2 noreply\r\n10\r\n");
  }

  public void testPrependEncode() {
    Command command = this.commandFactory.createPrependCommand(key, key
        .getBytes(), value, false, transcoder);
    assertNull(command.getIoBuffer());
    command.encode();
    checkByteBufferEquals(command, "prepend test 0 0 2\r\n10\r\n");

    command = this.commandFactory.createPrependCommand(key, key.getBytes(),
        value, true, transcoder);
    assertNull(command.getIoBuffer());
    command.encode();
    checkByteBufferEquals(command, "prepend test 0 0 2 noreply\r\n10\r\n");
  }
View Full Code Here


    command.encode();
    checkByteBufferEquals(command, "prepend test 0 0 2 noreply\r\n10\r\n");
  }

  public void testCASDecode() {
    Command command = this.commandFactory.createCASCommand(key, key
        .getBytes(), exp, value, cas, false, transcoder);
    checkDecodeNullAndNotLineByteBuffer(command);
    checkDecodeInvalidLine(command, "VALUE test 4 0 5\r\n");
    checkDecodeInvalidLine(command, "DELETED\r\n");
    checkDecodeValidLine(command, "STORED\r\n");
    assertTrue((Boolean) command.getResult());
    command.setResult(null);
    checkDecodeValidLine(command, "EXISTS\r\n");
    assertFalse((Boolean) command.getResult());
    command.setResult(null);
    checkDecodeValidLine(command, "STORED\r\n");
    assertTrue((Boolean) command.getResult());
    command.setResult(null);
    checkDecodeValidLine(command, "NOT_FOUND\r\n");
    assertFalse((Boolean) command.getResult());

  }
View Full Code Here

  }

  public void testIssue128() {
    // store command
    Command command = this.commandFactory.createSetCommand(key, key
        .getBytes(), exp, value, false, transcoder);
    command.decode(null, ByteBuffer
        .wrap("SERVER_ERROR out of memory storing object\r\n"
            .getBytes()));
    Exception e = command.getException();
    assertNotNull(e);
    assertEquals("out of memory storing object", e.getMessage());

    // cas command
    command = this.commandFactory.createCASCommand(key, key.getBytes(),
        exp, value, cas, false, transcoder);
    command.decode(null, ByteBuffer
        .wrap("SERVER_ERROR out of memory storing object\r\n"
            .getBytes()));
    e = command.getException();
    assertNotNull(e);
    assertEquals("out of memory storing object", e.getMessage());
  }
View Full Code Here

    assertNotNull(e);
    assertEquals("out of memory storing object", e.getMessage());
  }

  public void testStoreDecode() {
    Command command = this.commandFactory.createSetCommand(key, key
        .getBytes(), exp, value, false, transcoder);
    checkDecodeNullAndNotLineByteBuffer(command);
    checkDecodeInvalidLine(command, "EXISTS\r\n");
    checkDecodeInvalidLine(command, "END\r\n");
    checkDecodeValidLine(command, "STORED\r\n");
    assertTrue((Boolean) command.getResult());
    command.setResult(null);
    checkDecodeValidLine(command, "NOT_STORED\r\n");
    assertFalse((Boolean) command.getResult());
  }
View Full Code Here

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

public class TextIncrDecrCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncodeIncr() {
    Command command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0,0, CommandType.INCR, false);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "incr test 10\r\n");
   
    command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0,0, CommandType.INCR, true);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "incr test 10 noreply\r\n");
  }
View Full Code Here

    checkByteBufferEquals(command, "incr test 10 noreply\r\n");
  }

  public void testEncodeDecr() {
    Command command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0,0, CommandType.DECR, false);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "decr test 10\r\n");
   
    command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0,0, CommandType.DECR, true);
    assertNull(command.getIoBuffer());
    command.encode();

    checkByteBufferEquals(command, "decr test 10 noreply\r\n");
  }
View Full Code Here

    checkByteBufferEquals(command, "decr test 10 noreply\r\n");
  }

  public void testDecode() {
    Command command = this.commandFactory.createIncrDecrCommand("test",
        "test".getBytes(), 10, 0,0, CommandType.DECR, false);
    checkDecodeNullAndNotLineByteBuffer(command);
    try {
      command.decode(null, ByteBuffer.wrap("NOT_STORED\r\n".getBytes()));
      fail();
    } catch (NumberFormatException e) {
      assertEquals("For input string: \"NOT_STORED\"", e.getMessage());
    }
    try {
      command.decode(null, ByteBuffer.wrap("test\r\n".getBytes()));
      fail();
    } catch (NumberFormatException e) {
      assertEquals("For input string: \"test\"", e.getMessage());
    }
    try {
      command.decode(null, ByteBuffer.wrap("STORED\r\n".getBytes()));
      fail();
    } catch (NumberFormatException e) {
      assertEquals("For input string: \"STORED\"", e.getMessage());
    }
    try {
      command.decode(null, ByteBuffer.wrap("VALUE test\r\n".getBytes()));
      fail();
    } catch (NumberFormatException e) {
      assertEquals("For input string: \"VALUE test\"", e.getMessage());
    }
    checkDecodeValidLine(command, "NOT_FOUND\r\n");
    assertEquals("NOT_FOUND",command.getResult());
    checkDecodeValidLine(command, "3\r\n");
    assertEquals(3L,command.getResult());
  }
View Full Code Here

import net.rubyeye.xmemcached.command.Command;

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);
    command.encode();
    assertEquals("verbosity 1 noreply\r\n", new String(command
        .getIoBuffer().buf().array()));

  }
View Full Code Here

        .getIoBuffer().buf().array()));

  }

  public void testDecode() {
    Command command = this.commandFactory.createVerbosityCommand(
        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

import net.rubyeye.xmemcached.command.Command;
import net.rubyeye.xmemcached.command.text.TextFlushAllCommand;

public class TextFlushAllCommandUnitTest extends BaseTextCommandUnitTest {
  public void testEncode() {
    Command command = this.commandFactory.createFlushAllCommand(
        new CountDownLatch(1), 0, false);
    assertNull(command.getIoBuffer());
    command.encode();
    assertEquals(TextFlushAllCommand.FLUSH_ALL, command.getIoBuffer()
        .buf());

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

  }
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.