Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 1C1EE200BF6 for ; Tue, 10 Jan 2017 10:29:15 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 1A99B160B3D; Tue, 10 Jan 2017 09:29:15 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3BD97160B31 for ; Tue, 10 Jan 2017 10:29:14 +0100 (CET) Received: (qmail 35214 invoked by uid 500); 10 Jan 2017 09:29:13 -0000 Mailing-List: contact commits-help@struts.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@struts.apache.org Delivered-To: mailing list commits@struts.apache.org Received: (qmail 35205 invoked by uid 99); 10 Jan 2017 09:29:13 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 10 Jan 2017 09:29:13 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 4247DDFA98; Tue, 10 Jan 2017 09:29:13 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: lukaszlenart@apache.org To: commits@struts.apache.org Message-Id: <2b0078803e814c98ae061d908e5cb962@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: struts git commit: WW-4731 Adds additional test case to confirm that everything is ok Date: Tue, 10 Jan 2017 09:29:13 +0000 (UTC) archived-at: Tue, 10 Jan 2017 09:29:15 -0000 Repository: struts Updated Branches: refs/heads/master fc6ffba9c -> f48c9620f WW-4731 Adds additional test case to confirm that everything is ok Project: http://git-wip-us.apache.org/repos/asf/struts/repo Commit: http://git-wip-us.apache.org/repos/asf/struts/commit/f48c9620 Tree: http://git-wip-us.apache.org/repos/asf/struts/tree/f48c9620 Diff: http://git-wip-us.apache.org/repos/asf/struts/diff/f48c9620 Branch: refs/heads/master Commit: f48c9620fcb877d23492c6fdd3cc7f7be5cc10e7 Parents: fc6ffba Author: Lukasz Lenart Authored: Tue Jan 10 10:28:54 2017 +0100 Committer: Lukasz Lenart Committed: Tue Jan 10 10:28:54 2017 +0100 ---------------------------------------------------------------------- .../apache/struts2/views/xslt/XSLTResult.java | 6 +-- .../struts2/views/xslt/XSLTResultTest.java | 29 ++++++++++++-- core/src/test/resources/XSLTResultTest6.xsl | 40 ++++++++++++++++++++ core/src/test/resources/log4j2.xml | 1 + 4 files changed, 70 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/struts/blob/f48c9620/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java index c264a59..2e2746e 100644 --- a/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java +++ b/core/src/main/java/org/apache/struts2/views/xslt/XSLTResult.java @@ -171,8 +171,9 @@ public class XSLTResult implements Result { if (location != null) { templates = getTemplates(location); transformer = templates.newTransformer(); - } else + } else { transformer = TransformerFactory.newInstance().newTransformer(); + } transformer.setURIResolver(getURIResolver()); transformer.setErrorListener(buildErrorListener()); @@ -247,8 +248,7 @@ public class XSLTResult implements Result { * function. The default is an instance of ServletURIResolver, which operates relative to the servlet context. */ protected URIResolver getURIResolver() { - return new ServletURIResolver( - ServletActionContext.getServletContext()); + return new ServletURIResolver(ServletActionContext.getServletContext()); } protected Templates getTemplates(final String path) throws TransformerException, IOException { http://git-wip-us.apache.org/repos/asf/struts/blob/f48c9620/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java ---------------------------------------------------------------------- diff --git a/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java b/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java index 3e8c7f1..47e7345 100644 --- a/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java +++ b/core/src/test/java/org/apache/struts2/views/xslt/XSLTResultTest.java @@ -35,6 +35,7 @@ import javax.xml.transform.TransformerException; import javax.xml.transform.URIResolver; import javax.xml.transform.stream.StreamSource; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; /** @@ -82,6 +83,22 @@ public class XSLTResultTest extends StrutsInternalTestCase { assertTrue(out.indexOf(" -1); } + public void testSimpleTransform5() throws Exception { + result.setParse(false); + result.setStylesheetLocation("XSLTResultTest6.xsl"); + result.execute(mai); + + String out = response.getContentAsString(); + assertTrue(out.startsWith("")); + assertTrue(out.contains("WebWork in Action")); + assertTrue(out.contains("Patrick and Jason")); + assertTrue(out.contains("IIV")); + assertTrue(out.contains("<author/><editions/></book>")); + assertTrue(out.contains("<title>XWork not in Action")); + assertTrue(out.contains("Superman")); + assertTrue(out.contains("12343456667")); + } + public void testSimpleTransformParse() throws Exception { result.setParse(true); result.setStylesheetLocation("${top.myLocation}"); @@ -277,9 +294,9 @@ public class XSLTResultTest extends StrutsInternalTestCase { public List getBooks() { List list = new ArrayList(); - list.add(new Book("WebWork in Action", "Patrick and Jason")); + list.add(new Book("WebWork in Action", "Patrick and Jason", Arrays.asList("I", "IV"))); list.add(null); - list.add(new Book("XWork not in Action", "Superman")); + list.add(new Book("XWork not in Action", "Superman", Arrays.asList("1234", "345", "6667"))); return list; } @@ -289,10 +306,12 @@ public class XSLTResultTest extends StrutsInternalTestCase { private String title; private String author; + private List editions; - public Book(String title, String author) { + public Book(String title, String author, List editions) { this.title = title; this.author = author; + this.editions = editions; } public String getTitle() { @@ -302,5 +321,9 @@ public class XSLTResultTest extends StrutsInternalTestCase { public String getAuthor() { return author; } + + public List getEditions() { + return editions; + } } } http://git-wip-us.apache.org/repos/asf/struts/blob/f48c9620/core/src/test/resources/XSLTResultTest6.xsl ---------------------------------------------------------------------- diff --git a/core/src/test/resources/XSLTResultTest6.xsl b/core/src/test/resources/XSLTResultTest6.xsl new file mode 100644 index 0000000..606466d --- /dev/null +++ b/core/src/test/resources/XSLTResultTest6.xsl @@ -0,0 +1,40 @@ + + + + + + + + + + <xsl:value-of select="title"/> + + + + + + + + + + + http://git-wip-us.apache.org/repos/asf/struts/blob/f48c9620/core/src/test/resources/log4j2.xml ---------------------------------------------------------------------- diff --git a/core/src/test/resources/log4j2.xml b/core/src/test/resources/log4j2.xml index 263585e..c93452b 100644 --- a/core/src/test/resources/log4j2.xml +++ b/core/src/test/resources/log4j2.xml @@ -9,5 +9,6 @@ + \ No newline at end of file