You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2010/03/09 22:51:46 UTC
svn commit: r921145 - in /tomcat/trunk/test: org/apache/jasper/compiler/
webapp-3.0/ webapp-3.0/WEB-INF/
Author: markt
Date: Tue Mar 9 21:51:46 2010
New Revision: 921145
URL: http://svn.apache.org/viewvc?rev=921145&view=rev
Log:
Bug 48701 test cases
Added:
tomcat/trunk/test/webapp-3.0/bug48701-TVI-NFA.jsp (with props)
tomcat/trunk/test/webapp-3.0/bug48701-TVI-NG.jsp (with props)
tomcat/trunk/test/webapp-3.0/bug48701-UseBean.jsp (with props)
tomcat/trunk/test/webapp-3.0/bug48701-VI.jsp (with props)
tomcat/trunk/test/webapp-3.0/bug48701-fail.jsp (with props)
Modified:
tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java
tomcat/trunk/test/webapp-3.0/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=921145&r1=921144&r2=921145&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java (original)
+++ tomcat/trunk/test/org/apache/jasper/compiler/TestGenerator.java Tue Mar 9 21:51:46 2010
@@ -19,7 +19,15 @@ package org.apache.jasper.compiler;
import java.io.File;
import java.io.IOException;
+import java.util.Date;
+import javax.servlet.jsp.JspException;
+import javax.servlet.jsp.tagext.TagData;
+import javax.servlet.jsp.tagext.TagExtraInfo;
+import javax.servlet.jsp.tagext.TagSupport;
+import javax.servlet.jsp.tagext.VariableInfo;
+
+import org.apache.catalina.core.StandardContext;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
import org.apache.tomcat.util.buf.ByteChunk;
@@ -75,6 +83,114 @@ public class TestGenerator extends Tomca
assertNotNull(e);
}
+ public void testBug48701Fail() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir =
+ new File("test/webapp-3.0");
+ // app dir is relative to server home
+ StandardContext ctxt = (StandardContext) tomcat.addWebapp(null,
+ "/test", appDir.getAbsolutePath());
+
+ // This test needs the JSTL libraries
+ File lib = new File("webapps/examples/WEB-INF/lib");
+ ctxt.setAliases("/WEB-INF/lib=" + lib.getCanonicalPath());
+
+ tomcat.start();
+
+ Exception e = null;
+ try {
+ getUrl("http://localhost:" + getPort() + "/test/bug48701-fail.jsp");
+ } catch (IOException ioe) {
+ e = ioe;
+ }
+
+ // Failure is expected
+ assertNotNull(e);
+ }
+
+ public void testBug48701UseBean() throws Exception {
+ testBug48701("bug48701-UseBean.jsp");
+ }
+
+ public void testBug48701VariableInfo() throws Exception {
+ testBug48701("bug48701-VI.jsp");
+ }
+
+ public void testBug48701TagVariableInfoNameGiven() throws Exception {
+ testBug48701("bug48701-TVI-NG.jsp");
+ }
+
+ public void testBug48701TagVariableInfoNameFromAttribute() throws Exception {
+ testBug48701("bug48701-TVI-NFA.jsp");
+ }
+
+ private void testBug48701(String jsp) 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/" + jsp);
+
+ String result = res.toString();
+ assertEcho(result, "00-PASS");
+ }
+
+ public static class Bug48701 extends TagSupport {
+
+ private static final long serialVersionUID = 1L;
+
+ private String beanName = null;
+
+ public void setBeanName(String beanName) {
+ this.beanName = beanName;
+ }
+
+ public String getBeanName() {
+ return beanName;
+ }
+
+ @Override
+ public int doStartTag() throws JspException {
+ Bean bean = new Bean();
+ bean.setTime((new Date()).toString());
+ pageContext.setAttribute("now", bean);
+ return super.doStartTag();
+ }
+
+
+ }
+
+ public static class Bug48701TEI extends TagExtraInfo {
+
+ @Override
+ public VariableInfo[] getVariableInfo(TagData data) {
+ return new VariableInfo[] {
+ new VariableInfo("now", Bean.class.getCanonicalName(),
+ true, VariableInfo.AT_END)
+ };
+ }
+
+ }
+
+ public static class Bean {
+ private String time;
+
+ public void setTime(String time) {
+ this.time = time;
+ }
+
+ public String getTime() {
+ return time;
+ }
+ }
+
/** Assertion for text printed by tags:echo */
private static void assertEcho(String result, String expected) {
assertTrue(result.indexOf("<p>" + expected + "</p>") > 0);
Modified: tomcat/trunk/test/webapp-3.0/WEB-INF/bugs.tld
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/WEB-INF/bugs.tld?rev=921145&r1=921144&r2=921145&view=diff
==============================================================================
--- tomcat/trunk/test/webapp-3.0/WEB-INF/bugs.tld (original)
+++ tomcat/trunk/test/webapp-3.0/WEB-INF/bugs.tld Tue Mar 9 21:51:46 2010
@@ -28,11 +28,44 @@
<tag-class>org.apache.jasper.compiler.TestScriptingVariabler$Bug48616aTag</tag-class>
<body-content>JSP</body-content>
</tag>
-
<tag>
<name>Bug48616b</name>
<tag-class>org.apache.jasper.compiler.TestScriptingVariabler$Bug48616bTag</tag-class>
<tei-class>org.apache.jasper.compiler.TestScriptingVariabler$Bug48616bTei</tei-class>
<body-content>JSP</body-content>
</tag>
+
+ <tag>
+ <name>Bug48701a</name>
+ <tag-class>org.apache.jasper.compiler.TestGenerator$Bug48701</tag-class>
+ <tei-class>org.apache.jasper.compiler.TestGenerator$Bug48701TEI</tei-class>
+ <body-content>empty</body-content>
+ </tag>
+ <tag>
+ <name>Bug48701b</name>
+ <tag-class>org.apache.jasper.compiler.TestGenerator$Bug48701</tag-class>
+ <body-content>empty</body-content>
+ <variable>
+ <name-given>now</name-given>
+ <variable-class>org.apache.jasper.compiler.TestGenerator.Bean</variable-class>
+ <declare>true</declare>
+ <scope>AT_END</scope>
+ </variable>
+ </tag>
+ <tag>
+ <name>Bug48701c</name>
+ <tag-class>org.apache.jasper.compiler.TestGenerator$Bug48701</tag-class>
+ <body-content>empty</body-content>
+ <attribute>
+ <name>beanName</name>
+ <type>java.lang.String</type>
+ </attribute>
+ <variable>
+ <name-from-attribute>beanName</name-from-attribute>
+ <variable-class>org.apache.jasper.compiler.TestGenerator.Bean</variable-class>
+ <declare>true</declare>
+ <scope>AT_END</scope>
+ </variable>
+ </tag>
+
</taglib>
\ No newline at end of file
Added: tomcat/trunk/test/webapp-3.0/bug48701-TVI-NFA.jsp
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug48701-TVI-NFA.jsp?rev=921145&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug48701-TVI-NFA.jsp (added)
+++ tomcat/trunk/test/webapp-3.0/bug48701-TVI-NFA.jsp Tue Mar 9 21:51:46 2010
@@ -0,0 +1,20 @@
+<%--
+ 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:Bug48701c beanName="now" />
+<jsp:getProperty name="now" property="time" />
+<p>00-PASS</p>
Propchange: tomcat/trunk/test/webapp-3.0/bug48701-TVI-NFA.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/webapp-3.0/bug48701-TVI-NG.jsp
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug48701-TVI-NG.jsp?rev=921145&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug48701-TVI-NG.jsp (added)
+++ tomcat/trunk/test/webapp-3.0/bug48701-TVI-NG.jsp Tue Mar 9 21:51:46 2010
@@ -0,0 +1,20 @@
+<%--
+ 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:Bug48701b/>
+<jsp:getProperty name="now" property="time" />
+<p>00-PASS</p>
Propchange: tomcat/trunk/test/webapp-3.0/bug48701-TVI-NG.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/webapp-3.0/bug48701-UseBean.jsp
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug48701-UseBean.jsp?rev=921145&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug48701-UseBean.jsp (added)
+++ tomcat/trunk/test/webapp-3.0/bug48701-UseBean.jsp Tue Mar 9 21:51:46 2010
@@ -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.
+--%>
+<jsp:useBean id="now" class="java.util.Date" />
+<jsp:getProperty name="now" property="time" />
+<p>00-PASS</p>
\ No newline at end of file
Propchange: tomcat/trunk/test/webapp-3.0/bug48701-UseBean.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/webapp-3.0/bug48701-VI.jsp
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug48701-VI.jsp?rev=921145&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug48701-VI.jsp (added)
+++ tomcat/trunk/test/webapp-3.0/bug48701-VI.jsp Tue Mar 9 21:51:46 2010
@@ -0,0 +1,20 @@
+<%--
+ 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:Bug48701a/>
+<jsp:getProperty name="now" property="time" />
+<p>00-PASS</p>
Propchange: tomcat/trunk/test/webapp-3.0/bug48701-VI.jsp
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/webapp-3.0/bug48701-fail.jsp
URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug48701-fail.jsp?rev=921145&view=auto
==============================================================================
--- tomcat/trunk/test/webapp-3.0/bug48701-fail.jsp (added)
+++ tomcat/trunk/test/webapp-3.0/bug48701-fail.jsp Tue Mar 9 21:51:46 2010
@@ -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.
+--%>
+<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
+<c:set var="now" value='<%= new java.util.Date() %>' />
+<jsp:getProperty name="now" property="time" />
Propchange: tomcat/trunk/test/webapp-3.0/bug48701-fail.jsp
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org