Merge pull request #5 from apache/dependabot/maven/org.apache.httpcomponents-httpclient-4.5.13
Bump httpclient from 4.3 to 4.5.13
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
diff --git a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletImportTest.java b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletImportTest.java
index cbe86e4..4ad3cfe 100644
--- a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletImportTest.java
+++ b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/post/PostServletImportTest.java
@@ -21,6 +21,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.nio.file.Files;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
@@ -84,7 +85,7 @@
}
private File getTestFile(InputStream inputStream) throws IOException {
- File tempFile = File.createTempFile("file-to-upload", null, new File("target"));
+ File tempFile = Files.createTempFile(new File("target").toPath(), "file-to-upload", null).toFile();
FileOutputStream outputStream = new FileOutputStream(tempFile);
byte[] bbuf = new byte[16384]; //16k
int len;
diff --git a/src/main/resources/integration-test/servlets/errorhandler/401.jsp b/src/main/resources/integration-test/servlets/errorhandler/401.jsp
index a46e407..818a79d 100644
--- a/src/main/resources/integration-test/servlets/errorhandler/401.jsp
+++ b/src/main/resources/integration-test/servlets/errorhandler/401.jsp
@@ -23,6 +23,7 @@
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
<%
String customMessage= "custom error page";
+response.setStatus(401);
%>
<html>
<head>
diff --git a/src/main/resources/integration-test/servlets/errorhandler/421.jsp b/src/main/resources/integration-test/servlets/errorhandler/421.jsp
index 41a88bc..12d5a6d 100644
--- a/src/main/resources/integration-test/servlets/errorhandler/421.jsp
+++ b/src/main/resources/integration-test/servlets/errorhandler/421.jsp
@@ -40,6 +40,8 @@
final List selectors = Arrays.asList(slingRequest.getRequestPathInfo().getSelectors());
if(selectors.contains("312")) {
response.setStatus(312);
+} else {
+ response.setStatus(421);
}
if(selectors.contains("errorScriptException")) {
throw new Exception("Exception in error handler");
diff --git a/src/main/resources/integration-test/servlets/errorhandler/500.jsp b/src/main/resources/integration-test/servlets/errorhandler/500.jsp
index e6a55bc..1294168 100644
--- a/src/main/resources/integration-test/servlets/errorhandler/500.jsp
+++ b/src/main/resources/integration-test/servlets/errorhandler/500.jsp
@@ -23,6 +23,7 @@
<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
<%
String customMessage= "custom error page";
+response.setStatus(500);
%>
<html>
<head>
diff --git a/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/POST.jsp b/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/POST.jsp
index b4f74b0..a39b974 100644
--- a/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/POST.jsp
+++ b/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/POST.jsp
@@ -22,6 +22,5 @@
%>
<%
-response.setStatus(500);
response.sendError(500);
%>
diff --git a/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/testErrorHandler.jsp b/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/testErrorHandler.jsp
index 80cf1a5..ebb9732 100644
--- a/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/testErrorHandler.jsp
+++ b/src/main/resources/integration-test/servlets/errorhandler/testErrorHandler/testErrorHandler.jsp
@@ -32,13 +32,10 @@
final SlingHttpServletRequest slingRequest = (SlingHttpServletRequest)request;
if(Arrays.asList(slingRequest.getRequestPathInfo().getSelectors()).contains(SELECTOR_401)) {
- response.setStatus(401);
response.sendError(401);
}else if(Arrays.asList(slingRequest.getRequestPathInfo().getSelectors()).contains(SELECTOR_421)) {
- response.setStatus(421);
response.sendError(421,"421 from rendering script");
}else if(Arrays.asList(slingRequest.getRequestPathInfo().getSelectors()).contains(SELECTOR_500)) {
- response.setStatus(500);
response.sendError(500);
}else if(Arrays.asList(slingRequest.getRequestPathInfo().getSelectors()).contains(SELECTOR_THROWABLE)) {
throw new Exception("throwable selector was specified");