From 7a32a8ceb0e03af4bf6bbd6c2b614609812089d7 Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Wed, 19 Jun 2024 17:39:43 -0500 Subject: [PATCH] Adding ee11 Cross Context Dispatch Testing --- .../ccd-ee11-webapp/pom.xml | 39 +++++ .../jetty/tests/ccd/ee11/CCDServlet.java | 108 ++++++++++++++ .../jetty/tests/ccd/ee11/DumpServlet.java | 135 ++++++++++++++++++ .../jetty/tests/ccd/ee11/ForwardServlet.java | 35 +++++ .../ccd/ee11/InternalRequestURIFilter.java | 56 ++++++++ .../src/main/webapp/WEB-INF/web.xml | 29 ++++ .../redispatch/AbstractRedispatchTest.java | 2 +- .../redispatch/RedispatchPlansTests.java | 1 + .../ee11-forward-to-ee8-include-ee9-dump.txt | 30 ++++ .../plans/ee11-request-forward-dump.txt | 12 ++ .../plans/ee11-request-include-dump.txt | 12 ++ .../plans/ee11-session-ee8-ee9-ee8.txt | 36 +++++ ...orward-to-ee8-session-include-ee9-dump.txt | 50 +++++++ .../test/resources/webapp-xmls/ccd-ee11.xml | 19 +++ tests/test-cross-context-dispatch/pom.xml | 1 + 15 files changed, 564 insertions(+), 1 deletion(-) create mode 100644 tests/test-cross-context-dispatch/ccd-ee11-webapp/pom.xml create mode 100644 tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/CCDServlet.java create mode 100644 tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/DumpServlet.java create mode 100644 tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/ForwardServlet.java create mode 100644 tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/InternalRequestURIFilter.java create mode 100644 tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/webapp/WEB-INF/web.xml create mode 100644 tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-forward-to-ee8-include-ee9-dump.txt create mode 100644 tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-forward-dump.txt create mode 100644 tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-include-dump.txt create mode 100644 tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-ee8-ee9-ee8.txt create mode 100644 tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-forward-to-ee8-session-include-ee9-dump.txt create mode 100644 tests/test-cross-context-dispatch/ccd-tests/src/test/resources/webapp-xmls/ccd-ee11.xml diff --git a/tests/test-cross-context-dispatch/ccd-ee11-webapp/pom.xml b/tests/test-cross-context-dispatch/ccd-ee11-webapp/pom.xml new file mode 100644 index 00000000000..4b8fa034774 --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-ee11-webapp/pom.xml @@ -0,0 +1,39 @@ + + + 4.0.0 + + org.eclipse.jetty.tests.ccd + test-cross-context-dispatch + 12.1.0-SNAPSHOT + + ccd-ee11-webapp + war + Tests :: Cross Context Dispatch :: ee11 WebApp + + + + + org.eclipse.jetty.ee11 + jetty-ee11-bom + ${project.version} + pom + import + + + + + + + jakarta.servlet + jakarta.servlet-api + 6.1.0 + provided + + + org.eclipse.jetty.tests.ccd + ccd-common + ${project.version} + provided + + + diff --git a/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/CCDServlet.java b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/CCDServlet.java new file mode 100644 index 00000000000..1010251f0f5 --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/CCDServlet.java @@ -0,0 +1,108 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.tests.ccd.ee11; + +import java.io.IOException; +import java.util.Objects; + +import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletContext; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.tests.ccd.common.DispatchPlan; +import org.eclipse.jetty.tests.ccd.common.Property; +import org.eclipse.jetty.tests.ccd.common.Step; + +public class CCDServlet extends HttpServlet +{ + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + DispatchPlan dispatchPlan = (DispatchPlan)req.getAttribute(DispatchPlan.class.getName()); + + if (dispatchPlan == null) + throw new ServletException("Unable to find DispatchPlan"); + + dispatchPlan.addEvent("%s.service() dispatcherType=%s method=%s requestUri=%s", + this.getClass().getName(), + req.getDispatcherType(), req.getMethod(), req.getRequestURI()); + + Step step; + + while ((step = dispatchPlan.popStep()) != null) + { + if (step instanceof Step.ContextRedispatch contextRedispatchStep) + { + ServletContext otherContext = getServletContext().getContext(contextRedispatchStep.getContextPath()); + if (otherContext == null) + throw new NullPointerException("ServletContext.getContext(\"" + contextRedispatchStep.getContextPath() + "\") returned null"); + RequestDispatcher dispatcher = otherContext.getRequestDispatcher(contextRedispatchStep.getDispatchPath()); + if (dispatcher == null) + throw new NullPointerException("ServletContext.getRequestDispatcher(\"" + contextRedispatchStep.getDispatchPath() + "\") returned null"); + switch (contextRedispatchStep.getDispatchType()) + { + case FORWARD -> dispatcher.forward(req, resp); + case INCLUDE -> dispatcher.include(req, resp); + } + return; + } + else if (step instanceof Step.RequestDispatch requestDispatchStep) + { + RequestDispatcher dispatcher = req.getRequestDispatcher(requestDispatchStep.getDispatchPath()); + if (dispatcher == null) + throw new NullPointerException("HttpServletRequest.getRequestDispatcher(\"" + requestDispatchStep.getDispatchPath() + "\") returned null"); + switch (requestDispatchStep.getDispatchType()) + { + case FORWARD -> dispatcher.forward(req, resp); + case INCLUDE -> dispatcher.include(req, resp); + } + return; + } + else if (step instanceof Step.GetHttpSession getHttpSessionTask) + { + HttpSession session = req.getSession(false); + if (session == null) + { + dispatchPlan.addEvent("%s.service() HttpSession is null", + this.getClass().getName()); + } + else + { + String name = getHttpSessionTask.getName(); + Object value = session.getAttribute(name); + dispatchPlan.addEvent("%s.service() HttpSession exists: [%s]=[%s]", + this.getClass().getName(), + name, + Objects.toString(value) + ); + } + + } + else if (step instanceof Step.HttpSessionSetAttribute sessionSetAttribute) + { + HttpSession session = req.getSession(true); + req.setAttribute("session[" + req.getRequestURI() + "].id", session.getId()); + Property prop = sessionSetAttribute.getProperty(); + session.setAttribute(prop.getName(), prop.getValue()); + } + else + { + throw new RuntimeException("Unable to execute task " + step + " in " + this.getClass().getName()); + } + } + } +} diff --git a/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/DumpServlet.java b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/DumpServlet.java new file mode 100644 index 00000000000..7f7045c0e0d --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/DumpServlet.java @@ -0,0 +1,135 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.tests.ccd.ee11; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.Collections; +import java.util.Enumeration; +import java.util.List; +import java.util.Objects; +import java.util.Properties; +import java.util.function.Function; +import java.util.function.Supplier; + +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.servlet.http.HttpSession; +import org.eclipse.jetty.tests.ccd.common.DispatchPlan; + +public class DumpServlet extends HttpServlet +{ + private static final String NULL = ""; + + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws IOException, ServletException + { + DispatchPlan dispatchPlan = (DispatchPlan)req.getAttribute(DispatchPlan.class.getName()); + + if (dispatchPlan != null) + { + dispatchPlan.addEvent("%s.service() dispatcherType=%s method=%s requestUri=%s", + this.getClass().getName(), + req.getDispatcherType(), req.getMethod(), req.getRequestURI()); + } + + Properties props = new Properties(); + props.setProperty("requestType", req.getClass().getName()); + props.setProperty("responseType", resp.getClass().getName()); + + props.setProperty("request.authType", Objects.toString(req.getAuthType(), NULL)); + props.setProperty("request.characterEncoding", Objects.toString(req.getCharacterEncoding(), NULL)); + props.setProperty("request.contentLength", Long.toString(req.getContentLengthLong())); + props.setProperty("request.contentType", Objects.toString(req.getContentType(), NULL)); + props.setProperty("request.contextPath", Objects.toString(req.getContextPath(), NULL)); + props.setProperty("request.dispatcherType", Objects.toString(req.getDispatcherType(), NULL)); + props.setProperty("request.localAddr", Objects.toString(req.getLocalAddr(), NULL)); + props.setProperty("request.localName", Objects.toString(req.getLocalName(), NULL)); + props.setProperty("request.localPort", Integer.toString(req.getLocalPort())); + props.setProperty("request.locale", Objects.toString(req.getLocale(), NULL)); + props.setProperty("request.method", Objects.toString(req.getMethod(), NULL)); + props.setProperty("request.pathInfo", Objects.toString(req.getPathInfo(), NULL)); + props.setProperty("request.pathTranslated", Objects.toString(req.getPathTranslated(), NULL)); + props.setProperty("request.protocol", Objects.toString(req.getProtocol(), NULL)); + props.setProperty("request.queryString", Objects.toString(req.getQueryString(), NULL)); + props.setProperty("request.remoteAddr", Objects.toString(req.getRemoteAddr(), NULL)); + props.setProperty("request.remoteHost", Objects.toString(req.getRemoteHost(), NULL)); + props.setProperty("request.remotePort", Integer.toString(req.getRemotePort())); + props.setProperty("request.remoteUser", Objects.toString(req.getRemoteUser(), NULL)); + props.setProperty("request.requestedSessionId", Objects.toString(req.getRequestedSessionId(), NULL)); + props.setProperty("request.requestURI", Objects.toString(req.getRequestURI(), NULL)); + props.setProperty("request.requestURL", Objects.toString(req.getRequestURL(), NULL)); + props.setProperty("request.serverPort", Integer.toString(req.getServerPort())); + props.setProperty("request.servletPath", Objects.toString(req.getServletPath(), NULL)); + + props.setProperty("request.session.exists", "false"); + HttpSession httpSession = req.getSession(false); + if (httpSession != null) + { + props.setProperty("request.session.exists", "true"); + List attrNames = Collections.list(httpSession.getAttributeNames()); + attrNames + .forEach((name) -> + { + Object attrVal = httpSession.getAttribute(name); + props.setProperty("session[" + name + "]", Objects.toString(attrVal, NULL)); + }); + } + + addAttributes(props, "req", req::getAttributeNames, req::getAttribute); + addAttributes(props, "context", + () -> getServletContext().getAttributeNames(), + (name) -> getServletContext().getAttribute(name)); + + List headerNames = Collections.list(req.getHeaderNames()); + headerNames + .forEach((name) -> + { + String headerVal = req.getHeader(name); + props.setProperty("header[" + name + "]", Objects.toString(headerVal, NULL)); + }); + + if (dispatchPlan != null) + { + int eventCount = dispatchPlan.getEvents().size(); + props.setProperty("dispatchPlan.events.count", Integer.toString(dispatchPlan.getEvents().size())); + for (int i = 0; i < eventCount; i++) + { + props.setProperty("dispatchPlan.event[" + i + "]", dispatchPlan.getEvents().get(i)); + } + } + + resp.setStatus(HttpServletResponse.SC_OK); + resp.setCharacterEncoding("utf-8"); + resp.setContentType("text/x-java-properties"); + PrintWriter out = resp.getWriter(); + props.store(out, "From " + this.getClass().getName()); + } + + private void addAttributes(Properties props, + String prefix, + Supplier> getNamesSupplier, + Function getAttributeFunction) + { + List attrNames = Collections.list(getNamesSupplier.get()); + attrNames + .forEach((name) -> + { + Object attrVal = getAttributeFunction.apply(name); + props.setProperty(prefix + ".attr[" + name + "]", Objects.toString(attrVal, NULL)); + }); + } +} diff --git a/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/ForwardServlet.java b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/ForwardServlet.java new file mode 100644 index 00000000000..ed01563de12 --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/ForwardServlet.java @@ -0,0 +1,35 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.tests.ccd.ee11; + +import java.io.IOException; +import java.util.Objects; + +import jakarta.servlet.RequestDispatcher; +import jakarta.servlet.ServletException; +import jakarta.servlet.http.HttpServlet; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +public class ForwardServlet extends HttpServlet +{ + @Override + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException + { + String forwardTo = req.getHeader("X-ForwardTo"); + Objects.requireNonNull(forwardTo); + RequestDispatcher requestDispatcher = req.getRequestDispatcher(forwardTo); + requestDispatcher.forward(req, resp); + } +} diff --git a/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/InternalRequestURIFilter.java b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/InternalRequestURIFilter.java new file mode 100644 index 00000000000..0a4e8824dd0 --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/java/org/eclipse/jetty/tests/ccd/ee11/InternalRequestURIFilter.java @@ -0,0 +1,56 @@ +// +// ======================================================================== +// Copyright (c) 1995 Mort Bay Consulting Pty Ltd and others. +// +// This program and the accompanying materials are made available under the +// terms of the Eclipse Public License v. 2.0 which is available at +// https://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0 +// which is available at https://www.apache.org/licenses/LICENSE-2.0. +// +// SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 +// ======================================================================== +// + +package org.eclipse.jetty.tests.ccd.ee11; + +import java.io.IOException; + +import jakarta.servlet.Filter; +import jakarta.servlet.FilterChain; +import jakarta.servlet.ServletException; +import jakarta.servlet.ServletRequest; +import jakarta.servlet.ServletResponse; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletRequestWrapper; +import jakarta.servlet.http.HttpServletResponse; + +/** + * A servlet filter that will harshly change the return value of + * {@link HttpServletRequest#getRequestURI()} to something that does + * not satisfy the Servlet spec URI invariant {@code request URI == context path + servlet path + path info} + */ +public class InternalRequestURIFilter implements Filter +{ + @Override + public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException + { + HttpServletRequest httpServletRequest = (HttpServletRequest)request; + HttpServletResponse httpServletResponse = (HttpServletResponse)response; + InternalRequestURIWrapper requestURIWrapper = new InternalRequestURIWrapper(httpServletRequest); + chain.doFilter(requestURIWrapper, httpServletResponse); + } + + private static class InternalRequestURIWrapper extends HttpServletRequestWrapper + { + public InternalRequestURIWrapper(HttpServletRequest request) + { + super(request); + } + + @Override + public String getRequestURI() + { + return "/internal/"; + } + } +} diff --git a/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/webapp/WEB-INF/web.xml b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/webapp/WEB-INF/web.xml new file mode 100644 index 00000000000..707c1d75ec1 --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-ee11-webapp/src/main/webapp/WEB-INF/web.xml @@ -0,0 +1,29 @@ + + + + ccd-ee10 + + + ccd + org.eclipse.jetty.tests.ccd.ee11.CCDServlet + + + + dump + org.eclipse.jetty.tests.ccd.ee11.DumpServlet + + + + ccd + /redispatch/* + + + + dump + /dump/* + + + \ No newline at end of file diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/AbstractRedispatchTest.java b/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/AbstractRedispatchTest.java index 9684de6d7e7..6dc60918493 100644 --- a/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/AbstractRedispatchTest.java +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/AbstractRedispatchTest.java @@ -40,7 +40,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue; public abstract class AbstractRedispatchTest { protected static final int START_TIMEOUT = Integer.getInteger("home.start.timeout", 30); - protected static final List ENVIRONMENTS = List.of("ee8", "ee9", "ee10"); + protected static final List ENVIRONMENTS = List.of("ee8", "ee9", "ee10", "ee11"); static String toResponseDetails(ContentResponse response) { diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/RedispatchPlansTests.java b/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/RedispatchPlansTests.java index a9f41c5de21..e1a311bab8e 100644 --- a/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/RedispatchPlansTests.java +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/java/org/eclipse/jetty/tests/redispatch/RedispatchPlansTests.java @@ -77,6 +77,7 @@ public class RedispatchPlansTests extends AbstractRedispatchTest List disabledTests = new ArrayList<>(); disabledTests.add("ee10-session-ee8-ee9-ee8.txt"); // causes an ISE + disabledTests.add("ee11-session-ee8-ee9-ee8.txt"); // causes an ISE Path testPlansDir = MavenPaths.findTestResourceDir("plans"); try (Stream plansStream = Files.list(testPlansDir)) diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-forward-to-ee8-include-ee9-dump.txt b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-forward-to-ee8-include-ee9-dump.txt new file mode 100644 index 00000000000..a9419633e64 --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-forward-to-ee8-include-ee9-dump.txt @@ -0,0 +1,30 @@ +REQUEST|GET|/ccd-ee11/redispatch/ee11 +STEP|SET_HTTP_SESSION_ATTRIBUTE|test-name-10|test-value-ee11 +STEP|CONTEXT_FORWARD|/ccd-ee8|/redispatch/ee8 +STEP|CONTEXT_FORWARD|/ccd-ee9|/redispatch/ee9 +STEP|REQUEST_INCLUDE|/dump/ee9 +EXPECTED_EVENT|Initial plan: ee11-forward-to-ee8-include-ee9-dump.txt +EXPECTED_EVENT|DispatchPlanHandler.handle() method=GET path-query=/ccd-ee11/redispatch/ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee11.CCDServlet.service() dispatcherType=REQUEST method=GET requestUri=/ccd-ee11/redispatch/ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() dispatcherType=FORWARD method=GET requestUri=/ccd-ee8/redispatch/ee8 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.CCDServlet.service() dispatcherType=FORWARD method=GET requestUri=/ccd-ee9/redispatch/ee9 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.DumpServlet.service() dispatcherType=INCLUDE method=GET requestUri=/ccd-ee9/redispatch/ee9 +EXPECTED_PROP|request.dispatcherType|INCLUDE +EXPECTED_PROP|request.requestURI|/ccd-ee9/redispatch/ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.context_path]|/ccd-ee8 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.path_info]|/ee8 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.request_uri]|/ccd-ee8/redispatch/ee8 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.servlet_path]|/redispatch +EXPECTED_PROP|req.attr[jakarta.servlet.include.context_path]/ccd-ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.include.path_info]|/ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.include.request_uri]|/ccd-ee9/dump/ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.include.servlet_path]/dump +EXPECTED_PROP|req.attr[javax.servlet.include.context_path]| +EXPECTED_PROP|req.attr[javax.servlet.include.path_info]| +EXPECTED_PROP|req.attr[javax.servlet.include.request_uri]| +EXPECTED_PROP|req.attr[javax.servlet.include.servlet_path]| +EXPECTED_PROP|req.attr[javax.servlet.forward.context_path]|/ccd-ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.path_info]|/ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.request_uri]|/ccd-ee8/redispatch/ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.servlet_path]|/redispatch +EXPECTED_SESSION_IDS|true \ No newline at end of file diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-forward-dump.txt b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-forward-dump.txt new file mode 100644 index 00000000000..d2e757f3c5c --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-forward-dump.txt @@ -0,0 +1,12 @@ +REQUEST|GET|/ccd-ee11/redispatch/ee11 +STEP|REQUEST_FORWARD|/dump/ee11 +EXPECTED_EVENT|Initial plan: ee11-request-forward-dump.txt +EXPECTED_EVENT|DispatchPlanHandler.handle() method=GET path-query=/ccd-ee11/redispatch/ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee11.CCDServlet.service() dispatcherType=REQUEST method=GET requestUri=/ccd-ee11/redispatch/ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee11.DumpServlet.service() dispatcherType=FORWARD method=GET requestUri=/ccd-ee11/dump/ee11 +EXPECTED_PROP|request.dispatcherType|FORWARD +EXPECTED_PROP|request.requestURI|/ccd-ee11/dump/ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.context_path]|/ccd-ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.path_info]|/ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.request_uri]|/ccd-ee11/redispatch/ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.servlet_path]|/redispatch diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-include-dump.txt b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-include-dump.txt new file mode 100644 index 00000000000..9edcc961b0b --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-request-include-dump.txt @@ -0,0 +1,12 @@ +REQUEST|GET|/ccd-ee11/redispatch/ee11 +STEP|REQUEST_INCLUDE|/dump/ee11 +EXPECTED_EVENT|Initial plan: ee11-request-include-dump.txt +EXPECTED_EVENT|DispatchPlanHandler.handle() method=GET path-query=/ccd-ee11/redispatch/ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee11.CCDServlet.service() dispatcherType=REQUEST method=GET requestUri=/ccd-ee11/redispatch/ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee11.DumpServlet.service() dispatcherType=INCLUDE method=GET requestUri=/ccd-ee11/redispatch/ee11 +EXPECTED_PROP|request.dispatcherType|INCLUDE +EXPECTED_PROP|request.requestURI|/ccd-ee11/redispatch/ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.include.context_path]|/ccd-ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.include.path_info]|/ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.include.request_uri]|/ccd-ee11/dump/ee11 +EXPECTED_PROP|req.attr[jakarta.servlet.include.servlet_path]|/dump diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-ee8-ee9-ee8.txt b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-ee8-ee9-ee8.txt new file mode 100644 index 00000000000..efde3f322eb --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-ee8-ee9-ee8.txt @@ -0,0 +1,36 @@ +REQUEST|GET|/ccd-ee11/redispatch/ee11 +# we reach ee11 +STEP|SET_HTTP_SESSION_ATTRIBUTE|test-name-10|test-value-ee11 +STEP|CONTEXT_FORWARD|/ccd-ee8|/redispatch/ee8 +# we reach ee8 +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-10 +STEP|SET_HTTP_SESSION_ATTRIBUTE|test-name-8|test-value-ee8 +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-10 +STEP|CONTEXT_FORWARD|/ccd-ee9|/redispatch/ee9 +# we reach ee9 +STEP|CONTEXT_FORWARD|/ccd-ee8|/redispatch/ee8 +# we reach ee8 again (does the HttpSession still exist, and has values?) +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-8 +STEP|REQUEST_FORWARD|/dump/ee8 +EXPECTED_EVENT|Initial plan: ee11-session-ee8-ee9-ee8.txt +EXPECTED_EVENT|DispatchPlanHandler.handle() method=GET path-query=/ccd-ee11/redispatch/ee11 +# we reach ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee11.CCDServlet.service() dispatcherType=REQUEST method=GET requestUri=/ccd-ee11/redispatch/ee11 +# we reach ee8 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() dispatcherType=FORWARD method=GET requestUri=/ccd-ee8/redispatch/ee8 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() HttpSession is null +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() HttpSession exists: [test-name-10]=[null] +# we reach ee9 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.DumpServlet.service() dispatcherType=INCLUDE method=GET requestUri=/ccd-ee9/redispatch/ee9 +# we reached ee8 again +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() HttpSession exists: [test-name-8]=[test-value-ee8] +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.DumpServlet.service() dispatcherType=FORWARD method=GET requestUri=/ccd-ee8/dump/ee8 +EXPECTED_PROP|request.dispatcherType|FORWARD +EXPECTED_PROP|request.requestURI|/ccd-ee8/dump/ee8 +EXPECTED_PROP|request.session.exists|true +EXPECTED_PROP|session[test-name-8]|test-value-ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.context_path]|/ccd-ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.path_info]|/ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.request_uri]|/ccd-ee8/dump/ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.servlet_path]|/dump +EXPECTED_SESSION_IDS|true \ No newline at end of file diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-forward-to-ee8-session-include-ee9-dump.txt b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-forward-to-ee8-session-include-ee9-dump.txt new file mode 100644 index 00000000000..69ba5f20a6f --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/plans/ee11-session-forward-to-ee8-session-include-ee9-dump.txt @@ -0,0 +1,50 @@ +REQUEST|GET|/ccd-ee11/redispatch/ee11 +# we reach ee11 +STEP|SET_HTTP_SESSION_ATTRIBUTE|test-name-10|test-value-ee11 +STEP|CONTEXT_FORWARD|/ccd-ee8|/redispatch/ee8 +# we reach ee8 +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-10 +STEP|SET_HTTP_SESSION_ATTRIBUTE|test-name-8|test-value-ee8 +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-10 +STEP|CONTEXT_FORWARD|/ccd-ee9|/redispatch/ee9 +# we reach ee9 +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-10 +STEP|SET_HTTP_SESSION_ATTRIBUTE|test-name|test-value-ee9 +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-10 +STEP|GET_HTTP_SESSION_ATTRIBUTE|test-name-8 +STEP|REQUEST_INCLUDE|/dump/ee9 +EXPECTED_EVENT|Initial plan: ee11-session-forward-to-ee8-session-include-ee9-dump.txt +EXPECTED_EVENT|DispatchPlanHandler.handle() method=GET path-query=/ccd-ee11/redispatch/ee11 +# we reach ee11 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee11.CCDServlet.service() dispatcherType=REQUEST method=GET requestUri=/ccd-ee11/redispatch/ee11 +# we reach ee8 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() dispatcherType=FORWARD method=GET requestUri=/ccd-ee8/redispatch/ee8 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() HttpSession is null +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee8.CCDServlet.service() HttpSession exists: [test-name-10]=[null] +# we reach ee9 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.CCDServlet.service() dispatcherType=FORWARD method=GET requestUri=/ccd-ee9/redispatch/ee9 +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.CCDServlet.service() HttpSession is null +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.CCDServlet.service() HttpSession exists: [test-name-10]=[null] +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.CCDServlet.service() HttpSession exists: [test-name-8]=[null] +EXPECTED_EVENT|org.eclipse.jetty.tests.ccd.ee9.DumpServlet.service() dispatcherType=INCLUDE method=GET requestUri=/ccd-ee9/redispatch/ee9 +EXPECTED_PROP|request.dispatcherType|INCLUDE +EXPECTED_PROP|request.requestURI|/ccd-ee9/redispatch/ee9 +EXPECTED_PROP|request.session.exists|true +EXPECTED_PROP|session[test-name]|test-value-ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.context_path]|/ccd-ee8 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.path_info]|/ee8 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.request_uri]|/ccd-ee8/redispatch/ee8 +EXPECTED_PROP|req.attr[jakarta.servlet.forward.servlet_path]|/redispatch +EXPECTED_PROP|req.attr[jakarta.servlet.include.context_path]/ccd-ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.include.path_info]|/ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.include.request_uri]|/ccd-ee9/dump/ee9 +EXPECTED_PROP|req.attr[jakarta.servlet.include.servlet_path]/dump +EXPECTED_PROP|req.attr[javax.servlet.include.context_path]| +EXPECTED_PROP|req.attr[javax.servlet.include.path_info]| +EXPECTED_PROP|req.attr[javax.servlet.include.request_uri]| +EXPECTED_PROP|req.attr[javax.servlet.include.servlet_path]| +EXPECTED_PROP|req.attr[javax.servlet.forward.context_path]|/ccd-ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.path_info]|/ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.request_uri]|/ccd-ee8/redispatch/ee8 +EXPECTED_PROP|req.attr[javax.servlet.forward.servlet_path]|/redispatch +EXPECTED_SESSION_IDS|true \ No newline at end of file diff --git a/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/webapp-xmls/ccd-ee11.xml b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/webapp-xmls/ccd-ee11.xml new file mode 100644 index 00000000000..374e64770ce --- /dev/null +++ b/tests/test-cross-context-dispatch/ccd-tests/src/test/resources/webapp-xmls/ccd-ee11.xml @@ -0,0 +1,19 @@ + + + + + /ccd-ee11 + /ccd-ee11 + true + + + + + + + + + + + + diff --git a/tests/test-cross-context-dispatch/pom.xml b/tests/test-cross-context-dispatch/pom.xml index 57488c76426..e515587e762 100644 --- a/tests/test-cross-context-dispatch/pom.xml +++ b/tests/test-cross-context-dispatch/pom.xml @@ -14,6 +14,7 @@ ccd-common + ccd-ee11-webapp ccd-ee10-webapp ccd-ee9-webapp ccd-ee8-webapp