TAP-2388: Update test and example app
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/6f4c5640 Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/6f4c5640 Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/6f4c5640 Branch: refs/heads/beanmodel-split Commit: 6f4c5640ccd7e2122a46a7d0cc62cd771efa69b1 Parents: a43e17f Author: Howard M. Lewis Ship <hls...@apache.org> Authored: Fri Oct 24 16:09:12 2014 -0700 Committer: Howard M. Lewis Ship <hls...@apache.org> Committed: Fri Oct 24 16:09:12 2014 -0700 ---------------------------------------------------------------------- .../services/ComponentEventDispatcher.java | 3 -- .../internal/services/PageRenderDispatcher.java | 3 ++ tapestry-core/src/test/app5/WEB-INF/web.xml | 40 +++++++++++--------- .../integration/app5/ProductionModeTests.groovy | 7 ++-- .../integration/app5/pages/Error404.groovy | 20 ++++++++++ .../integration/app5/pages/Error404.tml | 18 +++++++++ 6 files changed, 67 insertions(+), 24 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6f4c5640/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventDispatcher.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventDispatcher.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventDispatcher.java index 555ff39..1d0bd5d 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventDispatcher.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/ComponentEventDispatcher.java @@ -49,9 +49,6 @@ public class ComponentEventDispatcher implements Dispatcher // ... in which case, this attribute is set. if (request.getAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND) != null) { - // This needs to be cleared out because the container may submit a request back into the filter - // for the 404 page and some containers reuse the existing HttpServletRequest. See TAP5-2388. - request.setAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND, null); return false; } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6f4c5640/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderDispatcher.java ---------------------------------------------------------------------- diff --git a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderDispatcher.java b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderDispatcher.java index 2e9e255..38e02e7 100644 --- a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderDispatcher.java +++ b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/PageRenderDispatcher.java @@ -42,6 +42,9 @@ public class PageRenderDispatcher implements Dispatcher if (request.getAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND) != null) { + // This needs to be cleared out because the container may submit a request back into the filter + // for the 404 page and some containers reuse the existing HttpServletRequest. See TAP5-2388. + request.setAttribute(InternalConstants.REFERENCED_COMPONENT_NOT_FOUND, null); return false; } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6f4c5640/tapestry-core/src/test/app5/WEB-INF/web.xml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/app5/WEB-INF/web.xml b/tapestry-core/src/test/app5/WEB-INF/web.xml index a1bcd9f..c8c61c3 100644 --- a/tapestry-core/src/test/app5/WEB-INF/web.xml +++ b/tapestry-core/src/test/app5/WEB-INF/web.xml @@ -1,19 +1,25 @@ <?xml version="1.0" encoding="UTF-8"?> -<!DOCTYPE web-app - PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" - "http://java.sun.com/dtd/web-app_2_3.dtd"> -<web-app> - <display-name>Integration Test App 5 -- Skinning</display-name> - <context-param> - <param-name>tapestry.app-package</param-name> - <param-value>org.apache.tapestry5.integration.app5</param-value> - </context-param> - <filter> - <filter-name>app</filter-name> - <filter-class>org.apache.tapestry5.TapestryFilter</filter-class> - </filter> - <filter-mapping> - <filter-name>app</filter-name> - <url-pattern>/*</url-pattern> - </filter-mapping> +<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"> + <display-name>Integration Test App 5 -- Skinning</display-name> + <context-param> + <param-name>tapestry.app-package</param-name> + <param-value>org.apache.tapestry5.integration.app5</param-value> + </context-param> + <filter> + <filter-name>app</filter-name> + <filter-class>org.apache.tapestry5.TapestryFilter</filter-class> + + </filter> + <filter-mapping> + <filter-name>app</filter-name> + <url-pattern>/*</url-pattern> + <dispatcher>REQUEST</dispatcher> + <dispatcher>ERROR</dispatcher> + </filter-mapping> + <error-page> + <error-code>404</error-code> + <location>/error404</location> + </error-page> </web-app> http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6f4c5640/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/ProductionModeTests.groovy ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/ProductionModeTests.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/ProductionModeTests.groovy index 265ac0b..484a39d 100644 --- a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/ProductionModeTests.groovy +++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/ProductionModeTests.groovy @@ -9,15 +9,14 @@ import org.testng.annotations.Test class ProductionModeTests extends TapestryCoreTestCase { @Test - void invalid_component_id_is_404() - { + void invalid_component_id_is_404() { openBaseURL() assertTitle "Default Layout" - def invalid = new URL("${baseURL}index.missing") + open "${baseURL}index.missing" - assertEquals 404, invalid.openConnection().responseCode + assertTitle "Error: 404" } } http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6f4c5640/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/pages/Error404.groovy ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/pages/Error404.groovy b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/pages/Error404.groovy new file mode 100644 index 0000000..0845a9d --- /dev/null +++ b/tapestry-core/src/test/groovy/org/apache/tapestry5/integration/app5/pages/Error404.groovy @@ -0,0 +1,20 @@ +package org.apache.tapestry5.integration.app5.pages + +import org.apache.tapestry5.ioc.annotations.Inject +import org.apache.tapestry5.services.Request +import org.apache.tapestry5.services.Response + +import javax.servlet.http.HttpServletResponse + +class Error404 { + + @Inject + Request request + + @Inject + Response response + + void beginRender() { + response.setStatus HttpServletResponse.SC_NOT_FOUND + } +} http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/6f4c5640/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app5/pages/Error404.tml ---------------------------------------------------------------------- diff --git a/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app5/pages/Error404.tml b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app5/pages/Error404.tml new file mode 100644 index 0000000..c1a36a9 --- /dev/null +++ b/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app5/pages/Error404.tml @@ -0,0 +1,18 @@ +<html xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"> + <head> + <title>Error: 404</title> + </head> + <body> + <div class="container"> + <div class="panel panel-danger"> + <div class="panel-heading"> + <h3 class="panel-title">Error 404: Not Found</h3> + </div> + <div class="panel-body"> + <p>The requested path,<code>${request.getAttribute('javax.servlet.error.request_uri')}</code>, was not found. + </p> + </div> + </div> + </div> + </body> +</html> \ No newline at end of file