You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by ss...@apache.org on 2022/09/12 16:35:49 UTC
[sling-org-apache-sling-launchpad-integration-tests] branch master updated: SLING-11569 Test case to validate including output from other servlets via RequestDispatcher
This is an automated email from the ASF dual-hosted git repository.
sseifert pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-integration-tests.git
The following commit(s) were added to refs/heads/master by this push:
new e9bd723 SLING-11569 Test case to validate including output from other servlets via RequestDispatcher
e9bd723 is described below
commit e9bd723ebd623006123c178f4adcead2f207c20d
Author: Stefan Seifert <st...@users.noreply.github.com>
AuthorDate: Thu Sep 8 13:19:06 2022 +0200
SLING-11569 Test case to validate including output from other servlets via RequestDispatcher
---
.../servlets/RequestDispatcherServletTest.java | 57 ++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/RequestDispatcherServletTest.java b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/RequestDispatcherServletTest.java
new file mode 100644
index 0000000..d42e4bd
--- /dev/null
+++ b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/RequestDispatcherServletTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.sling.launchpad.webapp.integrationtest.servlets;
+
+import java.io.IOException;
+
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+import org.junit.Test;
+
+/**
+ * Test servlets including other servlet responses via RequestDispatcher.
+ */
+public class RequestDispatcherServletTest extends HttpTestBase {
+
+ @Test
+ public void testOriginalResponse() throws IOException {
+ String content = getContent(HTTP_BASE_URL + "/testing/requestDispatcher/originalResponse", CONTENT_TYPE_PLAIN);
+
+ assertEquals("OriginalResponse", content);
+ }
+
+ /**
+ * Test includes output of OriginalResponseServlet directly via RequestDispatcher.
+ */
+ @Test
+ public void testIncludeDirect() throws IOException {
+ String content = getContent(HTTP_BASE_URL + "/testing/requestDispatcher/includeDirect", CONTENT_TYPE_PLAIN);
+
+ assertEquals("includeDirect(OriginalResponse)", content);
+ }
+
+ /**
+ * Test includes output of OriginalResponseServlet indirectly via RequestDispatcher, using a "synthetic response"
+ * created with Sling Builders API to buffer the response.
+ */
+ @Test
+ public void testIncludeBuffered() throws IOException {
+ String content = getContent(HTTP_BASE_URL + "/testing/requestDispatcher/includeBuffered", CONTENT_TYPE_PLAIN);
+
+ assertEquals("includeBuffered(OriginalResponse)", content);
+ }
+
+}
\ No newline at end of file