Search in sources :

Example 46 with MultiPayloadAdaptrisMessage

use of com.adaptris.core.MultiPayloadAdaptrisMessage 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 47 with MultiPayloadAdaptrisMessage

use of com.adaptris.core.MultiPayloadAdaptrisMessage 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)

Example 48 with MultiPayloadAdaptrisMessage

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

the class MultiPayloadMessageAggregator method aggregate.

@Override
public void aggregate(AdaptrisMessage original, Iterable<AdaptrisMessage> msgs) throws CoreException {
    if (!(original instanceof MultiPayloadAdaptrisMessage)) {
        throw new CoreException("Original not a multi-payload message, cannot merge");
    }
    log.trace("Adding messages to existing message [{}]", original.getUniqueId());
    MultiPayloadAdaptrisMessage multiMessage = (MultiPayloadAdaptrisMessage) original;
    String originalId = multiMessage.getCurrentPayloadId();
    long count = 0;
    for (AdaptrisMessage message : msgs) {
        if (filter(message)) {
            count++;
            log.trace("Adding message payload [{}]", message.getUniqueId());
            multiMessage.addPayload(message.getUniqueId(), message.getPayload());
        }
    }
    if (replaceOriginal()) {
        multiMessage.deletePayload(originalId);
    }
    log.trace("Finished adding {} messages", count);
}
Also used : CoreException(com.adaptris.core.CoreException) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) AdaptrisMessage(com.adaptris.core.AdaptrisMessage) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage)

Aggregations

MultiPayloadAdaptrisMessage (com.adaptris.core.MultiPayloadAdaptrisMessage)48 Test (org.junit.Test)44 MultiPayloadMessageFactory (com.adaptris.core.MultiPayloadMessageFactory)24 ServiceException (com.adaptris.core.ServiceException)5 InputStream (java.io.InputStream)5 ByteArrayInputStream (java.io.ByteArrayInputStream)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 StxTransformerFactory (com.adaptris.util.text.xml.StxTransformerFactory)3 XsltTransformerFactory (com.adaptris.util.text.xml.XsltTransformerFactory)3 TransformerException (javax.xml.transform.TransformerException)3 KeyValuePair (com.adaptris.util.KeyValuePair)2 XPath (com.adaptris.util.text.xml.XPath)2 UncheckedXPathException (net.sf.saxon.trans.UncheckedXPathException)2 Document (org.w3c.dom.Document)2 CoreException (com.adaptris.core.CoreException)1 KeyValuePairList (com.adaptris.util.KeyValuePairList)1 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 ArrayList (java.util.ArrayList)1 ThreadPoolExecutor (java.util.concurrent.ThreadPoolExecutor)1