Author: kkolinko
Date: Fri May 16 22:14:56 2014
New Revision: 1595367
URL: http://svn.apache.org/r1595367
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56529
Test case for attributes with empty string values in custom tags.
It is backport of r1595230 r1595365 from tomcat/trunk.
Added:
tomcat/tc7.0.x/trunk/test/webapp-3.0/bug5nnnn/bug56529.jsp
- copied unchanged from r1595365,
tomcat/trunk/test/webapp/bug5nnnn/bug56529.jsp
Modified:
tomcat/tc7.0.x/trunk/ (props changed)
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestGenerator.java
tomcat/tc7.0.x/trunk/test/webapp-3.0/WEB-INF/bugs.tld
Propchange: tomcat/tc7.0.x/trunk/
------------------------------------------------------------------------------
Merged /tomcat/trunk:r1595230,1595365
Modified:
tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestGenerator.java
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestGenerator.java?rev=1595367&r1=1595366&r2=1595367&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestGenerator.java
(original)
+++ tomcat/tc7.0.x/trunk/test/org/apache/jasper/compiler/TestGenerator.java Fri
May 16 22:14:56 2014
@@ -18,6 +18,7 @@
package org.apache.jasper.compiler;
import java.io.File;
+import java.io.IOException;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -33,6 +34,7 @@ import javax.servlet.jsp.tagext.Variable
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import org.junit.Assert;
import org.junit.Test;
import org.apache.catalina.core.StandardContext;
@@ -251,4 +253,63 @@ public class TestGenerator extends Tomca
private static void assertEcho(String result, String expected) {
assertTrue(result.indexOf("<p>" + expected + "</p>") > 0);
}
+
+ @Test
+ public void testBug56529() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir = new File("test/webapp-3.0");
+ // app dir is relative to server home
+ tomcat.addWebapp(null, "/test", appDir.getAbsolutePath());
+
+ tomcat.start();
+
+ ByteChunk bc = new ByteChunk();
+ int rc = getUrl("http://localhost:" + getPort() +
+ "/test/bug5nnnn/bug56529.jsp", bc, null);
+ Assert.assertEquals(HttpServletResponse.SC_OK, rc);
+ String response = bc.toStringInternal();
+ Assert.assertTrue(response,
+ response.contains("[1:attribute1: '', attribute2: '']"));
+ Assert.assertTrue(response,
+ response.contains("[2:attribute1: '', attribute2: '']"));
+ }
+
+ public static class Bug56529 extends TagSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ private String attribute1 = null;
+
+ private String attribute2 = null;
+
+ public void setAttribute1(String attribute1) {
+ this.attribute1 = attribute1;
+ }
+
+ public String getAttribute1() {
+ return attribute1;
+ }
+
+ public void setAttribute2(String attribute2) {
+ this.attribute2 = attribute2;
+ }
+
+ public String getAttribute2() {
+ return attribute2;
+ }
+
+ @Override
+ public int doEndTag() throws JspException {
+ try {
+ pageContext.getOut().print(
+ "attribute1: '" + attribute1 + "', " + "attribute2: '"
+ + attribute2 + "'");
+ } catch (IOException e) {
+ throw new JspException(e);
+ }
+ return EVAL_PAGE;
+ }
+
+ }
}
Modified: tomcat/tc7.0.x/trunk/test/webapp-3.0/WEB-INF/bugs.tld
URL:
http://svn.apache.org/viewvc/tomcat/tc7.0.x/trunk/test/webapp-3.0/WEB-INF/bugs.tld?rev=1595367&r1=1595366&r2=1595367&view=diff
==============================================================================
--- tomcat/tc7.0.x/trunk/test/webapp-3.0/WEB-INF/bugs.tld (original)
+++ tomcat/tc7.0.x/trunk/test/webapp-3.0/WEB-INF/bugs.tld Fri May 16 22:14:56
2014
@@ -67,6 +67,20 @@
<scope>AT_END</scope>
</variable>
</tag>
+ <tag>
+ <name>Bug56529</name>
+ <tag-class>org.apache.jasper.compiler.TestGenerator$Bug56529</tag-class>
+ <body-content>JSP</body-content>
+ <attribute>
+ <name>attribute1</name>
+ <required>true</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <name>attribute2</name>
+ <required>true</required>
+ </attribute>
+ </tag>
<function>
<name>bug49555</name>
<function-class>org.apache.el.TesterFunctions$Inner$Class</function-class>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]