use of com.adaptris.core.stubs.MockChannel 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.MockChannel in project interlok by adaptris.
the class MultiProducerWorkflowTest method testOnMessage_withConsumeLocation.
@Test
public void testOnMessage_withConsumeLocation() throws Exception {
MockMessageProducer producer = new MockMessageProducer();
MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { producer }), Arrays.asList(new Service[] { new NullService() }));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
msg.addMessageHeader(getName(), "hello world");
MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
workflow.setConsumer(new ConsumerWithLocation(getName()));
try {
start(channel);
workflow.onAdaptrisMessage(msg);
AdaptrisMessage consumed = producer.getMessages().get(0);
assertTrue(consumed.headersContainsKey(CoreConstants.MESSAGE_CONSUME_LOCATION));
assertEquals("hello world", consumed.getMetadataValue(CoreConstants.MESSAGE_CONSUME_LOCATION));
} finally {
stop(channel);
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class MultiProducerWorkflowTest method testToString.
@Test
public void testToString() throws Exception {
MockMessageProducer mock1 = new MockMessageProducer();
MockMessageProducer mock2 = new MockMessageProducer();
MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
assertNotNull(workflow.toString());
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class MultiProducerWorkflowTest method testHandleAdditionalProducerProduceException.
@Test
public void testHandleAdditionalProducerProduceException() throws Exception {
MockMessageProducer mock1 = new MockMessageProducer() {
@Override
protected void doProduce(AdaptrisMessage msg, String endpoint) throws ProduceException {
throw new ProduceException();
}
};
MockMessageProducer mock2 = new MockMessageProducer();
MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
try {
MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
workflow.setUseProcessedMessage(false);
channel.prepare();
channel.requestStart();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
workflow.onAdaptrisMessage(msg);
assertEquals(0, mock1.getMessages().size());
assertEquals(1, mock2.getMessages().size());
assertEquals(ORIGINAL_PAYLOAD, mock2.getMessages().get(0).getContent());
} finally {
channel.requestClose();
}
}
use of com.adaptris.core.stubs.MockChannel in project interlok by adaptris.
the class MultiProducerWorkflowTest method testUseOriginalMessage.
@Test
public void testUseOriginalMessage() throws Exception {
MockMessageProducer mock1 = new MockMessageProducer();
MockMessageProducer mock2 = new MockMessageProducer();
MockChannel channel = createChannel(Arrays.asList(new AdaptrisMessageProducer[] { mock1, mock2 }), Arrays.asList(new Service[] { new PayloadFromTemplateService().withTemplate(MODIFIED_PAYLOAD) }));
try {
MultiProducerWorkflow workflow = (MultiProducerWorkflow) channel.getWorkflowList().get(0);
workflow.setUseProcessedMessage(false);
channel.prepare();
channel.requestStart();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ORIGINAL_PAYLOAD);
workflow.onAdaptrisMessage(msg);
assertEquals(1, mock1.getMessages().size());
assertEquals(ORIGINAL_PAYLOAD, mock1.getMessages().get(0).getContent());
assertEquals(1, mock2.getMessages().size());
assertEquals(ORIGINAL_PAYLOAD, mock2.getMessages().get(0).getContent());
} finally {
channel.requestClose();
}
}
Aggregations