Search in sources :

Example 31 with MultiPayloadAdaptrisMessage

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

the class MultiPayloadByteArrayOutputParameterTest method testInsertUseDefaultId.

@Test
public void testInsertUseDefaultId() throws Exception {
    MultiPayloadByteArrayOutputParameter parameter = new MultiPayloadByteArrayOutputParameter();
    MultiPayloadMessageFactory messageFactory = new MultiPayloadMessageFactory();
    MultiPayloadAdaptrisMessage message = (MultiPayloadAdaptrisMessage) messageFactory.newMessage();
    parameter.insert(PAYLOAD, null, message);
    assertArrayEquals(PAYLOAD, message.getPayload(messageFactory.getDefaultPayloadId()));
}
Also used : MultiPayloadMessageFactory(com.adaptris.core.MultiPayloadMessageFactory) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Example 32 with MultiPayloadAdaptrisMessage

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

the class MultiPayloadByteArrayOutputParameterTest method testInsertSetId.

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

Example 33 with MultiPayloadAdaptrisMessage

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

the class MultiPayloadXmlTransformServiceTest method testSTXOutput.

@Test
public void testSTXOutput() throws Exception {
    MultiPayloadAdaptrisMessage m1 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
    MultiPayloadXmlTransformService service = createBaseExample();
    service.setUrl(PROPERTIES.getProperty(KEY_XML_TEST_STX_TRANSFORM_URL));
    service.setXmlTransformerFactory(new StxTransformerFactory());
    execute(service, m1);
    assertEquals(PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT), m1.getContent(PAYLOAD_ID_OUTPUT));
}
Also used : StxTransformerFactory(com.adaptris.util.text.xml.StxTransformerFactory) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

Example 34 with MultiPayloadAdaptrisMessage

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

the class MultiPayloadXmlTransformServiceTest method testIssue2641_NoOutputMessageEncoding.

@Test
public void testIssue2641_NoOutputMessageEncoding() throws Exception {
    MultiPayloadAdaptrisMessage msg = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_ISSUE2641_INPUT), "ISO-8859-1");
    Document srcXml = createDocument(msg.getPayload(PAYLOAD_ID_SOURCE));
    XPath srcXpath = new XPath();
    String srcValue = srcXpath.selectSingleTextItem(srcXml, ISSUE2641_SRC_XPATH);
    assertEquals("ISO-8859-1", msg.getContentEncoding());
    MultiPayloadXmlTransformService service = createBaseExample();
    service.setUrl(PROPERTIES.getProperty(KEY_ISSUE2641_TRANSFORM_URL));
    execute(service, msg);
    assertEquals("ISO-8859-1", msg.getContentEncoding());
    // We're using UTF-8 as the encoding; get bytes will give us the right thing.
    Document destXml = createDocument(msg.getPayload(PAYLOAD_ID_OUTPUT));
    XPath destXpath = new XPath();
    String destValue = destXpath.selectSingleTextItem(destXml, ISSUE2641_DEST_XPATH);
    log.debug("testIssue2641:: srcValue  = [" + srcValue + "]");
    log.debug("testIssue2641:: destValue = [" + destValue + "]");
    // All things being equal, they should be the same.
    assertEquals(srcValue, destValue);
}
Also used : XPath(com.adaptris.util.text.xml.XPath) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 35 with MultiPayloadAdaptrisMessage

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

the class MultiPayloadXmlTransformServiceTest method testXSLTOutput_NamedXsltTransformFactory.

@Test
public void testXSLTOutput_NamedXsltTransformFactory() throws Exception {
    MultiPayloadAdaptrisMessage m1 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
    MultiPayloadXmlTransformService service = createBaseExample();
    XsltTransformerFactory fac = new XsltTransformerFactory(net.sf.saxon.TransformerFactoryImpl.class.getCanonicalName());
    service.setXmlTransformerFactory(fac);
    execute(service, m1);
    assertEquals(PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT), m1.getContent(PAYLOAD_ID_OUTPUT));
}
Also used : XsltTransformerFactory(com.adaptris.util.text.xml.XsltTransformerFactory) MultiPayloadAdaptrisMessage(com.adaptris.core.MultiPayloadAdaptrisMessage) Test(org.junit.Test)

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