Search in sources :

Example 1 with InterlokMessage

use of com.adaptris.interlok.types.InterlokMessage in project interlok by adaptris.

the class BlobListRendererTest method testRender.

@Test
public void testRender() throws Exception {
    InterlokMessage msg = Mockito.mock(InterlokMessage.class);
    StringWriter writer = new StringWriter();
    Mockito.when(msg.getWriter()).thenReturn(writer);
    BlobListRenderer render = new BlobListRenderer() {
    };
    Collection<RemoteBlob> blobs = createBlobs(10);
    render.render(blobs, msg);
    assertEquals(10, IOUtils.readLines(new StringReader(writer.toString())).size());
}
Also used : StringWriter(java.io.StringWriter) InterlokMessage(com.adaptris.interlok.types.InterlokMessage) StringReader(java.io.StringReader) Test(org.junit.Test)

Example 2 with InterlokMessage

use of com.adaptris.interlok.types.InterlokMessage in project interlok by adaptris.

the class BlobListRendererTest method testRender_Fail.

@Test
public void testRender_Fail() throws Exception {
    InterlokMessage msg = Mockito.mock(InterlokMessage.class);
    StringWriter writer = new StringWriter();
    Mockito.when(msg.getWriter()).thenThrow(new IOException());
    BlobListRenderer render = new BlobListRenderer() {
    };
    Collection<RemoteBlob> blobs = createBlobs(10);
    try {
        render.render(blobs, msg);
        fail();
    } catch (InterlokException expected) {
    }
}
Also used : InterlokException(com.adaptris.interlok.InterlokException) StringWriter(java.io.StringWriter) InterlokMessage(com.adaptris.interlok.types.InterlokMessage) IOException(java.io.IOException) Test(org.junit.Test)

Example 3 with InterlokMessage

use of com.adaptris.interlok.types.InterlokMessage in project interlok by adaptris.

the class FileDataInputParameterTest method testInterlokMessage.

@Test(expected = RuntimeException.class)
public void testInterlokMessage() throws Exception {
    InterlokMessage msg = Mockito.mock(InterlokMessage.class);
    FileDataInputParameter p = new FileDataInputParameter();
    p.setUrl("file:////tmp/doesnotexist");
    p.url(msg);
}
Also used : InterlokMessage(com.adaptris.interlok.types.InterlokMessage) Test(org.junit.Test)

Example 4 with InterlokMessage

use of com.adaptris.interlok.types.InterlokMessage in project interlok by adaptris.

the class FileInputStreamDataInputParameterTest method testInterlokMessage.

@Test(expected = RuntimeException.class)
public void testInterlokMessage() throws Exception {
    InterlokMessage msg = Mockito.mock(InterlokMessage.class);
    FileInputStreamDataInputParameter p = new FileInputStreamDataInputParameter();
    p.setUrl("file:////tmp/doesnotexist");
    p.url(msg);
}
Also used : InterlokMessage(com.adaptris.interlok.types.InterlokMessage) Test(org.junit.Test)

Example 5 with InterlokMessage

use of com.adaptris.interlok.types.InterlokMessage 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

InterlokMessage (com.adaptris.interlok.types.InterlokMessage)6 Test (org.junit.Test)6 InterlokException (com.adaptris.interlok.InterlokException)2 StringWriter (java.io.StringWriter)2 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 DataOutputParameter (com.adaptris.interlok.config.DataOutputParameter)1 IOException (java.io.IOException)1 StringReader (java.io.StringReader)1