@Test
 public void testXsltWithImports() throws Exception {
   Resource resource = new ClassPathResource("transform-with-import.xsl", this.getClass());
   transformer = new XsltPayloadTransformer(resource);
   transformer.afterPropertiesSet();
   assertEquals(transformer.doTransform(buildMessage(docAsString)), outputAsString);
 }
 @Test
 public void testSourceWithResultTransformer() throws Exception {
   Integer returnValue = new Integer(13);
   transformer =
       new XsltPayloadTransformer(getXslResource(), new StubResultTransformer(returnValue));
   transformer.afterPropertiesSet();
   Object transformed = transformer.doTransform(buildMessage(new StringSource(docAsString)));
   assertEquals("Wrong value from result conversion", returnValue, transformed);
 }
 @Test
 public void docInStringOut() throws Exception {
   transformer = new XsltPayloadTransformer(getXslResourceThatOutputsText());
   transformer.setResultFactory(new StringResultFactory());
   transformer.setAlwaysUseResultFactory(true);
   transformer.afterPropertiesSet();
   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());
 }
 @Test
 public void stringInDomResultOut() throws Exception {
   Resource resource = new ClassPathResource("transform-with-import.xsl", this.getClass());
   transformer = new XsltPayloadTransformer(resource);
   transformer.setResultFactory(new StringResultFactory());
   transformer.setAlwaysUseResultFactory(true);
   transformer.afterPropertiesSet();
   Object returned =
       transformer.doTransform(buildMessage(XmlTestUtil.getDocumentForString(docAsString)));
   assertEquals("Wrong type of return ", StringResult.class, returned.getClass());
 }
 @Test
 public void testStringAsPayloadUseResultFactoryTrue() throws Exception {
   transformer.setAlwaysUseResultFactory(true);
   Object transformed = transformer.doTransform(buildMessage(docAsString));
   assertEquals(
       "Wrong return type for useFactories true", DOMResult.class, transformed.getClass());
   DOMResult result = (DOMResult) transformed;
   assertXMLEqual(
       "Document incorrect after transformation",
       XmlTestUtil.getDocumentForString(outputAsString),
       (Document) result.getNode());
 }
 @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");
   transformer.afterPropertiesSet();
   Object transformed = transformer.doTransform(buildMessage(new StringSource(docAsString)));
   assertEquals("Wrong value from result conversion", returnValue, transformed);
 }
 @Test
 public void testStringAsPayload() throws Exception {
   Object transformed = transformer.doTransform(buildMessage(docAsString));
   assertEquals("Wrong return type for string payload", String.class, transformed.getClass());
   String transformedString = (String) transformed;
   assertXMLEqual("String incorrect after transform", outputAsString, transformedString);
 }
 @Test
 public void testSourceAsPayload() throws Exception {
   Object transformed = transformer.doTransform(buildMessage(new StringSource(docAsString)));
   assertEquals("Wrong return type for source payload", DOMResult.class, transformed.getClass());
   DOMResult result = (DOMResult) transformed;
   assertXMLEqual(
       "Document incorrect after transformation",
       XmlTestUtil.getDocumentForString(outputAsString),
       (Document) result.getNode());
 }
 @Test
 public void testDocumentAsPayload() throws Exception {
   Object transformed =
       transformer.doTransform(buildMessage(XmlTestUtil.getDocumentForString(docAsString)));
   assertTrue(
       "Wrong return type for document payload",
       Document.class.isAssignableFrom(transformed.getClass()));
   Document transformedDocument = (Document) transformed;
   assertXMLEqual(outputAsString, XmlTestUtil.docToString(transformedDocument));
 }
 @Before
 public void setUp() throws Exception {
   transformer = new XsltPayloadTransformer(getXslResource());
   transformer.afterPropertiesSet();
 }
 @Test(expected = MessagingException.class)
 public void testUnsupportedPayloadType() throws Exception {
   transformer.doTransform(buildMessage(new Long(12)));
 }
 @Test(expected = TransformerException.class)
 public void testNonXmlString() throws Exception {
   transformer.doTransform(buildMessage("test"));
 }
 @Test(expected = TransformerFactoryConfigurationError.class)
 public void testXsltPayloadWithBadTransformerFactoryClassname() throws Exception {
   transformer = new XsltPayloadTransformer(getXslResource(), "foo.bar.Baz");
   transformer.afterPropertiesSet();
   transformer.doTransform(buildMessage(new StringSource(docAsString)));
 }