Author: markt Date: Thu May 31 19:10:17 2012 New Revision: 1344868 URL: http://svn.apache.org/viewvc?rev=1344868&view=rev Log: Add some tests inspired by BZ53257 that confirm that the ServletContext correctly handles getResource() calls for resources that used ';', '+', '&', and '#' in the file name
Added: tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java (with props) tomcat/trunk/test/webapp-3.0/bug53257/ tomcat/trunk/test/webapp-3.0/bug53257/foo#bar tomcat/trunk/test/webapp-3.0/bug53257/foo&bar tomcat/trunk/test/webapp-3.0/bug53257/foo+bar tomcat/trunk/test/webapp-3.0/bug53257/foo;bar tomcat/trunk/test/webapp-3.0/bug53257/index.jsp (with props) Added: tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java URL: http://svn.apache.org/viewvc/tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java?rev=1344868&view=auto ============================================================================== --- tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java (added) +++ tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java Thu May 31 19:10:17 2012 @@ -0,0 +1,51 @@ +/* + * 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. + */ +package org.apache.catalina.core; + +import java.io.File; + +import org.junit.Assert; +import org.junit.Test; + +import org.apache.catalina.startup.Tomcat; +import org.apache.catalina.startup.TomcatBaseTest; +import org.apache.tomcat.util.buf.ByteChunk; + +public class TestApplicationContext extends TomcatBaseTest { + + @Test + public void testBug53257() 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/bug53257/index.jsp"); + + String result = res.toString(); + String[] lines = result.split("\n"); + for (String line : lines) { + if (line.startsWith("FAIL")) { + Assert.fail(line); + } + } + } +} Propchange: tomcat/trunk/test/org/apache/catalina/core/TestApplicationContext.java ------------------------------------------------------------------------------ svn:eol-style = native Added: tomcat/trunk/test/webapp-3.0/bug53257/foo#bar URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug53257/foo%23bar?rev=1344868&view=auto ============================================================================== --- tomcat/trunk/test/webapp-3.0/bug53257/foo#bar (added) +++ tomcat/trunk/test/webapp-3.0/bug53257/foo#bar Thu May 31 19:10:17 2012 @@ -0,0 +1 @@ +OK \ No newline at end of file Added: tomcat/trunk/test/webapp-3.0/bug53257/foo&bar URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug53257/foo%26bar?rev=1344868&view=auto ============================================================================== --- tomcat/trunk/test/webapp-3.0/bug53257/foo&bar (added) +++ tomcat/trunk/test/webapp-3.0/bug53257/foo&bar Thu May 31 19:10:17 2012 @@ -0,0 +1 @@ +OK \ No newline at end of file Added: tomcat/trunk/test/webapp-3.0/bug53257/foo+bar URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug53257/foo%2Bbar?rev=1344868&view=auto ============================================================================== --- tomcat/trunk/test/webapp-3.0/bug53257/foo+bar (added) +++ tomcat/trunk/test/webapp-3.0/bug53257/foo+bar Thu May 31 19:10:17 2012 @@ -0,0 +1 @@ +OK \ No newline at end of file Added: tomcat/trunk/test/webapp-3.0/bug53257/foo;bar URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug53257/foo%3Bbar?rev=1344868&view=auto ============================================================================== --- tomcat/trunk/test/webapp-3.0/bug53257/foo;bar (added) +++ tomcat/trunk/test/webapp-3.0/bug53257/foo;bar Thu May 31 19:10:17 2012 @@ -0,0 +1 @@ +OK \ No newline at end of file Added: tomcat/trunk/test/webapp-3.0/bug53257/index.jsp URL: http://svn.apache.org/viewvc/tomcat/trunk/test/webapp-3.0/bug53257/index.jsp?rev=1344868&view=auto ============================================================================== --- tomcat/trunk/test/webapp-3.0/bug53257/index.jsp (added) +++ tomcat/trunk/test/webapp-3.0/bug53257/index.jsp Thu May 31 19:10:17 2012 @@ -0,0 +1,34 @@ +<%-- + 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 contentType="text/plain; charset=UTF-8" +%><%@page import="java.net.URL,java.net.URLConnection"%><% + String[] testFiles = + new String[] {"foo;bar", "foo&bar", "foo#bar", "foo+bar"}; + for (String testFile : testFiles) { + URL url = application.getResource("/bug53257/" + testFile); + if (url == null) { + out.print("FAIL (url) - " + testFile + "\n"); + } else { + URLConnection conn = url.openConnection(); + long lastModified = conn.getLastModified(); + if (lastModified == -1) { + out.print("FAIL (last modified)- " + testFile + "\n"); + } else { + out.print("PASS - " + testFile + "\n"); + } + } + } +%> \ No newline at end of file Propchange: tomcat/trunk/test/webapp-3.0/bug53257/index.jsp ------------------------------------------------------------------------------ svn:eol-style = native --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org