Enable testcase for 50413#c6, now that the issue is fixed with r1056889.
authorkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 9 Jan 2011 08:10:33 +0000 (08:10 +0000)
committerkkolinko <kkolinko@13f79535-47bb-0310-9956-ffa450edef68>
Sun, 9 Jan 2011 08:10:33 +0000 (08:10 +0000)
Update changelog.

git-svn-id: https://svn.apache.org/repos/asf/tomcat/trunk@1056890 13f79535-47bb-0310-9956-ffa450edef68

test/org/apache/catalina/servlets/TestDefaultServlet.java
webapps/docs/changelog.xml

index 1125737..42ec3c2 100644 (file)
@@ -220,8 +220,47 @@ public class TestDefaultServlet extends TomcatBaseTest {
         client.connect();
         client.processRequest();
         assertTrue(client.isResponse404());
-        // FIXME: The following currently fails
-        // assertEquals("It is 404.html", client.getResponseBody());
+        assertEquals("It is 404.html", client.getResponseBody());
+    }
+
+    /**
+     * Test what happens if a custom 404 page is configured,
+     * but its file is actually missing.
+     */
+    public void testCustomErrorPageMissing() throws Exception {
+        File appDir = new File(getTemporaryDirectory(), "MyApp");
+        new File(appDir, "WEB-INF").mkdirs();
+        Writer w = new OutputStreamWriter(new FileOutputStream(new File(appDir,
+                "WEB-INF/web.xml")), "UTF-8");
+        try {
+            w.write("<?xml version='1.0' encoding='UTF-8'?>\n"
+                    + "<web-app xmlns='http://java.sun.com/xml/ns/j2ee' "
+                    + " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"
+                    + " xsi:schemaLocation='http://java.sun.com/xml/ns/j2ee "
+                    + " http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd'"
+                    + " version='2.4'>\n"
+                    + "<error-page>\n<error-code>404</error-code>\n"
+                    + "<location>/404-absent.html</location>\n</error-page>\n"
+                    + "</web-app>\n");
+            w.flush();
+        } finally {
+            w.close();
+        }
+
+        Tomcat tomcat = getTomcatInstance();
+        String contextPath = "/MyApp";
+        tomcat.addWebapp(null, contextPath, appDir.getAbsolutePath());
+        tomcat.start();
+
+        TestCustomErrorClient client = new TestCustomErrorClient();
+        client.setPort(getPort());
+
+        client.reset();
+        client.setRequest(new String[] { "GET /MyApp/missing HTTP/1.0" + CRLF
+                + CRLF });
+        client.connect();
+        client.processRequest();
+        assertTrue(client.isResponse404());
     }
 
     public static int getUrl(String path, ByteChunk out,
index 90c9213..ce8454e 100644 (file)
       </fix>
       <fix>
         <bug>50413</bug>: Ensure 304 responses are not returned when using
-        static files as error pages. (markt)
+        static files as error pages. (markt/kkolinko)
       </fix>
       <fix>
         <bug>50448</bug>: Fix possible <code>IllegalStateException</code>