Search in sources :

Example 21 with ServiceException

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) {
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ServiceList(com.adaptris.core.ServiceList) Service(com.adaptris.core.Service) LogMessageService(com.adaptris.core.services.LogMessageService) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) MetadataElement(com.adaptris.core.MetadataElement) AddMetadataService(com.adaptris.core.services.metadata.AddMetadataService) Test(org.junit.Test)

Example 22 with ServiceException

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.
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) Test(org.junit.Test)

Example 23 with ServiceException

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) {
        ;
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) ReplaceNode(com.adaptris.util.text.xml.ReplaceNode) ServiceException(com.adaptris.core.ServiceException) CoreException(com.adaptris.core.CoreException) Test(org.junit.Test)

Example 24 with ServiceException

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());
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Example 25 with ServiceException

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());
    }
}
Also used : ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) Test(org.junit.Test)

Aggregations

ServiceException (com.adaptris.core.ServiceException)236 Test (org.junit.Test)172 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)161 CoreException (com.adaptris.core.CoreException)45 DefaultMessageFactory (com.adaptris.core.DefaultMessageFactory)26 StandaloneProducer (com.adaptris.core.StandaloneProducer)18 MetadataElement (com.adaptris.core.MetadataElement)17 ValidationStage (com.adaptris.transform.validate.ValidationStage)16 Cache (com.adaptris.core.cache.Cache)15 DefectiveMessageFactory (com.adaptris.core.stubs.DefectiveMessageFactory)13 TimeInterval (com.adaptris.util.TimeInterval)13 MockMessageProducer (com.adaptris.core.stubs.MockMessageProducer)11 Connection (java.sql.Connection)10 File (java.io.File)9 IOException (java.io.IOException)9 OutputStream (java.io.OutputStream)9 SQLException (java.sql.SQLException)9 InputStream (java.io.InputStream)8 Document (org.w3c.dom.Document)8 Channel (com.adaptris.core.Channel)7