You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2013/09/19 15:00:39 UTC

svn commit: r1524722 - /sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ImmediateScriptActivationTest.java

Author: bdelacretaz
Date: Thu Sep 19 13:00:38 2013
New Revision: 1524722

URL: http://svn.apache.org/r1524722
Log:
SLING-2788 - add test to verify immediate script activation

Added:
    sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ImmediateScriptActivationTest.java

Added: sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ImmediateScriptActivationTest.java
URL: http://svn.apache.org/viewvc/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ImmediateScriptActivationTest.java?rev=1524722&view=auto
==============================================================================
--- sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ImmediateScriptActivationTest.java (added)
+++ sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ImmediateScriptActivationTest.java Thu Sep 19 13:00:38 2013
@@ -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;
+
+import java.io.IOException;
+
+/** Upload many different scripts in sequence and verify that they are immediately
+ *  available to render content.
+ */
+public class ImmediateScriptActivationTest extends AbstractSlingResourceTypeRenderingTest {
+
+    public static final int LOOP_COUNT = 10;
+    
+    private void assertScriptActivation(String testId, String testScript, String extension, String expectedContent) throws IOException {
+        final String testUrl = displayUrl + "." + testId + ".html";
+        {
+            final String content = getContent(testUrl, CONTENT_TYPE_HTML);
+            assertFalse("Expecting no rendering script initially", content.contains(expectedContent));
+        }
+        
+        {
+            final String toDelete = uploadTestScript(testScript,testId + ".html" + extension);
+            try {
+                final String content = getContent(testUrl, CONTENT_TYPE_HTML);
+                assertContains(content, expectedContent);
+            } finally {
+                testClient.delete(toDelete);
+            }
+        }
+    }
+    
+    public void testEspActivation() throws IOException {
+        for(int i=0; i < LOOP_COUNT; i++) {
+            assertScriptActivation("test_" + i, "rendering-test.esp", ".esp", "ESP template");
+        }
+    }
+    
+    public void testJspActivation() throws IOException {
+        for(int i=0; i < LOOP_COUNT; i++) {
+            assertScriptActivation("test_" + i, "rendering-test.jsp", ".jsp", "<h1>JSP rendering result</h1>");
+        }
+    }
+}
\ No newline at end of file