SLING-601 Add integration test for new call counter functionality
git-svn-id: https://svn.apache.org/repos/asf/incubator/sling/trunk@738531 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java b/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
index 9882a3c..bce0225 100644
--- a/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
+++ b/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
@@ -38,6 +38,7 @@
private String nodeUrlC;
private String nodeUrlD;
private String nodeUrlE;
+ private String nodeUrlF;
private String scriptPath;
private String forcedResourceType;
private Set<String> toDelete = new HashSet<String>();
@@ -68,11 +69,16 @@
props.put("pathToInclude", pathToInclude + ".html");
nodeUrlE = testClient.createNode(url, props);
+ // Node F is used for the max calls detection test
+ props.put("testMaxCalls","true");
+ nodeUrlF = testClient.createNode(url, props);
+
// Node C is used for the infinite loop detection test
props.remove("pathToInclude");
+ props.remove("testMaxCalls");
props.put("testInfiniteLoop","true");
nodeUrlC = testClient.createNode(url, props);
-
+
// Node D is used for the "force resource type" test
forcedResourceType = getClass().getSimpleName() + "/" + System.currentTimeMillis();
props.remove("testInfiniteLoop");
@@ -131,6 +137,22 @@
assertTrue(
"Response contains infinite loop error message",
content.contains("org.apache.sling.api.request.RecursionTooDeepException"));
+
+ // TODO: SLING-515, status is 500 when running the tests as part of the maven build
+ // but 200 if running tests against a separate instance started with mvn jetty:run
+ // final int status = get.getStatusCode();
+ // assertEquals("Status is 500 for infinite loop",HttpServletResponse.SC_INTERNAL_SERVER_ERROR, status);
+ }
+
+ public void testMaxCallsDetection() throws IOException {
+ // Node F has a property that causes over 1000 includes
+ // Sling must indicate the problem in its response
+ final GetMethod get = new GetMethod(nodeUrlF + ".html");
+ httpClient.executeMethod(get);
+ final String content = get.getResponseBodyAsString();
+ assertTrue(
+ "Response contains infinite loop error message",
+ content.contains("org.apache.sling.api.request.TooManyCallsException"));
// TODO: SLING-515, status is 500 when running the tests as part of the maven build
// but 200 if running tests against a separate instance started with mvn jetty:run
diff --git a/src/test/resources/integration-test/include-test.jsp b/src/test/resources/integration-test/include-test.jsp
index 0f26e4d..75a3f2b 100644
--- a/src/test/resources/integration-test/include-test.jsp
+++ b/src/test/resources/integration-test/include-test.jsp
@@ -40,6 +40,7 @@
String pathToInclude = getProperty(currentNode, "pathToInclude");
String forceResourceType = getProperty(currentNode, "forceResourceType");
String testInfiniteLoop = getProperty(currentNode, "testInfiniteLoop");
+String testMaxCalls = getProperty(currentNode, "testMaxCalls");
%><html>
<body>
@@ -80,5 +81,23 @@
<%
}
%>
+
+ <h2>Test 4</h2>
+ <%
+ if(pathToInclude != null && testMaxCalls != null) {
+ %>
+ <p>pathToInclude = <%= pathToInclude %></p>
+ <p>Including <%= pathToInclude %></p>
+ <%
+ for (int i=0; i < 1200; i++) {
+ %>
+ <%= i %><br />
+ <hr />
+ <sling:include path="<%= pathToInclude %>" />
+ <hr />
+ <%
+ }
+ }
+ %>
</body>
</html>