Search in sources :

Example 21 with MultiPayloadMessageFactory

use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.

the class MultiPayloadMessageSplitterTest method setUp.

@Before
public void setUp() throws Exception {
    splitter = createSplitterForTests();
    message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage(ID_1, PAYLOAD_1, "UTF-8");
    message.addContent(ID_2, PAYLOAD_2);
}
Also used : MultiPayloadMessageFactory(com.adaptris.core.MultiPayloadMessageFactory) Before(org.junit.Before)

Example 22 with MultiPayloadMessageFactory

use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.

the class MultiPayloadStreamOutputParameterTest method testInsertSetId.

@Test
public void testInsertSetId() throws Exception {
    MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
    try (InputStream in = new ByteArrayInputStream(PAYLOAD.getBytes())) {
        InputStreamWithEncoding stream = new InputStreamWithEncoding(in, ENCODING);
        MultiPayloadStreamOutputParameter parameter = new MultiPayloadStreamOutputParameter();
        parameter.setPayloadId(ID);
        parameter.insert(stream, message);
    }
    assertEquals(PAYLOAD, message.getContent(ID));
}
Also used : MultiPayloadMessageFactory(com.adaptris.core.MultiPayloadMessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Example 23 with MultiPayloadMessageFactory

use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.

the class MultiPayloadStreamOutputParameterTest method testInsertNoEncoding.

@Test
public void testInsertNoEncoding() throws Exception {
    MultiPayloadMessageFactory messageFactory = new MultiPayloadMessageFactory();
    MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) messageFactory.newMessage();
    try (InputStream in = new ByteArrayInputStream(PAYLOAD.getBytes())) {
        InputStreamWithEncoding stream = new InputStreamWithEncoding(in, null);
        MultiPayloadStreamOutputParameter parameter = new MultiPayloadStreamOutputParameter();
        parameter.setContentEncoding(null);
        parameter.insert(stream, ID, message);
    }
    assertEquals(PAYLOAD, message.getContent(ID));
}
Also used : MultiPayloadMessageFactory(com.adaptris.core.MultiPayloadMessageFactory) ByteArrayInputStream(java.io.ByteArrayInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Example 24 with MultiPayloadMessageFactory

use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.

the class MultiPayloadStringInputParameterTest method testExtract.

@Test
public void testExtract() throws Exception {
    MultiPayloadStringInputParameter parameter = new MultiPayloadStringInputParameter();
    parameter.setPayloadId(ID);
    MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage(ID, PAYLOAD, ENCODING);
    assertEquals(PAYLOAD, parameter.extract(message));
    assertEquals(PAYLOAD, parameter.extract(ID, message));
    assertEquals(PAYLOAD, parameter.extract(null, message));
}
Also used : MultiPayloadMessageFactory(com.adaptris.core.MultiPayloadMessageFactory) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Example 25 with MultiPayloadMessageFactory

use of com.adaptris.core.MultiPayloadMessageFactory in project interlok by adaptris.

the class MultiPayloadStringOutputParameterTest method testInsertSetId.

@Test
public void testInsertSetId() throws Exception {
    MultiPayloadStringOutputParameter parameter = new MultiPayloadStringOutputParameter();
    parameter.setPayloadId(ID);
    MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
    parameter.insert(PAYLOAD, message);
    assertEquals(PAYLOAD, message.getContent(ID));
}
Also used : MultiPayloadMessageFactory(com.adaptris.core.MultiPayloadMessageFactory) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Aggregations

MultiPayloadMessageFactory (com.adaptris.core.MultiPayloadMessageFactory)26 MultiPayloadAdaptrisMessage (com.adaptris.core.MultiPayloadAdaptrisMessage)24 Test (org.junit.Test)23 InputStream (java.io.InputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 Before (org.junit.Before)2 ServiceException (com.adaptris.core.ServiceException)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1