use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class AdvancedMessageSplitterServiceTest method testDoServiceWithFailures_SendEventsTrue.
@Test
public void testDoServiceWithFailures_SendEventsTrue() 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(true);
try {
ExampleServiceCase.execute(service, msg);
fail("Expecting failure from AlwaysFailService");
} catch (ServiceException expected) {
;
}
LifecycleHelper.stopAndClose(eh);
assertEvents(ehp, 1, MessageLifecycleEvent.class);
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class MultipartMessageBuilderTest method testService_Exception.
@Test
public void testService_Exception() throws Exception {
AdaptrisMessage msg = new DefectiveMessageFactory(WhenToBreak.OUTPUT).newMessage("Hello World");
MultipartMessageBuilder service = new MultipartMessageBuilder().withMimeParts(new InlineMimePartBuilder());
try {
ExampleServiceCase.execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class RegexpServiceTest method testService_Exception.
@Test
public void testService_Exception() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(ALTERNATE_PAYLOAD);
RegexpService s = new RegexpService();
s.getExecutions().add(new Execution(new DodgyInputParameter(), new MetadataDataOutputParameter(TARGET_METADATA_KEY)));
try {
execute(s, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class SyntaxRoutingServiceTest method testDoServiceNoMatch.
@Test
public void testDoServiceNoMatch() throws Exception {
SyntaxRoutingService service = new SyntaxRoutingService();
service.setRoutingKey(ROUTING_KEY);
service.setSyntaxIdentifiers(createStandardIdentifiers());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage("The quick brown fox");
try {
execute(service, msg);
fail();
} catch (ServiceException e) {
assertEquals("Unable to identify the message syntax for routing", e.getMessage());
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class MetadataComparisonServiceTest method testCompareTimestamp_Fails.
@Test
public void testCompareTimestamp_Fails() throws Exception {
MetadataComparisonService s = new MetadataComparisonService(KEY_1, KEY_2, new CompareTimestamps());
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
msg.addMetadata(KEY_1, sdf.format(new Date(1)));
msg.addMetadata(KEY_2, sdf.format(new Date()));
try {
execute(s, msg);
fail();
} catch (ServiceException expected) {
}
}
Aggregations