Author: markt
Date: Wed Nov 27 19:58:05 2013
New Revision: 1546172
URL: http://svn.apache.org/r1546172
Log:
Create dependency to the TLD file rather than to the webappPath of the root of
the search
Add a test case for bug 55807 and the other issues fixed in TldScanner while
investigating bug 55807
Added:
tomcat/trunk/test/webapp/WEB-INF/classes/META-INF/bug55807.tld (with
props)
tomcat/trunk/test/webapp/bug5nnnn/bug55807.jsp (with props)
Modified:
tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java
tomcat/trunk/test/org/apache/jasper/servlet/TestTldScanner.java
Modified: tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java?rev=1546172&r1=1546171&r2=1546172&view=diff
==============================================================================
--- tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java (original)
+++ tomcat/trunk/java/org/apache/jasper/servlet/TldScanner.java Wed Nov 27
19:58:05 2013
@@ -313,6 +313,7 @@ public class TldScanner {
if (!metaInf.isDirectory()) {
return;
}
+ final Path filePath = file.toPath();
Files.walkFileTree(metaInf.toPath(), new SimpleFileVisitor<Path>()
{
@Override
public FileVisitResult visitFile(Path file,
@@ -322,9 +323,11 @@ public class TldScanner {
return FileVisitResult.CONTINUE;
}
+ String resourcePath = webappPath + "/" +
+ file.subpath(filePath.getNameCount(),
file.getNameCount());
try {
URL url = file.toUri().toURL();
- TldResourcePath path = new TldResourcePath(url,
webappPath);
+ TldResourcePath path = new TldResourcePath(url,
resourcePath);
parseTld(path);
tldFound = true;
} catch (SAXException e) {
Modified: tomcat/trunk/test/org/apache/jasper/servlet/TestTldScanner.java
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/jasper/servlet/TestTldScanner.java?rev=1546172&r1=1546171&r2=1546172&view=diff
==============================================================================
--- tomcat/trunk/test/org/apache/jasper/servlet/TestTldScanner.java (original)
+++ tomcat/trunk/test/org/apache/jasper/servlet/TestTldScanner.java Wed Nov 27
19:58:05 2013
@@ -17,6 +17,9 @@
package org.apache.jasper.servlet;
import java.io.File;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.junit.Assert;
import org.junit.Test;
@@ -24,6 +27,8 @@ import org.junit.Test;
import org.apache.catalina.Context;
import org.apache.catalina.startup.Tomcat;
import org.apache.catalina.startup.TomcatBaseTest;
+import org.apache.tomcat.util.buf.ByteChunk;
+import org.apache.tomcat.util.scan.StandardJarScanner;
public class TestTldScanner extends TomcatBaseTest {
@@ -39,4 +44,45 @@ public class TestTldScanner extends Tomc
Assert.assertEquals(5, scanner.getUriTldResourcePathMap().size());
Assert.assertEquals(1, scanner.getListeners().size());
}
+
+
+ @Test
+ public void testBug55807() throws Exception {
+ Tomcat tomcat = getTomcatInstance();
+
+ File appDir = new File("test/webapp");
+ Context context = tomcat.addWebapp(null, "/test",
appDir.getAbsolutePath());
+ ((StandardJarScanner)
context.getJarScanner()).setScanAllDirectories(true);
+ tomcat.start();
+
+ ByteChunk res = new ByteChunk();
+ Map<String,List<String>> headers = new HashMap<>();
+
+ getUrl("http://localhost:" + getPort() + "/test/bug5nnnn/bug55807.jsp",
+ res, headers);
+
+ // Check request completed
+ String result = res.toString();
+ assertEcho(result, "OK");
+
+ // Check the dependencies count
+ Assert.assertTrue(result.contains("<p>DependenciesCount: 1</p>"));
+
+ // Check the right timestamp was used in the dependency
+ File tld = new
File("test/webapp/WEB-INF/classes/META-INF/bug55807.tld");
+ String expected = "<p>/WEB-INF/classes/META-INF/bug55807.tld : " +
+ tld.lastModified() + "</p>";
+ Assert.assertTrue(result.contains(expected));
+
+
+ // Check content type
+
Assert.assertTrue(headers.get("Content-Type").get(0).startsWith("text/html"));
+ }
+
+
+ /** Assertion for text printed by tags:echo */
+ private static void assertEcho(String result, String expected) {
+ Assert.assertTrue(result, result.indexOf("<p>" + expected + "</p>") >
0);
+ }
+
}
Added: tomcat/trunk/test/webapp/WEB-INF/classes/META-INF/bug55807.tld
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/WEB-INF/classes/META-INF/bug55807.tld?rev=1546172&view=auto
==============================================================================
--- tomcat/trunk/test/webapp/WEB-INF/classes/META-INF/bug55807.tld (added)
+++ tomcat/trunk/test/webapp/WEB-INF/classes/META-INF/bug55807.tld Wed Nov 27
19:58:05 2013
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="ISO-8859-1" ?>
+<!--
+ 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.
+--><!DOCTYPE taglib
+ PUBLIC "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN"
+ "http://java.sun.com/dtd/web-jsptaglibrary_1_1.dtd">
+<taglib>
+ <tlibversion>1.0</tlibversion>
+ <jspversion>1.1</jspversion>
+ <shortname>Tags11</shortname>
+ <uri>http://tomcat.apache.org/bug55807</uri>
+
+ <tag>
+ <name>Echo</name>
+ <tagclass>org.apache.jasper.compiler.TestValidator$Echo</tagclass>
+ <bodycontent>empty</bodycontent>
+ <attribute>
+ <name>echo</name>
+ <required>yes</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ </tag>
+
+</taglib>
\ No newline at end of file
Propchange: tomcat/trunk/test/webapp/WEB-INF/classes/META-INF/bug55807.tld
------------------------------------------------------------------------------
svn:eol-style = native
Added: tomcat/trunk/test/webapp/bug5nnnn/bug55807.jsp
URL:
http://svn.apache.org/viewvc/tomcat/trunk/test/webapp/bug5nnnn/bug55807.jsp?rev=1546172&view=auto
==============================================================================
--- tomcat/trunk/test/webapp/bug5nnnn/bug55807.jsp (added)
+++ tomcat/trunk/test/webapp/bug5nnnn/bug55807.jsp Wed Nov 27 19:58:05 2013
@@ -0,0 +1,30 @@
+<%--
+ 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 language="java" contentType="text/html; charset=ISO-8859-1"
+ pageEncoding="ISO-8859-1" import="java.util.Map"%>
+<%@ taglib prefix="bug55807" uri="http://tomcat.apache.org/bug55807" %>
+<html>
+ <body>
+ <bug55807:Echo echo="OK"/>
+ <p>DependenciesCount: <%=_jspx_dependants.size() %></p>
+ <%
+ for (Map.Entry<String,Long> entry : _jspx_dependants.entrySet()) {
+ out.println("<p>" + entry.getKey() + " : " + entry.getValue() +
"</p>");
+ }
+ %>
+ </body>
+</html>
\ No newline at end of file
Propchange: tomcat/trunk/test/webapp/bug5nnnn/bug55807.jsp
------------------------------------------------------------------------------
svn:eol-style = native
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]