public void _testErrorCommand() throws Exception { Command nonexisCmd = new Command() { @Override public boolean decode(MemcachedTCPSession session, ByteBuffer buffer) { return decodeError(ByteUtils.nextLine(buffer)); } @Override public void encode() { ioBuffer = IoBuffer.wrap(ByteBuffer.wrap("test\r\n".getBytes())); } }; nonexisCmd.setKey("test"); nonexisCmd.setLatch(new CountDownLatch(1)); memcachedClient.getConnector().send(nonexisCmd); // this.memcachedClient.flushAll(); nonexisCmd.getLatch().await(); assertNotNull(nonexisCmd.getException()); assertEquals( "Nonexist command,check your memcached version please.", nonexisCmd.getException().getMessage()); assertTrue(nonexisCmd.getException() instanceof UnknownCommandException); memcachedClient.set("name", 0, "dennis"); assertEquals("dennis", memcachedClient.get("name")); }