Author: violetagg
Date: Fri May 16 15:24:08 2014
New Revision: 1595230

URL: http://svn.apache.org/r1595230
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=56529
Test case for attributes with empty string values in custom tags.

Added:
    tomcat/trunk/test/webapp/bug5nnnn/bug56529.jsp   (with props)
Modified:
    tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java
    tomcat/trunk/test/webapp/WEB-INF/bugs.tld

Modified: tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java?rev=1595230&r1=1595229&r2=1595230&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java (original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java Fri May 16 
15:24:08 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.WebResourceRoot;
@@ -256,4 +258,57 @@ 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");
+        // 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);
+   }
+
+    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().println("attribute1: " + attribute1);
+                pageContext.getOut().println("attribute2: " + attribute2);
+            } catch (IOException e) {
+                throw new JspException(e);
+            }
+            return EVAL_PAGE;
+        }
+
+    }
 }

Modified: tomcat/trunk/test/webapp/WEB-INF/bugs.tld
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/WEB-INF/bugs.tld?rev=1595230&r1=1595229&r2=1595230&view=diff
==============================================================================
--- tomcat/trunk/test/webapp/WEB-INF/bugs.tld (original)
+++ tomcat/trunk/test/webapp/WEB-INF/bugs.tld Fri May 16 15:24:08 2014
@@ -65,6 +65,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>

Added: tomcat/trunk/test/webapp/bug5nnnn/bug56529.jsp
URL: 
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug56529.jsp?rev=1595230&view=auto
==============================================================================
--- tomcat/trunk/test/webapp/bug5nnnn/bug56529.jsp (added)
+++ tomcat/trunk/test/webapp/bug5nnnn/bug56529.jsp Fri May 16 15:24:08 2014
@@ -0,0 +1,24 @@
+<%--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+      http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+--%>
+<%@ taglib uri="http://tomcat.apache.org/bugs"; prefix="bugs" %>
+<bugs:Bug56529 attribute2="">
+    <jsp:attribute name="attribute1"></jsp:attribute>
+</bugs:Bug56529>
+
+<bugs:Bug56529 attribute2="">
+    <jsp:attribute name="attribute1" />
+</bugs:Bug56529>

Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug56529.jsp
------------------------------------------------------------------------------
    svn:eol-style = native



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org
For additional commands, e-mail: dev-h...@tomcat.apache.org

Reply via email to