Colleague at $work reported issues path parameters and extension mapping so add some...
authormarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 6 Oct 2010 15:09:37 +0000 (15:09 +0000)
committermarkt <markt@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 6 Oct 2010 15:09:37 +0000 (15:09 +0000)
git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1005076 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/catalina/connector/TestCoyoteAdapter.java

index ac772ea..5a9d1ad 100644 (file)
@@ -130,4 +130,34 @@ public class TestCoyoteAdapter extends TomcatBaseTest {
             pw.write(sessionId);
         }
     }
+
+    public void testPathParamExtRootNoParam() throws Exception {
+        pathParamExtenionTest("/testapp/blah.txt", "none");
+    }
+
+    public void testPathParamExtLevel1NoParam() throws Exception {
+        pathParamExtenionTest("/testapp/blah/blah.txt", "none");
+    }
+
+    public void testPathParamExtLevel1WithParam() throws Exception {
+        pathParamExtenionTest("/testapp/blah;x=y/blah.txt", "none");
+    }
+
+    private void pathParamExtenionTest(String path, String expected)
+            throws Exception {
+        // Setup Tomcat instance
+        Tomcat tomcat = getTomcatInstance();
+
+        // Must have a real docBase - just use temp
+        Context ctx = 
+            tomcat.addContext("/testapp", System.getProperty("java.io.tmpdir"));
+
+        Tomcat.addServlet(ctx, "servlet", new PathParamServlet());
+        ctx.addServletMapping("*.txt", "servlet");
+
+        tomcat.start();
+
+        ByteChunk res = getUrl("http://localhost:" + getPort() + path);
+        assertEquals(expected, res.toString());
+    }
 }