use of com.adaptris.util.text.xml.XsltTransformerFactory 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.util.text.xml.XsltTransformerFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testXSLT_XslMessageTerminate.
@Test
public void testXSLT_XslMessageTerminate() throws Exception {
AdaptrisMessage m1 = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
XmlTransformService service = new XmlTransformService();
XsltTransformerFactory fac = new XsltTransformerFactory();
fac.getTransformerFactoryAttributes().add(new KeyValuePair("http://saxon.sf.net/feature/messageEmitterClass", MessageWarner.class.getCanonicalName()));
fac.getTransformerFactoryFeatures().add(new KeyValuePair(XMLConstants.FEATURE_SECURE_PROCESSING, "true"));
service.setXmlTransformerFactory(fac);
service.setUrl(PROPERTIES.getProperty(KEY_XML_TEST_TRANSFORM_URL_XSL_MESSAGE));
try {
execute(service, m1);
fail();
} catch (ServiceException expected) {
assertExceptionCause(expected, TransformerException.class, UncheckedXPathException.class);
}
}
use of com.adaptris.util.text.xml.XsltTransformerFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testXSLTOutput_NamedXsltTransformFactory.
@Test
public void testXSLTOutput_NamedXsltTransformFactory() throws Exception {
AdaptrisMessage m1 = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
XmlTransformService service = new XmlTransformService();
XsltTransformerFactory fac = new XsltTransformerFactory(net.sf.saxon.TransformerFactoryImpl.class.getCanonicalName());
service.setXmlTransformerFactory(fac);
service.setUrl(PROPERTIES.getProperty(KEY_XML_TEST_TRANSFORM_URL));
execute(service, m1);
assertEquals("payload " + m1.getContent(), PROPERTIES.getProperty(KEY_XML_TEST_OUTPUT), m1.getContent());
}
use of com.adaptris.util.text.xml.XsltTransformerFactory in project interlok by adaptris.
the class XmlTransformServiceTest method testXSLT_RecoverableError_NoFail.
@Test
public void testXSLT_RecoverableError_NoFail() throws Exception {
AdaptrisMessage m1 = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
String oldName = Thread.currentThread().getName();
Thread.currentThread().setName(getName());
XmlTransformService service = new XmlTransformService();
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.util.text.xml.XsltTransformerFactory in project interlok by adaptris.
the class XmlTransformerTest method testTransform_InputStreamOutputStream.
@Test
public void testTransform_InputStreamOutputStream() throws Exception {
XmlTransformerFactory factory = new XsltTransformerFactory();
XmlTransformer transform = factory.configure(new XmlTransformer());
String xsl = backslashToSlash(PROPERTIES.getProperty(KEY_XML_TEST_TRANSFORM_URL));
AdaptrisMessage m1 = MessageHelper.createMessage(PROPERTIES.getProperty(KEY_XML_TEST_INPUT));
try (InputStream in = m1.getInputStream();
OutputStream out = m1.getOutputStream()) {
transform.transform(factory.createTransformer(xsl), in, out, xsl);
}
}
Aggregations