Search in sources :

Example 1 with DataOutputParameter

use of com.adaptris.interlok.config.DataOutputParameter in project interlok by adaptris.

the class ExceptionAsStringReportTest method testDoService_Payload_Exception.

@Test
public void testDoService_Payload_Exception() throws Exception {
    AdaptrisMessage msg = AdaptrisMessageFactory.getDefaultInstance().newMessage();
    msg.addObjectHeader(CoreConstants.OBJ_METADATA_EXCEPTION, new Exception("This is the exception"));
    ExceptionReportService service = new ExceptionReportService(new ExceptionAsString().withTarget(new DataOutputParameter<String>() {

        @Override
        public void insert(String data, InterlokMessage msg) throws InterlokException {
            throw new CoreException();
        }
    }));
    try {
        execute(service, msg);
        fail();
    } catch (ServiceException expected) {
    }
}
Also used : DataOutputParameter(com.adaptris.interlok.config.DataOutputParameter) MetadataDataOutputParameter(com.adaptris.core.common.MetadataDataOutputParameter) CoreException(com.adaptris.core.CoreException) ServiceException(com.adaptris.core.ServiceException) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) InterlokMessage(com.adaptris.interlok.types.InterlokMessage) CoreException(com.adaptris.core.CoreException) ServiceException(com.adaptris.core.ServiceException) InterlokException(com.adaptris.interlok.InterlokException) Test(org.junit.Test)

Aggregations

AdaptrisMessage (com.adaptris.core.AdaptrisMessage)1 CoreException (com.adaptris.core.CoreException)1 ServiceException (com.adaptris.core.ServiceException)1 MetadataDataOutputParameter (com.adaptris.core.common.MetadataDataOutputParameter)1 InterlokException (com.adaptris.interlok.InterlokException)1 DataOutputParameter (com.adaptris.interlok.config.DataOutputParameter)1 InterlokMessage (com.adaptris.interlok.types.InterlokMessage)1 Test (org.junit.Test)1