use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testMultipleParameters_STXOutput.
@Test
public void testMultipleParameters_STXOutput() throws Exception {
MultiPayloadAdaptrisMessage msg = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
msg.addMetadata("world", "World");
msg.addMetadata("one", "World");
msg.addMetadata("two", "World");
msg.addMetadata("three", "World");
msg.addMetadata("four", "World");
MultiPayloadXmlTransformService service = createBaseExample();
service.setUrl(PROPERTIES.getProperty(KEY_XML_TEST_STX_TRANSFORM_URL));
service.setXmlTransformerFactory(new StxTransformerFactory());
service.setTransformParameter(new StringMetadataParameter());
execute(service, msg);
assertEquals(PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT) + "World", msg.getContent(PAYLOAD_ID_OUTPUT));
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testXSLT_RecoverableError_NoFail.
@Test
public void testXSLT_RecoverableError_NoFail() throws Exception {
MultiPayloadAdaptrisMessage m1 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
String oldName = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
MultiPayloadXmlTransformService service = createBaseExample();
XsltTransformerFactory fac = new XsltTransformerFactory();
fac.setFailOnRecoverableError(false);
service.setXmlTransformerFactory(fac);
service.setUrl(PROPERTIES.getProperty(KEY_XML_TEST_INVALID_TRANSFORM_URL));
try {
execute(service, m1);
} finally {
Thread.currentThread().setName(oldName);
}
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testOutputWithCacheResetsParameters.
// INTERLOK-3113
@Test
public void testOutputWithCacheResetsParameters() throws Exception {
MultiPayloadAdaptrisMessage m1 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
m1.addMessageHeader("myKey", "myValue");
MultiPayloadAdaptrisMessage m2 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
MultiPayloadXmlTransformService service = createBaseExample();
service.setCacheTransforms(true);
service.setTransformParameter(new StringMetadataParameter(new String[] { "myKey" }, new String[0]));
try {
start(service);
service.doService(m1);
assertNotNull(service.getTransforms().get(PROPERTIES.getProperty(KEY_XML_TEST_TRANSFORM_URL)).getParameter("myKey"));
service.doService(m2);
assertNull(service.getTransforms().get(PROPERTIES.getProperty(KEY_XML_TEST_TRANSFORM_URL)).getParameter("myKey"));
} finally {
stop(service);
}
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testObtainUrlWithEmptyMetadataValue.
@Test
public void testObtainUrlWithEmptyMetadataValue() throws Exception {
MultiPayloadAdaptrisMessage msg = (MultiPayloadAdaptrisMessage) new MultiPayloadMessageFactory().newMessage();
msg.addMetadata("key", "");
MultiPayloadXmlTransformService service = new MultiPayloadXmlTransformService();
try {
service.setUrl(URL);
service.setMetadataKey("key");
service.setAllowOverride(true);
LifecycleHelper.init(service);
assertEquals(URL, service.obtainUrlToUse(msg));
} finally {
LifecycleHelper.close(service);
}
}
use of com.adaptris.core.MultiPayloadAdaptrisMessage in project interlok by adaptris.
the class MultiPayloadXmlTransformServiceTest method testOutputWithNoCache.
@Test
public void testOutputWithNoCache() throws Exception {
MultiPayloadAdaptrisMessage m1 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
MultiPayloadAdaptrisMessage m2 = MessageHelper.createMultiPayloadMessage(PAYLOAD_ID_SOURCE, PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
MultiPayloadXmlTransformService service = createBaseExample();
service.setCacheTransforms(false);
try {
start(service);
service.doService(m1);
service.doService(m2);
assertEquals(PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT), m1.getContent(PAYLOAD_ID_OUTPUT));
assertEquals(PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT), m2.getContent(PAYLOAD_ID_OUTPUT));
} finally {
stop(service);
}
}
Aggregations