From 622de1c46ea937fa0a0a4f1ccc0126c2352c4d62 Mon Sep 17 00:00:00 2001 From: markt Date: Sun, 7 Mar 2010 20:32:26 +0000 Subject: [PATCH] Test that tags from libraries that declare various JSP versions have EL and deferred EL enabled/disabled as appropriate. This currently triggers a failure - fix to follow shortly. git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@920096 13f79535-47bb-0310-9956-ffa450edef68 --- test/org/apache/jasper/compiler/TestValidator.java | 54 ++++++++++++++++++++++ test/webapp-3.0/WEB-INF/tags11.tld | 36 +++++++++++++++ test/webapp-3.0/WEB-INF/tags12.tld | 36 +++++++++++++++ test/webapp-3.0/WEB-INF/tags20.tld | 37 +++++++++++++++ test/webapp-3.0/WEB-INF/tags21.tld | 37 +++++++++++++++ test/webapp-3.0/tld-versions.jsp | 29 ++++++++++++ 6 files changed, 229 insertions(+) create mode 100644 test/webapp-3.0/WEB-INF/tags11.tld create mode 100644 test/webapp-3.0/WEB-INF/tags12.tld create mode 100644 test/webapp-3.0/WEB-INF/tags20.tld create mode 100644 test/webapp-3.0/WEB-INF/tags21.tld create mode 100644 test/webapp-3.0/tld-versions.jsp diff --git a/test/org/apache/jasper/compiler/TestValidator.java b/test/org/apache/jasper/compiler/TestValidator.java index 17fc195f7..c2a74e5eb 100644 --- a/test/org/apache/jasper/compiler/TestValidator.java +++ b/test/org/apache/jasper/compiler/TestValidator.java @@ -20,8 +20,12 @@ package org.apache.jasper.compiler; import java.io.File; import java.io.IOException; +import javax.servlet.jsp.JspException; +import javax.servlet.jsp.tagext.TagSupport; + import org.apache.catalina.startup.Tomcat; import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.tomcat.util.buf.ByteChunk; public class TestValidator extends TomcatBaseTest { @@ -45,4 +49,54 @@ public class TestValidator extends TomcatBaseTest { // Failure is expected assertNotNull(e); } + + + public void testTldVersions30() 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 res = getUrl("http://localhost:" + getPort() + + "/test/tld-versions.jsp"); + + String result = res.toString(); + + assertTrue(result.indexOf("

${'00-hello world'}

") > 0); + assertTrue(result.indexOf("

#{'01-hello world'}

") > 0); + assertTrue(result.indexOf("

${'02-hello world'}

") > 0); + assertTrue(result.indexOf("

#{'03-hello world'}

") > 0); + assertTrue(result.indexOf("

04-hello world

") > 0); + assertTrue(result.indexOf("

#{'05-hello world'}

") > 0); + assertTrue(result.indexOf("

06-hello world

") > 0); + } + + public static class Echo extends TagSupport { + + private static final long serialVersionUID = 1L; + + private String echo = null; + + public void setEcho(String echo) { + this.echo = echo; + } + + public String getEcho() { + return echo; + } + + @Override + public int doStartTag() throws JspException { + try { + pageContext.getOut().print("

" + echo + "

"); + } catch (IOException e) { + pageContext.getServletContext().log("Tag (Echo21) failure", e); + } + return super.doStartTag(); + } + } } diff --git a/test/webapp-3.0/WEB-INF/tags11.tld b/test/webapp-3.0/WEB-INF/tags11.tld new file mode 100644 index 000000000..b78be0327 --- /dev/null +++ b/test/webapp-3.0/WEB-INF/tags11.tld @@ -0,0 +1,36 @@ + + + + 1.0 + 1.1 + Tags11 + http://tomcat.apache.org/tags11 + + + Echo + org.apache.jasper.compiler.TestValidator$Echo + empty + + echo + yes + + + + \ No newline at end of file diff --git a/test/webapp-3.0/WEB-INF/tags12.tld b/test/webapp-3.0/WEB-INF/tags12.tld new file mode 100644 index 000000000..55908d982 --- /dev/null +++ b/test/webapp-3.0/WEB-INF/tags12.tld @@ -0,0 +1,36 @@ + + + + 1.0 + 1.2 + Tags12 + http://tomcat.apache.org/tags12 + + + Echo + org.apache.jasper.compiler.TestValidator$Echo + empty + + echo + yes + + + + \ No newline at end of file diff --git a/test/webapp-3.0/WEB-INF/tags20.tld b/test/webapp-3.0/WEB-INF/tags20.tld new file mode 100644 index 000000000..9130867cb --- /dev/null +++ b/test/webapp-3.0/WEB-INF/tags20.tld @@ -0,0 +1,37 @@ + + + 1.0 + Tags20 + http://tomcat.apache.org/tags20 + + + Echo + org.apache.jasper.compiler.TestValidator$Echo + empty + + echo + yes + true + + + + \ No newline at end of file diff --git a/test/webapp-3.0/WEB-INF/tags21.tld b/test/webapp-3.0/WEB-INF/tags21.tld new file mode 100644 index 000000000..7b8c3c542 --- /dev/null +++ b/test/webapp-3.0/WEB-INF/tags21.tld @@ -0,0 +1,37 @@ + + + 1.0 + Tags21 + http://tomcat.apache.org/tags21 + + + Echo + org.apache.jasper.compiler.TestValidator$Echo + empty + + echo + yes + true + + + + \ No newline at end of file diff --git a/test/webapp-3.0/tld-versions.jsp b/test/webapp-3.0/tld-versions.jsp new file mode 100644 index 000000000..debf2501d --- /dev/null +++ b/test/webapp-3.0/tld-versions.jsp @@ -0,0 +1,29 @@ +<%-- + 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 prefix="tags11" uri="http://tomcat.apache.org/tags11" %> +<%@ taglib prefix="tags12" uri="http://tomcat.apache.org/tags12" %> +<%@ taglib prefix="tags20" uri="http://tomcat.apache.org/tags20" %> +<%@ taglib prefix="tags21" uri="http://tomcat.apache.org/tags21" %> + + + + + + + + \ No newline at end of file -- 2.11.0