You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by as...@apache.org on 2013/01/30 16:03:02 UTC

svn commit: r1440446 - in /sling/trunk/launchpad/integration-tests/src/main: java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/ java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ resources/inte...

Author: asanso
Date: Wed Jan 30 15:03:01 2013
New Revision: 1440446

URL: http://svn.apache.org/viewvc?rev=1440446&view=rev
Log:
SLING-2718 - Add integration test for the error handling mechanism. 
Committing initial test

Added:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
    sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/servlets/errorhandler/
    sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/servlets/errorhandler/404.jsp

Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java?rev=1440446&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java (added)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/servlets/resolver/errorhandler/ErrorHandlingTest.java Wed Jan 30 15:03:01 2013
@@ -0,0 +1,56 @@
+/*
+ * 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.resolver.errorhandler;
+
+import java.io.IOException;
+import org.apache.sling.launchpad.webapp.integrationtest.JspTestBase;
+
+
+/** Test the sling error handling mechanism http://sling.apache.org/site/errorhandling.html*/
+public class ErrorHandlingTest extends JspTestBase {
+
+	public final static String TEST_ROOT = "/apps";
+ 
+	public static final String ERROR_HANDLER_PATH = "/apps/sling/servlet/errorhandler";
+
+	private static final String NOT_EXISTING_NODE_PATH="/notExisting";
+
+	private String testNodePath;
+
+	@Override
+	protected void setUp() throws Exception {
+		super.setUp();
+		scriptPath = TEST_ROOT;
+		testClient.mkdirs(HTTP_BASE_URL, "/apps/sling/servlet/errorhandler");
+		uploadTestScript("servlets/errorhandler/404.jsp", "sling/servlet/errorhandler/404.jsp");
+		
+		testNodePath = testClient.createNode(HTTP_BASE_URL + TEST_ROOT, null);
+	}
+
+	@Override
+	protected void tearDown() throws Exception {
+		super.tearDown();
+		testClient.delete(HTTP_BASE_URL + TEST_ROOT);
+	}
+
+	public void test_404_errorhandling() throws IOException{	
+		final String expected = "No resource found (404) - custom error page";
+		final String url =  testNodePath+NOT_EXISTING_NODE_PATH +".html";	
+		assertContains(getContent(url, CONTENT_TYPE_HTML,null,200), expected);
+	}
+
+}

Added: sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/servlets/errorhandler/404.jsp
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/servlets/errorhandler/404.jsp?rev=1440446&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/servlets/errorhandler/404.jsp (added)
+++ sling/trunk/launchpad/integration-tests/src/main/resources/integration-test/servlets/errorhandler/404.jsp Wed Jan 30 15:03:01 2013
@@ -0,0 +1,34 @@
+<!--
+/*
+ * 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.
+-->
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
+<!-- simple JSP rendering test -->
+<%@page session="false"%>
+<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
+<%
+String customMessage= "custom error page";
+%>
+<html>
+	<head>
+		<title>404 No resource found</title>
+	</head>
+	<body>
+		<h1>No resource found (404) - <%=customMessage%></h1>
+	</body>
+</html>
\ No newline at end of file