public void testOptimiezeGetWithSameKey() {
this.writeQueue.clear();
Queue<Command> localQueue = new SimpleQueue<Command>();
for (int i = 0; i < 10; i++) {
Command cmd = this.commandFactory.createGetCommand(String
.valueOf(0), String.valueOf(0).getBytes(),
CommandType.GET_ONE, null);
cmd.encode();
this.writeQueue.add(cmd);
cmd.setWriteFuture(new FutureImpl<Boolean>());
localQueue.add(cmd);
}
TextGetOneCommand optimiezeCommand = (TextGetOneCommand) this.optimiezer
.optimiezeGet(this.writeQueue, this.executingCmds,
this.currentCmd);
assertEquals(1, optimiezeCommand.getMergeCommands().size());
assertEquals(11, optimiezeCommand.getMergeCount());
assertEquals(0, this.writeQueue.size());
assertNull(this.writeQueue.peek());
assertSame(CommandType.GET_ONE, optimiezeCommand.getCommandType());
assertEquals(11, optimiezeCommand.getMergeCount());
assertEquals("get 0\r\n", new String(optimiezeCommand.getIoBuffer()
.buf().array()));
optimiezeCommand.decode(null, ByteBuffer.wrap("VALUE 0 0 2\r\n10\r\n"
.getBytes()));
assertEquals(0, this.currentCmd.getLatch().getCount());
Transcoder transcoder = new SerializingTranscoder();
assertEquals("10", transcoder.decode((CachedData) this.currentCmd
.getResult()));
for (Command cmd : localQueue) {
assertEquals(0, cmd.getLatch().getCount());
assertEquals("10", transcoder.decode((CachedData) this.currentCmd
.getResult()));
}
assertEquals(0, optimiezeCommand.getMergeCount());
}