use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class RetryMessageErrorHandlerTest method createWorkflow.
private StandardWorkflow createWorkflow(AdaptrisMessageProducer producer, Service[] services) throws Exception {
StandardWorkflow workflow = new StandardWorkflow();
workflow.setConsumer(new MockMessageConsumer());
workflow.setProducer(producer);
workflow.getServiceCollection().addAll(Arrays.asList(services));
return workflow;
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class StandaloneConsumerTest method testSetAdaptrisMessageListener.
@Test
public void testSetAdaptrisMessageListener() throws Exception {
MockMessageProducer prod = new MockMessageProducer();
StandardWorkflow aml1 = new StandardWorkflow();
aml1.setConsumer(new MockMessageConsumer());
aml1.setProducer(prod);
Channel channel = new MockChannel();
channel.getWorkflowList().add(aml1);
channel.prepare();
LifecycleHelper.init(aml1);
LifecycleHelper.start(aml1);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("xxx");
aml1.onAdaptrisMessage(msg);
// test the WF directly...
assertTrue(prod.getMessages().size() == 1);
MockMessageConsumer consumer1 = new MockMessageConsumer();
StandaloneConsumer sc = new StandaloneConsumer();
sc.setConsumer(consumer1);
sc.registerAdaptrisMessageListener(aml1);
LifecycleHelper.init(sc);
consumer1.submitMessage(msg);
// basic test SC...
assertTrue(((MockMessageProducer) aml1.getProducer()).getMessages().size() == 2);
stop(sc);
stop(channel);
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class PoolingWorkflowTest method testOnMessage_WithConsumeLocation.
@Test
public void testOnMessage_WithConsumeLocation() throws Exception {
MockChannel channel = createChannel();
PoolingWorkflow wf = (PoolingWorkflow) channel.getWorkflowList().get(0);
MockMessageProducer prod = (MockMessageProducer) wf.getProducer();
wf.setConsumer(new ConsumerWithLocation(getName()));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMessageHeader(getName(), "hello world");
try {
start(channel);
MockMessageConsumer m = (MockMessageConsumer) wf.getConsumer();
m.submitMessage(msg);
waitForMessages(prod, 1);
AdaptrisMessage consumed = prod.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.MockMessageConsumer in project interlok by adaptris.
the class PoolingWorkflowTest method submitMessages.
private void submitMessages(PoolingWorkflow wf, int number) throws Exception {
MockMessageConsumer m = (MockMessageConsumer) wf.getConsumer();
for (int i = 0; i < number; i++) {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(String.valueOf(i));
msg.addMetadata(COUNT, String.valueOf(i));
m.submitMessage(msg);
}
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class PoolingWorkflowTest method buildChannel.
private MockChannel buildChannel(List<Service> services) throws Exception {
MockChannel channel = new MockChannel();
PoolingWorkflow wf = new PoolingWorkflow();
MockMessageConsumer consumer = new MockMessageConsumer();
MockMessageProducer producer = new MockMessageProducer();
wf.getServiceCollection().addAll(services);
wf.setConsumer(consumer);
wf.setProducer(producer);
channel.getWorkflowList().add(wf);
return channel;
}
Aggregations