final int flag = MessageFlagUtils.getFlag(null);
final PutCommand request =
new PutCommand(this.topic, partition, data, flag, CheckSum.crc32(data), null, opaque);
final long msgId = 100000L;
EasyMock.expect(this.remotingClient.isConnected(this.slaveUrl)).andReturn(true);
final MessageStore store = this.mocksControl.createMock(MessageStore.class);
EasyMock.expect(this.idWorker.nextId()).andReturn(msgId);
EasyMock.expect(this.storeManager.getOrCreateMessageStore(this.topic, partition)).andReturn(store);
final BooleanCommand expectResp =
new BooleanCommand(
HttpStatus.InternalServerError,
"Put message to [master 'meta://localhost:8123'] [partition 'SamsaCommandProcessorUnitTest-1'] failed",
opaque);
final AtomicBoolean invoked = new AtomicBoolean(false);
final PutCallback cb = new PutCallback() {
@Override
public void putComplete(final ResponseCommand resp) {
invoked.set(true);
System.out.println(((BooleanCommand) resp).getErrorMsg());
if (!expectResp.equals(resp)) {
throw new RuntimeException();
}
}
};
final SamsaCommandProcessor.SyncAppendCallback apdcb =
this.commandProcessor.new SyncAppendCallback(partition,
this.metaConfig.getBrokerId() + "-" + partition, request, msgId, cb);
store.append(msgId, request, apdcb);
EasyMock.expectLastCall().andAnswer(new IAnswer<Object>() {
@Override
public Object answer() throws Throwable {
((SamsaCommandProcessor.SyncAppendCallback) EasyMock.getCurrentArguments()[2]).appendComplete(Location