Author: mrdon
Date: Fri Dec 1 00:02:59 2006
New Revision: 481180
URL: http://svn.apache.org/viewvc?view=rev&rev=481180
Log:
Adding test for xslt includes
WW-1483
Added:
struts/struts2/trunk/core/src/test/resources/XSLTResultTest4.xsl
Modified:
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
Modified:
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java?view=diff&rev=481180&r1=481179&r2=481180
==============================================================================
---
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
(original)
+++
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java
Fri Dec 1 00:02:59 2006
@@ -23,10 +23,14 @@
import java.util.ArrayList;
import java.util.List;
+import javax.xml.transform.Source;
import javax.xml.transform.TransformerException;
+import javax.xml.transform.URIResolver;
+import javax.xml.transform.stream.StreamSource;
import org.apache.struts2.ServletActionContext;
import org.apache.struts2.StrutsTestCase;
+import org.apache.struts2.util.ClassLoaderUtils;
import org.springframework.mock.web.MockHttpServletRequest;
import org.springframework.mock.web.MockHttpServletResponse;
import org.springframework.mock.web.MockServletContext;
@@ -114,6 +118,27 @@
assertTrue(out.indexOf("Hello Santa Claus how are you?") > -1);
assertTrue(out.indexOf("WebWork in Action by Patrick and Jason") > -1);
assertTrue(out.indexOf("XWork not in Action by Superman") > -1);
+ }
+
+ public void testTransform4WithDocumentInclude() throws Exception {
+ result = new XSLTResult(){
+ protected URIResolver getURIResolver() {
+ return new URIResolver() {
+ public Source resolve(String href, String base) throws
TransformerException {
+ return new
StreamSource(ClassLoaderUtils.getResourceAsStream(href, this.getClass()));
+ }
+
+ };
+ }
+
+ };
+ result.setParse(false);
+ result.setLocation("XSLTResultTest4.xsl");
+ result.execute(mai);
+
+ String out = response.getContentAsString();
+ assertTrue(out.startsWith("<?xml version=\"1.0\"
encoding=\"UTF-8\"?>"));
+ assertTrue(out.indexOf("<validators>") > -1);
}
protected void setUp() throws Exception {
Added: struts/struts2/trunk/core/src/test/resources/XSLTResultTest4.xsl
URL:
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/XSLTResultTest4.xsl?view=auto&rev=481180
==============================================================================
--- struts/struts2/trunk/core/src/test/resources/XSLTResultTest4.xsl (added)
+++ struts/struts2/trunk/core/src/test/resources/XSLTResultTest4.xsl Fri Dec 1
00:02:59 2006
@@ -0,0 +1,9 @@
+<xsl:stylesheet version="1.0"
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ xmlns="http://www.w3.org/TR/xhtml1/strict">
+
+ <xsl:template match="result">
+ <xsl:copy-of select="document('validators.xml')"/>
+ </xsl:template>
+
+</xsl:stylesheet>
\ No newline at end of file