Author: fmeschbe
Date: Wed Jan 28 16:47:50 2009
New Revision: 738531

URL: http://svn.apache.org/viewvc?rev=738531&view=rev
Log:
SLING-601 Add integration test for new call counter functionality

Modified:
    
incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
    
incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/include-test.jsp

Modified: 
incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java?rev=738531&r1=738530&r2=738531&view=diff
==============================================================================
--- 
incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
 (original)
+++ 
incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspIncludeTest.java
 Wed Jan 28 16:47:50 2009
@@ -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

Modified: 
incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/include-test.jsp
URL: 
http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/include-test.jsp?rev=738531&r1=738530&r2=738531&view=diff
==============================================================================
--- 
incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/include-test.jsp
 (original)
+++ 
incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/include-test.jsp
 Wed Jan 28 16:47:50 2009
@@ -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>


Reply via email to