use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class RegexpMetadataServiceTest method testServiceNotAllowNulls.
@Test
public void testServiceNotAllowNulls() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(PAYLOAD);
RegexpMetadataService service = createService();
execute(service, msg);
try {
msg.setContent(ALTERNATE_PAYLOAD, msg.getContentEncoding());
execute(service, msg);
fail("Expected serviceException");
} catch (ServiceException expected) {
;
}
assertTrue("message contains key1", msg.containsKey("postcode"));
assertEquals("Found the post-code", "UB3 5AN", msg.getMetadataValue("postcode"));
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class MetadataToPayloadTest method testService_NoMetadata.
@Test
public void testService_NoMetadata() throws Exception {
MetadataToPayloadService service = new MetadataToPayloadService("DoesNotExistKey", MetadataSource.Standard);
AdaptrisMessage msg = createMessage(false);
try {
execute(service, msg);
fail("Should fail with no key found");
} catch (ServiceException ex) {
// expected.
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class PoolingMessageSplitterServiceTest method testServiceWithFailures.
@Test
public void testServiceWithFailures() throws Exception {
PoolingMessageSplitterService service = SplitterCase.createPooling(new XpathMessageSplitter("/envelope/document", "UTF-8"), new AlwaysFailService()).withWaitWhileBusy(true);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(XML_MESSAGE);
XpathMessageSplitter splitter = new XpathMessageSplitter("/envelope/document", "UTF-8");
try {
execute(service, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ServiceExceptionHandlerTest method testThrowFirst.
@Test
@SuppressWarnings("deprecation")
public void testThrowFirst() throws Exception {
ServiceExceptionHandler handler = new ServiceExceptionHandler();
handler.uncaughtException(Thread.currentThread(), new ServiceException("first"));
handler.uncaughtException(Thread.currentThread(), new ServiceException("second"));
try {
handler.throwFirstException();
fail();
} catch (ServiceException expected) {
assertEquals("first", expected.getMessage());
assertEquals(1, expected.getSuppressed().length);
}
assertNull(handler.getFirstThrowableException());
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class AdvancedMessageSplitterServiceTest method testDoServiceWithFailures_NullEventHandler_SendEvents.
@Test
public void testDoServiceWithFailures_NullEventHandler_SendEvents() 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);
service.setSendEvents(true);
try {
ExampleServiceCase.execute(service, msg);
fail("Expecting failure from AlwaysFailService");
} catch (ServiceException expected) {
;
}
}
Aggregations