use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class StandardWorkflowTest method testOnMessage_ServiceFailsWithRetryHandlerFailureCallback.
@Test
public void testOnMessage_ServiceFailsWithRetryHandlerFailureCallback() throws Exception {
AtomicBoolean onSuccess = new AtomicBoolean(false);
MockChannel channel = createChannel(new MockMessageProducer(), Arrays.asList(new Service[] { new ThrowExceptionService(new ConfiguredException("expected")) }));
channel.setMessageErrorHandler(new RetryMessageErrorHandler(3, new TimeInterval(100l, TimeUnit.MILLISECONDS), new NullService()));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
StandardWorkflow workflow = (StandardWorkflow) channel.getWorkflowList().get(0);
try {
start(channel);
workflow.onAdaptrisMessage(msg, (m) -> {
onSuccess.set(true);
}, (m) -> {
onSuccess.set(false);
});
assertFalse(onSuccess.get());
} finally {
stop(channel);
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class StandardWorkflowTest method testOnMessage_ServiceFailsFailureCallback.
@Test
public void testOnMessage_ServiceFailsFailureCallback() throws Exception {
AtomicBoolean onSuccess = new AtomicBoolean(false);
MockChannel channel = createChannel(new MockMessageProducer(), Arrays.asList(new Service[] { new ThrowExceptionService(new ConfiguredException("expected")) }));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD_1);
StandardWorkflow workflow = (StandardWorkflow) channel.getWorkflowList().get(0);
try {
start(channel);
workflow.onAdaptrisMessage(msg, (m) -> {
onSuccess.set(true);
}, (m) -> {
onSuccess.set(false);
});
assertFalse(onSuccess.get());
} finally {
stop(channel);
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class StandardProcessingExceptionHandlerTest method testServiceListWithErrorWithBlankServiceId.
@Test
public void testServiceListWithErrorWithBlankServiceId() throws Exception {
StandardProcessingExceptionHandler meh = new StandardProcessingExceptionHandler();
MockMessageProducer producer = new MockMessageProducer();
try {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("XXXX");
ServiceList services = new ServiceList(Arrays.asList(new Service[] { new ThrowExceptionService(new ConfiguredException("Always Fail")), new StandaloneProducer(producer) }));
services.setUniqueId("");
meh.setProcessingExceptionService(services);
start(meh);
meh.handleProcessingException(msg);
assertTrue("Make sure none produced", producer.getMessages().size() == 0);
} finally {
stop(meh);
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class StandardProcessingExceptionHandlerTest method testMultipleErrorHandlers_AlwaysHandle_False.
@Test
public void testMultipleErrorHandlers_AlwaysHandle_False() throws Exception {
MockMessageProducer aep = new MockMessageProducer();
MockMessageProducer wep = new MockMessageProducer();
MockMessageProducer cep = new MockMessageProducer();
StandardProcessingExceptionHandler aeh = new StandardProcessingExceptionHandler(new StandaloneProducer(aep));
aeh.setAlwaysHandleException(false);
StandardProcessingExceptionHandler weh = new StandardProcessingExceptionHandler(new StandaloneProducer(wep));
StandardProcessingExceptionHandler ceh = new StandardProcessingExceptionHandler(new StandaloneProducer(cep));
Adapter adapter = AdapterTest.createAdapter(getName());
adapter.setMessageErrorHandler(aeh);
MockMessageConsumer consumer = new MockMessageConsumer();
adapter.getChannelList().clear();
adapter.getChannelList().add(createChannel(consumer, ceh, weh, new ThrowExceptionService(new ConfiguredException(getName()))));
try {
start(adapter);
consumer.submitMessage(AdaptrisMessageFactory.getDefaultInstance().newMessage());
assertEquals(0, aep.messageCount());
assertEquals(0, cep.messageCount());
assertEquals(1, wep.messageCount());
} finally {
stop(adapter);
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class BranchingHttpRequestServiceTest method retrieveObjectForSampleConfig.
@Override
protected BranchingServiceCollection retrieveObjectForSampleConfig() {
BranchingHttpRequestService service = createForExamples();
BranchingServiceCollection sl = new BranchingServiceCollection();
sl.addService(service);
sl.setFirstServiceId(service.getUniqueId());
sl.addService(new ThrowExceptionService("5XX Server Error", new ConfiguredException("Got 5XX error from server")));
sl.addService(new ThrowExceptionService("4XX Client Error", new ConfiguredException("Got 4XX error from server")));
sl.addService(new NullService("Not Found"));
sl.addService(new LogMessageService("2XX OK"));
sl.addService(new ThrowExceptionService("DefaultServiceId", new ConfiguredException("Unmatched Response")));
return sl;
}
Aggregations