use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testXSLT_FatalError.
@Test
public void testXSLT_FatalError() 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_FATAL_TRANSFORM_URL));
try {
execute(service, m1);
fail();
} catch (ServiceException expected) {
assertExceptionCause(expected, TransformerException.class, UncheckedXPathException.class);
}
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testObtainUrlWithNoMetadataValueNoUrl.
@Test
public void testObtainUrlWithNoMetadataValueNoUrl() throws Exception {
MultiPayloadAdaptrisMessage msg = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
MultiPayloadXmlTransformService service = new MultiPayloadXmlTransformService();
try {
service.setMetadataKey("key");
service.setAllowOverride(true);
LifecycleHelper.init(service);
try {
service.obtainUrlToUse(msg);
fail();
} catch (ServiceException expected) {
// expected
}
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testIssue2641.
@Test
public void testIssue2641() 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));
service.setOutputMessageEncoding("UTF-8");
execute(service, msg);
assertEquals("UTF-8", msg.getContentEncoding());
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);
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testObtainUrlWithMetadataValueInMessageAllowOverride.
@Test
public void testObtainUrlWithMetadataValueInMessageAllowOverride() throws Exception {
MultiPayloadAdaptrisMessage msg = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
MultiPayloadXmlTransformService service = new MultiPayloadXmlTransformService();
msg.addMetadata("key", "val");
try {
service.setUrl(URL);
service.setMetadataKey("key");
service.setAllowOverride(true);
LifecycleHelper.init(service);
// allow override is false
assertEquals("val", service.obtainUrlToUse(msg));
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testObtainUrlWithNoMetadataValue.
@Test
public void testObtainUrlWithNoMetadataValue() throws Exception {
MultiPayloadXmlTransformService service = new MultiPayloadXmlTransformService();
MultiPayloadAdaptrisMessage msg = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
try {
service.setUrl(URL);
service.setMetadataKey("key");
service.setAllowOverride(true);
LifecycleHelper.init(service);
assertEquals(URL, service.obtainUrlToUse(msg));
} finally {
LifecycleHelper.close(service);
}
}
Aggregations