use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class AdaptrisConnectionTest method testCloseWithWorkerLifecycle.
@Test
public void testCloseWithWorkerLifecycle() throws Exception {
MockConnection mc = new MockConnection();
List<MockMessageConsumer> consumers = createConsumers();
List<MockMessageProducer> producers = createProducers();
for (MockMessageConsumer c : consumers) {
mc.addMessageConsumer(c);
}
for (MockMessageProducer c : producers) {
mc.addMessageProducer(c);
}
mc.setWorkersFirstOnShutdown(true);
invoke(mc, INIT);
invoke(producers, INIT);
invoke(consumers, INIT);
invoke(mc, START);
invoke(producers, START);
invoke(consumers, START);
invoke(mc, STOP);
assertState(producers, StoppedState.getInstance());
assertState(consumers, StoppedState.getInstance());
invoke(mc, CLOSE);
assertState(producers, ClosedState.getInstance());
assertState(consumers, ClosedState.getInstance());
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class DefaultFailedMessageRetrierTest method testRoundTrip_AdapterRetry.
@Test
public void testRoundTrip_AdapterRetry() throws Exception {
AdaptrisMarshaller marshaller = DefaultMarshaller.getDefaultMarshaller();
Adapter adapter = (Adapter) marshaller.unmarshal(marshaller.marshal(createAdapterForRetry(create(), new StandardProcessingExceptionHandler(new StandaloneProducer(new MockMessageProducer())))));
DefaultFailedMessageRetrier retrier = (DefaultFailedMessageRetrier) adapter.getFailedMessageRetrier();
MockMessageProducer errProd = getErrorHandler(adapter);
try {
FailFirstMockMessageProducer workflowProducer = (FailFirstMockMessageProducer) adapter.getChannelList().get(0).getWorkflowList().get(0).getProducer();
MockMessageConsumer consumer = (MockMessageConsumer) adapter.getChannelList().get(0).getWorkflowList().get(0).getConsumer();
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("ABCDEF");
start(adapter);
consumer.submitMessage(msg);
// SHould have failed
assertEquals(1, errProd.messageCount());
retrier.onAdaptrisMessage(errProd.getMessages().get(0));
assertTrue(msg.containsKey(CoreConstants.RETRY_COUNT_KEY));
assertEquals("1", msg.getMetadataValue(CoreConstants.RETRY_COUNT_KEY));
assertEquals(1, workflowProducer.getMessages().size());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class DefaultFailedMessageRetrierTest method createAdapterForRetry.
private Adapter createAdapterForRetry(FailedMessageRetrier retrier, ProcessingExceptionHandler errorHandler) throws Exception {
Adapter adapter = AdapterTest.createAdapter(getName());
adapter.setFailedMessageRetrier(retrier);
adapter.setMessageErrorHandler(errorHandler);
adapter.getChannelList().clear();
Channel c = new Channel();
c.setUniqueId(getName());
StandardWorkflow wf = new StandardWorkflow();
wf.setUniqueId(getName());
wf.setConsumer(new MockMessageConsumer());
wf.setProducer(new FailFirstMockMessageProducer());
c.getWorkflowList().add(wf);
adapter.getChannelList().add(c);
return adapter;
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class WorkflowLifecycleStrategyCase method configure.
protected Workflow configure(WorkflowImp wf, String uid) {
wf.setUniqueId(uid);
wf.setConsumer(new MockMessageConsumer());
return wf;
}
use of com.adaptris.core.stubs.MockMessageConsumer in project interlok by adaptris.
the class WorkflowListTest method createWorkflow.
private StandardWorkflow createWorkflow(String uid) {
StandardWorkflow result = new StandardWorkflow();
result.setUniqueId(uid);
result.setConsumer(new MockMessageConsumer());
return result;
}
Aggregations