From c0bdb9d9bfb45de1a70af69a162cf6cb4e1e8de2 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 31 Jan 2010 00:34:37 +0000 Subject: [PATCH] Add tests for AttributeParser and deferredSyntaxAllowedAsLiteral git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@904935 13f79535-47bb-0310-9956-ffa450edef68 --- test/org/apache/el/TestELInJsp.java | 36 ++++++++++++++++++++++++++++++ test/webapp/WEB-INF/tags/echo-deferred.tag | 17 ++++++++++++++ test/webapp/WEB-INF/tags/implicit.tld | 23 +++++++++++++++++++ test/webapp/bug45451.jspf | 10 +++++++++ test/webapp/bug45451c.jsp | 2 +- test/webapp/bug45451d.jspx | 5 +++++ test/webapp/bug45451e.jsp | 19 ++++++++++++++++ 7 files changed, 111 insertions(+), 1 deletion(-) create mode 100644 test/webapp/WEB-INF/tags/echo-deferred.tag create mode 100644 test/webapp/WEB-INF/tags/implicit.tld create mode 100644 test/webapp/bug45451e.jsp diff --git a/test/org/apache/el/TestELInJsp.java b/test/org/apache/el/TestELInJsp.java index 0bfd53696..8953e3088 100644 --- a/test/org/apache/el/TestELInJsp.java +++ b/test/org/apache/el/TestELInJsp.java @@ -165,6 +165,11 @@ public class TestELInJsp extends TomcatBaseTest { assertTrue(result.indexOf("06-\\2") > 0); assertTrue(result.indexOf("07-\\${1+1}") > 0); assertTrue(result.indexOf("08-\\\\2") > 0); + assertTrue(result.indexOf("09-2") > 0); + assertTrue(result.indexOf("10-#{1+1}") > 0); + assertTrue(result.indexOf("11-\\2") > 0); + assertTrue(result.indexOf("12-\\#{1+1}") > 0); + assertTrue(result.indexOf("13-\\\\2") > 0); res = getUrl("http://localhost:" + getPort() + "/test/bug45451c.jsp"); result = res.toString(); @@ -180,6 +185,11 @@ public class TestELInJsp extends TomcatBaseTest { assertTrue(result.indexOf("06-\\${1+1}") > 0); assertTrue(result.indexOf("07-\\\\${1+1}") > 0); assertTrue(result.indexOf("08-\\\\${1+1}") > 0); + assertTrue(result.indexOf("09-#{1+1}") > 0); + assertTrue(result.indexOf("10-\\#{1+1}") > 0); + assertTrue(result.indexOf("11-\\#{1+1}") > 0); + assertTrue(result.indexOf("12-\\\\#{1+1}") > 0); + assertTrue(result.indexOf("13-\\\\#{1+1}") > 0); res = getUrl("http://localhost:" + getPort() + "/test/bug45451d.jspx"); result = res.toString(); @@ -194,6 +204,32 @@ public class TestELInJsp extends TomcatBaseTest { assertTrue(result.indexOf("06-\\${1+1}") > 0); assertTrue(result.indexOf("07-\\\\${1+1}") > 0); assertTrue(result.indexOf("08-\\\\\\${1+1}") > 0); + assertTrue(result.indexOf("09-2") > 0); + assertTrue(result.indexOf("10-#{1+1}") > 0); + assertTrue(result.indexOf("11-\\#{1+1}") > 0); + assertTrue(result.indexOf("12-\\\\#{1+1}") > 0); + assertTrue(result.indexOf("13-\\\\\\#{1+1}") > 0); + + res = getUrl("http://localhost:" + getPort() + "/test/bug45451e.jsp"); + result = res.toString(); + System.out.println(result); + // Warning: JSP attribute escaping != Java String escaping + // Warning: Attributes are always unescaped before passing to the EL + // processor + assertTrue(result.indexOf("00-2") > 0); + assertTrue(result.indexOf("01-${1+1}") > 0); + assertTrue(result.indexOf("02-\\${1+1}") > 0); + assertTrue(result.indexOf("03-\\\\${1+1}") > 0); + assertTrue(result.indexOf("04-2") > 0); + assertTrue(result.indexOf("05-${1+1}") > 0); + assertTrue(result.indexOf("06-\\2") > 0); + assertTrue(result.indexOf("07-\\${1+1}") > 0); + assertTrue(result.indexOf("08-\\\\2") > 0); + assertTrue(result.indexOf("09-#{1+1}") > 0); + assertTrue(result.indexOf("10-\\#{1+1}") > 0); + assertTrue(result.indexOf("11-\\#{1+1}") > 0); + assertTrue(result.indexOf("12-\\\\#{1+1}") > 0); + assertTrue(result.indexOf("13-\\\\#{1+1}") > 0); } public void testBug45511() throws Exception { diff --git a/test/webapp/WEB-INF/tags/echo-deferred.tag b/test/webapp/WEB-INF/tags/echo-deferred.tag new file mode 100644 index 000000000..caa6e612f --- /dev/null +++ b/test/webapp/WEB-INF/tags/echo-deferred.tag @@ -0,0 +1,17 @@ +<%-- + 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. +--%> +<%@ tag %><%@ attribute name="echo" deferredValue="true" %>

${echo}

\ No newline at end of file diff --git a/test/webapp/WEB-INF/tags/implicit.tld b/test/webapp/WEB-INF/tags/implicit.tld new file mode 100644 index 000000000..e99820ae4 --- /dev/null +++ b/test/webapp/WEB-INF/tags/implicit.tld @@ -0,0 +1,23 @@ + + + + \ No newline at end of file diff --git a/test/webapp/bug45451.jspf b/test/webapp/bug45451.jspf index 2d9f9b3c0..e4483e366 100644 --- a/test/webapp/bug45451.jspf +++ b/test/webapp/bug45451.jspf @@ -23,3 +23,13 @@ + + + + + + + + + + diff --git a/test/webapp/bug45451c.jsp b/test/webapp/bug45451c.jsp index a1b8b06d0..38324a3aa 100644 --- a/test/webapp/bug45451c.jsp +++ b/test/webapp/bug45451c.jsp @@ -14,6 +14,6 @@ See the License for the specific language governing permissions and limitations under the License. --%> -<%@page isELIgnored="true" %> +<%@page isELIgnored="true" deferredSyntaxAllowedAsLiteral="true" %> <%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> <%@ include file="bug45451.jspf" %> diff --git a/test/webapp/bug45451d.jspx b/test/webapp/bug45451d.jspx index 09a478541..5a0039f75 100644 --- a/test/webapp/bug45451d.jspx +++ b/test/webapp/bug45451d.jspx @@ -30,6 +30,11 @@ + + + + + \ No newline at end of file diff --git a/test/webapp/bug45451e.jsp b/test/webapp/bug45451e.jsp new file mode 100644 index 000000000..b181d136c --- /dev/null +++ b/test/webapp/bug45451e.jsp @@ -0,0 +1,19 @@ +<%-- + 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. +--%> +<%@page deferredSyntaxAllowedAsLiteral="true" %> +<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %> +<%@ include file="bug45451.jspf" %> -- 2.11.0