use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.
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 by apache.
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 by apache.
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);
}
use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.
the class SendMessageProcessorTest method testProcessRequest_PropertiesTooLong.
@Test
public void testProcessRequest_PropertiesTooLong() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.PROPERTIES_SIZE_EXCEEDED, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
assertPutResult(ResponseCode.MESSAGE_ILLEGAL);
}
use of org.apache.rocketmq.store.AppendMessageResult in project rocketmq by apache.
the class SendMessageProcessorTest method testProcessRequest_FlushSlaveTimeout.
@Test
public void testProcessRequest_FlushSlaveTimeout() throws RemotingCommandException {
when(messageStore.putMessage(any(MessageExtBrokerInner.class))).thenReturn(new PutMessageResult(PutMessageStatus.FLUSH_SLAVE_TIMEOUT, new AppendMessageResult(AppendMessageStatus.UNKNOWN_ERROR)));
assertPutResult(ResponseCode.FLUSH_SLAVE_TIMEOUT);
}
Aggregations