public void testLineParser() throws Exception {
    String input = "This is a multiline string\r\nhere is line two\r\n";
    ByteBuffer b = ByteBuffer.wrap(input.getBytes());
    SimpleOp op = new SimpleOp(OperationReadType.LINE);
    op.linesToRead = 2;
    op.readFromBuffer(b);
    assertEquals("This is a multiline string", op.getLines().get(0));
    assertEquals("here is line two", op.getLines().get(1));
    op.setBytesToRead(2);
    op.readFromBuffer(ByteBuffer.wrap("xy".getBytes()));
    byte[] expected = { 'x', 'y' };
    assertTrue("Expected " + Arrays.toString(expected) + " but got "
        + Arrays.toString(op.getCurentBytes()),
        Arrays.equals(expected, op.getCurentBytes()));
  }
Test the basic operation buffer handling stuff.
src/test/java/net/spy/memcached/protocol/ascii/BaseOpTest.java