public void testProcessingActions() throws Exception {
MockEndpoint outboundEndpoint = getProcessedMessagesEndpoint(1);
MockEndpoint failedEndpoint = getFailedMessagesEndpoint(0);
MockProcessor processor = new MockProcessor();
ConnectorService processorService = new MockConnectorService("test", processor, resourceRegistry);
// add a pre-processing action
MockAction preProcessingAction = new MockAction();
processorService.addPreProcessingAction(preProcessingAction);
// add another pre-processing action that changes the message
processorService.addPreProcessingAction(new Action() {
@Override
public void execute(Message message) throws Exception {
Message smsMessage = (Message) message;
smsMessage.setProperty("from", "1234");
}
});
// add a post-processing action
MockAction postProcessingAction = new MockAction();
processorService.addPostProcessingAction(postProcessingAction);
// add another post-processing action that changes the message
processorService.addPostProcessingAction(new Action() {
@Override
public void execute(Message message) throws Exception {
Message smsMessage = (Message) message;
smsMessage.setProperty("to", "1111");
}
});
processorService.start();
simulateMessage(new Message(), "activemq:mokai-test");
outboundEndpoint.assertIsSatisfied(DEFAULT_TIMEOUT);
failedEndpoint.assertIsSatisfied(DEFAULT_TIMEOUT);