use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class AdvancedMessageSplitterServiceTest method testDoServiceWithFailures_SendEventsFalse.
@Test
public void testDoServiceWithFailures_SendEventsFalse() throws Exception {
MockMessageProducer producer = new MockMessageProducer();
AdaptrisMessage msg = createMessage(REGEXP_DATA);
AdvancedMessageSplitterService service = createAdvanced(new SimpleRegexpMessageSplitter("\\|"), new Service[] { new ThrowExceptionService(new ConfiguredException("Fail")), new StandaloneProducer(producer) });
DefaultEventHandler eh = new DefaultEventHandler();
MockMessageProducer ehp = new MockMessageProducer();
eh.setProducer(ehp);
LifecycleHelper.initAndStart(eh);
service.registerEventHandler(eh);
service.setSendEvents(false);
try {
ExampleServiceCase.execute(service, msg);
fail("Expecting failure from AlwaysFailService");
} catch (ServiceException expected) {
;
}
LifecycleHelper.stopAndClose(eh);
assertEvents(ehp, 0, MessageLifecycleEvent.class);
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class AdvancedMessageSplitterServiceTest method testDoServiceWithFailures.
@Test
public void testDoServiceWithFailures() throws Exception {
MockMessageProducer producer = new MockMessageProducer();
AdaptrisMessage msg = createMessage(REGEXP_DATA);
AdvancedMessageSplitterService service = createAdvanced(new SimpleRegexpMessageSplitter("\\|"), new Service[] { new ThrowExceptionService(new ConfiguredException("Fail")), new StandaloneProducer(producer) });
try {
ExampleServiceCase.execute(service, msg);
fail("Expecting failure from AlwaysFailService");
} catch (ServiceException expected) {
;
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class AdvancedMessageSplitterServiceTest method testDoServiceWithFailures_NullEventHandler.
@Test
public void testDoServiceWithFailures_NullEventHandler() throws Exception {
MockMessageProducer producer = new MockMessageProducer();
AdaptrisMessage msg = createMessage(REGEXP_DATA);
AdvancedMessageSplitterService service = createAdvanced(new SimpleRegexpMessageSplitter("\\|"), new Service[] { new ThrowExceptionService(new ConfiguredException("Fail")), new StandaloneProducer(producer) });
service.registerEventHandler(null);
try {
ExampleServiceCase.execute(service, msg);
fail("Expecting failure from AlwaysFailService");
} catch (ServiceException expected) {
;
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class SwitchTest method testService_Failure.
@Test
public void testService_Failure() throws Exception {
Switch service = createForTests();
service.getCases().add(new Case().withCondition(new CaseDefault()).withService(new ThrowExceptionService(new ConfiguredException("always-fail"))));
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata("myKey", "17");
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.services.exception.ThrowExceptionService in project interlok by adaptris.
the class JmsTransactedWorkflowTest method retrieveObjectForSampleConfig.
@Override
protected Object retrieveObjectForSampleConfig() {
Channel c = new Channel();
try {
c.setUniqueId(UUID.randomUUID().toString());
c.setConsumeConnection(configure(new JmsConnection()));
JmsTransactedWorkflow workflow = createWorkflow("Sample_Queue_1");
workflow.setUniqueId(UUID.randomUUID().toString());
workflow.setWaitPeriodAfterRollback(new TimeInterval(30L, TimeUnit.SECONDS.name()));
workflow.getServiceCollection().addService(new WaitService());
workflow.getServiceCollection().addService(new ThrowExceptionService(new ConfiguredException("Fail")));
workflow.setProducer(new FsProducer().withBaseDirectoryUrl("file:////path/to/directory"));
c.getWorkflowList().add(workflow);
} catch (CoreException e) {
throw new RuntimeException(e);
}
return c;
}
Aggregations