use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class SendMessageProcessorTest method testProcessRequest.
@Test
public void testProcessRequest() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK)));
assertPutResult(ResponseCode.SUCCESS);
}
use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class SendMessageProcessorTest method testProcessRequest_WithHook.
@Test
public void testProcessRequest_WithHook() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK)));
List<SendMessageHook> sendMessageHookList = new ArrayList<>();
final SendMessageContext[] sendMessageContext = new SendMessageContext[1];
SendMessageHook sendMessageHook = new SendMessageHook() {
@Override
public String hookName() {
return null;
}
@Override
public void sendMessageBefore(SendMessageContext context) {
sendMessageContext[0] = context;
}
@Override
public void sendMessageAfter(SendMessageContext context) {
}
};
sendMessageHookList.add(sendMessageHook);
sendMessageProcessor.registerSendMessageHook(sendMessageHookList);
assertPutResult(ResponseCode.SUCCESS);
System.out.println(sendMessageContext[0]);
assertThat(sendMessageContext[0]).isNotNull();
assertThat(sendMessageContext[0].getTopic()).isEqualTo(topic);
assertThat(sendMessageContext[0].getProducerGroup()).isEqualTo(group);
}
use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class SendMessageProcessorTest method testProcessRequest_FlushTimeOut.
@Test
public void testProcessRequest_FlushTimeOut() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.FLUSH_DISK_TIMEOUT, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
assertPutResult(ResponseCode.FLUSH_DISK_TIMEOUT);
}
use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class SendMessageProcessorTest method testProcessRequest_MessageIllegal.
@Test
public void testProcessRequest_MessageIllegal() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.MESSAGE_ILLEGAL, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
assertPutResult(ResponseCode.MESSAGE_ILLEGAL);
}
use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq-rocketmq-all-4.1.0-incubating by lirenzuo.
the class SendMessageProcessorTest method testProcessRequest_WithMsgBack.
@Test
public void testProcessRequest_WithMsgBack() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PUT_OK, new AppendMessageResult(AppendMessageStatus.PUT_OK)));
final RemotingCommand request = createSendMsgBackCommand(RequestCode.CONSUMER_SEND_MSG_BACK);
sendMessageProcessor = new SendMessageProcessor(brokerController);
final RemotingCommand response = sendMessageProcessor.processRequest(handlerContext, request);
assertThat(response).isNotNull();
assertThat(response.getCode()).isEqualTo(ResponseCode.SUCCESS);
}
Aggregations