From 6ea67a6d640817b0feeb9ce7e6cbc6267a6a3e01 Mon Sep 17 00:00:00 2001 From: Kusal Kithul-Godage Date: Mon, 19 Dec 2022 17:03:14 +1100 Subject: [PATCH 1/3] WW-5270 Test for forwarding from Struts excluded URL to Struts Action --- .../struts2/showcase/servlet/TestServlet.java | 41 +++++++++++++++++++ apps/showcase/src/main/resources/struts.xml | 2 +- apps/showcase/src/main/webapp/WEB-INF/web.xml | 10 +++++ .../showcase/DispatcherResultTest.java | 2 - .../apache/struts2/showcase/ForwardTest.java | 41 +++++++++++++++++++ .../dispatcher/servlet/StrutsServlet.java | 3 +- 6 files changed, 94 insertions(+), 5 deletions(-) create mode 100644 apps/showcase/src/main/java/org/apache/struts2/showcase/servlet/TestServlet.java create mode 100644 apps/showcase/src/test/java/it/org/apache/struts2/showcase/ForwardTest.java diff --git a/apps/showcase/src/main/java/org/apache/struts2/showcase/servlet/TestServlet.java b/apps/showcase/src/main/java/org/apache/struts2/showcase/servlet/TestServlet.java new file mode 100644 index 0000000000..f754bd3a67 --- /dev/null +++ b/apps/showcase/src/main/java/org/apache/struts2/showcase/servlet/TestServlet.java @@ -0,0 +1,41 @@ +/* + * $Id$ + * + * 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.struts2.showcase.servlet; + +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; +import javax.servlet.http.HttpServletRequest; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; + +public class TestServlet extends HttpServlet { + @Override + public void service(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException { + switch (request.getPathInfo()) { + case "/forward": + getServletContext().getRequestDispatcher("/dispatcher/dispatch.action").forward(request, response); + break; + default: + response.sendError(404); + break; + } + } +} diff --git a/apps/showcase/src/main/resources/struts.xml b/apps/showcase/src/main/resources/struts.xml index cb47af8bf4..6354a36574 100644 --- a/apps/showcase/src/main/resources/struts.xml +++ b/apps/showcase/src/main/resources/struts.xml @@ -44,7 +44,7 @@ - + diff --git a/apps/showcase/src/main/webapp/WEB-INF/web.xml b/apps/showcase/src/main/webapp/WEB-INF/web.xml index 1bcfa4184e..001641b7d0 100644 --- a/apps/showcase/src/main/webapp/WEB-INF/web.xml +++ b/apps/showcase/src/main/webapp/WEB-INF/web.xml @@ -142,6 +142,11 @@ 4 + + testServlet + org.apache.struts2.showcase.servlet.TestServlet + + dwr /dwr/* @@ -162,6 +167,11 @@ /async/receiveNewMessages + + testServlet + /testServlet/* + +