INT-2768 Add XSLT Transformer Factory Class Name
Add the ability to inject the class name of the xslt transformer implementation. https://jira.springsource.org/browse/INT-2768 -add @author to java docs -updat copywrite year to current year add new test and check for class name that it exists. -fix xslt payload transformer and test for unknown class name, will now default to the jre default transformer.
This commit is contained in:
@@ -16,6 +16,10 @@
|
||||
|
||||
package org.springframework.integration.xml.transformer;
|
||||
|
||||
import static junit.framework.Assert.assertEquals;
|
||||
import static junit.framework.Assert.assertTrue;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
|
||||
import javax.xml.transform.Result;
|
||||
import javax.xml.transform.TransformerException;
|
||||
import javax.xml.transform.dom.DOMResult;
|
||||
@@ -34,15 +38,12 @@ import org.springframework.xml.transform.StringResult;
|
||||
import org.springframework.xml.transform.StringSource;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.custommonkey.xmlunit.XMLAssert.assertXMLEqual;
|
||||
|
||||
|
||||
/**
|
||||
* @author Jonas Partner
|
||||
* @author Oleg Zhurakousky
|
||||
* @author Gunnar Hillert
|
||||
* @author Mike Bazos
|
||||
*/
|
||||
public class XsltPayloadTransformerTests {
|
||||
|
||||
@@ -112,6 +113,28 @@ public class XsltPayloadTransformerTests {
|
||||
assertEquals("Wrong value from result conversion", returnValue,
|
||||
transformed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXsltPayloadWithTransformerFactoryClassname() throws Exception {
|
||||
Integer returnValue = new Integer(13);
|
||||
transformer = new XsltPayloadTransformer(getXslResource(), new StubResultTransformer(returnValue),
|
||||
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
|
||||
Object transformed = transformer
|
||||
.doTransform(buildMessage(new StringSource(docAsString)));
|
||||
assertEquals("Wrong value from result conversion", returnValue,
|
||||
transformed);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testXsltPayloadWithBadTransformerFactoryClassname() throws Exception {
|
||||
Integer returnValue = new Integer(13);
|
||||
transformer = new XsltPayloadTransformer(getXslResource(), new StubResultTransformer(returnValue),
|
||||
"foo.bar.Baz");
|
||||
Object transformed = transformer
|
||||
.doTransform(buildMessage(new StringSource(docAsString)));
|
||||
assertEquals("Wrong value from result conversion", returnValue,
|
||||
transformed);
|
||||
}
|
||||
|
||||
@Test(expected = TransformerException.class)
|
||||
public void testNonXmlString() throws Exception {
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
input-channel="paramHeadersWithStartWildCharacterChannel"
|
||||
output-channel="output"
|
||||
xsl-resource="classpath:org/springframework/integration/xml/transformer/transformer.xslt"
|
||||
xslt-param-headers="*Param, foo">
|
||||
xslt-param-headers="*Param, foo"
|
||||
transformer-factory-class="com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl">
|
||||
</int-xml:xslt-transformer>
|
||||
|
||||
<int-xml:xslt-transformer id="paramHeadersWithEndWildCharacter"
|
||||
|
||||
Reference in New Issue
Block a user