This is an automated email from the ASF dual-hosted git repository.
enorman 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 6fe5251 revert part of the last commit of tests that are not ready yet
new 803a0ef Merge branch 'master' of
https://gitbox.apache.org/repos/asf/sling-org-apache-sling-launchpad-integration-tests
6fe5251 is described below
commit 6fe5251d93df4bed8aed1f205c3452f62a4c545e
Author: Eric Norman <[email protected]>
AuthorDate: Mon Aug 3 18:06:36 2020 -0700
revert part of the last commit of tests that are not ready yet
---
.../resolver/errorhandler/ErrorHandlingTest.java | 27 +----------
.../servlets/errorhandler/json.404.jsp | 52 ----------------------
2 files changed, 1 insertion(+), 78 deletions(-)
diff --git
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
index 0b1a6c8..1a26cd7 100644
---
a/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
+++
b/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
@@ -16,19 +16,14 @@
*/
package
org.apache.sling.launchpad.webapp.integrationtest.servlets.resolver.errorhandler;
-import java.io.StringReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
-import javax.json.Json;
-import javax.json.JsonObject;
-import javax.json.JsonReader;
-
import org.apache.commons.httpclient.NameValuePair;
-import org.apache.sling.launchpad.webapp.integrationtest.RenderingTestBase;
import org.apache.sling.servlets.post.SlingPostConstants;
+import org.apache.sling.launchpad.webapp.integrationtest.RenderingTestBase;
/** Test the sling error handling mechanism
http://sling.apache.org/site/errorhandling.html*/
public class ErrorHandlingTest extends RenderingTestBase {
@@ -63,7 +58,6 @@ public class ErrorHandlingTest extends RenderingTestBase {
testClient.mkdirs(HTTP_BASE_URL, ERROR_HANDLER_PATH);
testClient.mkdirs(HTTP_BASE_URL,
TEST_ROOT+"/"+THROW_ERROR_PATH);
uploadTestScript("servlets/errorhandler/404.jsp",
"sling/servlet/errorhandler/404.jsp");
- uploadTestScript("servlets/errorhandler/json.404.jsp",
"sling/servlet/errorhandler/json.404.jsp");
uploadTestScript("servlets/errorhandler/Throwable.jsp",
"sling/servlet/errorhandler/Throwable.jsp");
uploadTestScript("servlets/errorhandler/500.jsp",
"sling/servlet/errorhandler/500.jsp");
uploadTestScript("servlets/errorhandler/401.jsp",
"sling/servlet/errorhandler/401.jsp");
@@ -177,23 +171,4 @@ public class ErrorHandlingTest extends RenderingTestBase {
assertWithRetries(url, 500, expected, HTTP_METHOD_POST, params);
}
- /**
- * Test an error handling script registered for a json extension
- */
- public void test_404_errorhandling_JSON_extension() throws Throwable {
- final String url = testNodePath + NOT_EXISTING_NODE_PATH +
".json";
- List <NameValuePair> params=new ArrayList<NameValuePair>();
- String json = getContent(url, CONTENT_TYPE_JSON, params, 404,
HTTP_METHOD_GET);
-
- // assert the error content is right.
- JsonObject jsonObj = null;
- try (JsonReader reader = Json.createReader(new StringReader(json))) {
- jsonObj = reader.readObject();
- }
- assertNotNull(jsonObj);
- assertEquals(404, jsonObj.getInt("status"));
- assertEquals("Resource at '/apps/testNode/notExisting.json' not found:
No resource found", jsonObj.getString("message"));
- assertEquals("/apps/testNode/notExisting.json",
jsonObj.getString("request_uri"));
- }
-
}
diff --git
a/src/main/resources/integration-test/servlets/errorhandler/json.404.jsp
b/src/main/resources/integration-test/servlets/errorhandler/json.404.jsp
deleted file mode 100644
index b15ae57..0000000
--- a/src/main/resources/integration-test/servlets/errorhandler/json.404.jsp
+++ /dev/null
@@ -1,52 +0,0 @@
-<%@page import="javax.json.JsonWriter"%>
-<%@page import="javax.json.JsonObject"%>
-<%@page import="javax.json.JsonObjectBuilder"%>
-<%@page import="javax.json.JsonBuilderFactory"%>
-<%@page import="javax.json.Json"%>
-<%@page import="java.util.Collections"%>
-<%@page import="org.apache.sling.api.SlingConstants"%>
-<%
-/*
- * 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.
- */
-
-int status = (Integer)request.getAttribute(SlingConstants.ERROR_STATUS);
-response.setStatus(status);
-response.setCharacterEncoding("UTF-8");
-response.setContentType("application/json");
-
-JsonBuilderFactory factory = Json.createBuilderFactory(Collections.emptyMap());
-JsonObjectBuilder jsonObjBuilder = factory.createObjectBuilder();
-
-jsonObjBuilder.add("status", status);
-
-String msg = (String)request.getAttribute(SlingConstants.ERROR_MESSAGE);
-if (msg != null && !msg.isEmpty()) {
- jsonObjBuilder.add("message", msg);
-}
-
-String requestUri =
(String)request.getAttribute(SlingConstants.ERROR_REQUEST_URI);
-if (requestUri != null && !requestUri.isEmpty()) {
- jsonObjBuilder.add("request_uri", requestUri);
-}
-
-JsonObject jsonObj = jsonObjBuilder.build();
-JsonWriter jsonWriter = Json.createWriter(response.getWriter());
-jsonWriter.writeObject(jsonObj);
-jsonWriter.close();
-%>
\ No newline at end of file