RpcDispatcher.Marshaller mockMarshaller1 = mock(RpcDispatcher.Marshaller.class);
RpcDispatcher.Marshaller mockMarshaller = mock(RpcDispatcher.Marshaller.class);
PutKeyValueCommand putCommand = new PutKeyValueCommand();
putCommand.setKey(key);
putCommand.setValue(value);
SingleRpcCommand rpcCommand = new SingleRpcCommand("replSync");
Object[] params = new Object[]{putCommand};
rpcCommand.setParameters(SingleRpcCommand.COMMAND_ID, params);
when(mockMarshaller1.objectToBuffer(anyObject())).thenReturn(originalMarshaller1.objectToBuffer(rpcCommand));
when(mockMarshaller.objectFromBuffer((byte[]) anyObject(), anyInt(), anyInt())).thenThrow(new EOFException());
dispatcher1.setRequestMarshaller(mockMarshaller1);
dispatcher2.setRequestMarshaller(mockMarshaller);
cache1.put(key, value);