use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class ExceptionReportServiceTest method testBug2356.
@Test
public void testBug2356() throws Exception {
ServiceImp failingService = new ThrowExceptionService(new ConfiguredException("Fail"));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_PAYLOAD);
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport()).withDocumentMerge(new InsertNode(XPATH_ROOT)));
MockMessageProducer mockProducer = new MockMessageProducer();
StandardProcessingExceptionHandler speh = new StandardProcessingExceptionHandler(new ServiceList(new Service[] { service, new StandaloneProducer(mockProducer) }));
MockChannel channel = new MockChannel();
MockMessageConsumer consumer = new MockMessageConsumer();
StandardWorkflow wf = new StandardWorkflow();
wf.getServiceCollection().add(failingService);
wf.setConsumer(consumer);
channel.setMessageErrorHandler(speh);
channel.getWorkflowList().add(wf);
try {
channel.prepare();
channel.requestStart();
consumer.submitMessage(msg);
assertEquals(1, mockProducer.getMessages().size());
AdaptrisMessage failedMessage = mockProducer.getMessages().get(0);
assertNotSame(XML_PAYLOAD, failedMessage.getContent());
XmlUtils xml = XmlHelper.createXmlUtils(failedMessage);
assertEquals(RAW_DATA, xml.getSingleTextItem(XPATH_ORIGINAL_NODE));
assertNotNull(xml.getSingleNode(XPATH_ROOT + "/Exception"));
String xmlElement = xml.getSingleTextItem(XPATH_ROOT + "/Exception");
assertTrue(xmlElement.contains("com.adaptris.core.services.exception.ThrowExceptionService.doService"));
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class FailedMessageRetrierCase method createWorkflow.
protected StandardWorkflow createWorkflow(String uniqueId) throws Exception {
AdaptrisMessageConsumer consumer = new MockMessageConsumer();
AdaptrisMessageProducer producer = new MockMessageProducer();
StandardWorkflow workflow = new StandardWorkflow();
workflow.setUniqueId(uniqueId);
workflow.setConsumer(consumer);
workflow.setProducer(producer);
Channel channel = new MockChannel();
channel.setUniqueId(null);
channel.getWorkflowList().add(workflow);
channel.prepare();
return workflow;
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class RequestReplyWorkflowTest method createChannel.
// private RequestReplyWorkflow workFlow;
// private MockMessageConsumer consumer;
// private MockRequestReplyProducer producer;
// private MockMessageProducer replyProducer;
private Channel createChannel() throws Exception {
Channel channel = new MockChannel();
MockMessageConsumer consumer = new MockMessageConsumer();
MockRequestReplyProducer producer = new MockRequestReplyProducer();
MockMessageProducer replyProducer = new MockMessageProducer();
RequestReplyWorkflow workFlow = new RequestReplyWorkflow();
workFlow.setConsumer(consumer);
workFlow.setProducer(producer);
workFlow.setReplyProducer(replyProducer);
channel.getWorkflowList().addWorkflow(workFlow);
channel.prepare();
return channel;
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class RequestReplyWorkflowTest method submitMessages.
private void submitMessages(Workflow wf, int number) {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx");
msg.addMetadata(REQUEST_METADATA_KEY, REQUEST_METADATA_VALUE);
MockMessageConsumer m = (MockMessageConsumer) wf.getConsumer();
for (int i = 0; i < number; i++) {
m.submitMessage(msg);
}
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class RequestReplyWorkflowTest method testWorkflow_NullReply.
@Test
public void testWorkflow_NullReply() throws Exception {
Channel channel = new MockChannel();
RequestReplyWorkflow workflow = new RequestReplyWorkflow();
workflow.setConsumer(new MockMessageConsumer());
AdaptrisMessageProducer replier = mock(AdaptrisMessageProducer.class);
doThrow(new ProduceException()).when(replier).produce(any(AdaptrisMessage.class));
doThrow(new ProduceException()).when(replier).produce(any(AdaptrisMessage.class));
when(replier.createName()).thenReturn("mock");
when(replier.createQualifier()).thenReturn("mock");
when(replier.isTrackingEndpoint()).thenReturn(false);
AdaptrisMessageProducer requestor = mock(AdaptrisMessageProducer.class);
when(requestor.request(any(AdaptrisMessage.class))).thenReturn(null);
when(requestor.request(any(AdaptrisMessage.class))).thenReturn(null);
when(requestor.request(any(AdaptrisMessage.class), anyLong())).thenReturn(null);
when(requestor.request(any(AdaptrisMessage.class), anyLong())).thenReturn(null);
when(requestor.createName()).thenReturn("mock");
when(requestor.createQualifier()).thenReturn("mock");
when(requestor.isTrackingEndpoint()).thenReturn(false);
workflow.setProducer(requestor);
workflow.setReplyProducer(replier);
channel.getWorkflowList().add(workflow);
try {
start(channel);
submitMessages(workflow, 1);
} finally {
stop(channel);
}
}
Aggregations