From 12dafc81793284e8329e0bfd19b1a6f3bbecbab8 Mon Sep 17 00:00:00 2001 From: "jonas.partner" Date: Tue, 12 Apr 2011 10:00:33 +0100 Subject: [PATCH] add test for producing a text output using relates to INT-1838 --- .../transformer/XsltPayloadTransformerTests.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java index 14dd1bb0df..70ed9f31e5 100644 --- a/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java +++ b/spring-integration-xml/src/test/java/org/springframework/integration/xml/transformer/XsltPayloadTransformerTests.java @@ -155,6 +155,15 @@ public class XsltPayloadTransformerTests { assertEquals("Wrong type of return ", StringResult.class, returned.getClass()); } + @Test + public void docInStringOut() throws Exception { + transformer = new XsltPayloadTransformer(getXslResourceThatOutputsText()); + transformer.setResultFactory(new StringResultFactory()); + transformer.setAlwaysUseResultFactory(true); + Object returned = transformer.doTransform(buildMessage(XmlTestUtil.getDocumentForString(docAsString))); + assertEquals("Wrong type of return ", StringResult.class, returned.getClass()); + assertEquals("Wrong content in string", "hello world", returned.toString()); + } protected Message buildMessage(Object payload) { return MessageBuilder.withPayload(payload).build(); @@ -165,6 +174,11 @@ public class XsltPayloadTransformerTests { return new ByteArrayResource(xsl.getBytes("UTF-8")); } + private Resource getXslResourceThatOutputsText() throws Exception { + String xsl = "hello world"; + return new ByteArrayResource(xsl.getBytes("UTF-8")); + } + public static class StubResultTransformer implements ResultTransformer { private Object objectToReturn;