use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class DynamicServiceExecutorTest method testDoService_MimeServiceExtractor_NullSelector.
@Test
public void testDoService_MimeServiceExtractor_NullSelector() throws Exception {
AddMetadataService metadataService = new AddMetadataService();
metadataService.addMetadataElement(new MetadataElement(getName(), getName()));
DynamicServiceExecutor dynamicService = createService();
dynamicService.setServiceExtractor(new MimeServiceExtractor());
AdaptrisMessage msg = createMimeMessage(new ServiceList(new Service[] { metadataService }), ENCODING_BASE64);
try {
execute(dynamicService, msg);
fail();
} catch (ServiceException expected) {
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class WhileTest method testInnerServiceExceptionPropagated.
@Test
public void testInnerServiceExceptionPropagated() throws Exception {
when(mockCondition.evaluate(message)).thenReturn(true);
doThrow(new ServiceException()).when(mockService).doService(message);
try {
logicalExpression.doService(message);
fail("Expected a service exception");
} catch (ServiceException ex) {
// expected.
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ExceptionReportServiceTest method testNonXml.
@Test
public void testNonXml() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage(RAW_DATA);
msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception("This is the exception"));
ExceptionReportService service = new ExceptionReportService(new ExceptionAsXml().withExceptionGenerator(new SimpleExceptionReport()).withDocumentMerge(new ReplaceNode(XPATH_ORIGINAL_NODE)));
try {
execute(service, msg);
fail("success with non-xml payload");
} catch (ServiceException expected) {
;
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ThrowExceptionServiceTest method testDefaultExceptionFromMetadata.
@Test
public void testDefaultExceptionFromMetadata() throws Exception {
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
ThrowExceptionService service = new ThrowExceptionService(new ExceptionFromMetadata());
try {
execute(service, msg);
fail("Expected Exception");
} catch (ServiceException e) {
assertNull(e.getMessage());
}
}
use of com.adaptris.core.ServiceException in project interlok by adaptris.
the class ThrowExceptionServiceTest method testExceptionFromMetadataNoConfiguredMessage.
@Test
public void testExceptionFromMetadataNoConfiguredMessage() throws Exception {
ExceptionFromMetadata em = new ExceptionFromMetadata();
em.setExceptionMessageMetadataKey(METADATA_KEY);
AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
msg.addMetadata(METADATA_KEY, METADATA_VALUE);
try {
execute(new ThrowExceptionService(em), msg);
fail("Expected Exception");
} catch (ServiceException e) {
assertEquals(METADATA_VALUE, e.getMessage());
}
}
Aggregations