incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r690209 - in /incubator/sling/trunk/launchpad/testing/src/test: java/org/apache/sling/launchpad/webapp/integrationtest/ resources/integration-test/ resources/integration-test/esp-load/ resources/integration-test/esp-load/subfolder/
Date Fri, 29 Aug 2008 12:37:20 GMT
Author: bdelacretaz
Date: Fri Aug 29 05:37:19 2008
New Revision: 690209

URL: http://svn.apache.org/viewvc?rev=690209&view=rev
Log:
SLING-428 - integration tests for ESP load() and print() functions

Added:
    incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java
  (with props)
    incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/
    incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/included-a.esp
    incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/main.esp
    incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/subfolder/
    incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/subfolder/included-b.esp
    incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/print.esp
Modified:
    incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java

Added: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java?rev=690209&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java
(added)
+++ incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java
Fri Aug 29 05:37:19 2008
@@ -0,0 +1,90 @@
+/*
+ * 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.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.sling.commons.testing.integration.HttpTestBase;
+
+/** Test the SLING-428 esp load function */
+public class EspLoadTest extends HttpTestBase {
+    
+    private String basePath;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        basePath = "/" + getClass().getSimpleName() + "_" + System.currentTimeMillis();
+    }
+    
+    public void testNestedInclude() throws Exception {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("scriptToInclude", "included-a.esp");
+        props.put(SLING_RESOURCE_TYPE, getClass().getSimpleName());
+        final TestNode tn = new TestNode(HTTP_BASE_URL + basePath, props);
+        final String subfolder = tn.scriptPath + "/subfolder";
+        testClient.mkdirs(WEBDAV_BASE_URL, subfolder);
+        final String [] toDelete = {
+                uploadTestScript(tn.scriptPath, "esp-load/main.esp", "html.esp"),
+                uploadTestScript(tn.scriptPath, "esp-load/included-a.esp", "included-a.esp"),
+                uploadTestScript(subfolder, 
+                        "esp-load/subfolder/included-b.esp", "included-b.esp")
+        };
+
+        try {
+            final String content = getContent(tn.nodeUrl + ".html", CONTENT_TYPE_HTML);
+            
+            final String [] expectedStringsInOrder = {
+                    "main.esp before load",
+                    "included-a.esp before load",
+                    "included-b.esp",
+                    "included-a.esp after load",
+                    "main.esp after load"
+            };
+            
+            int pos = 0;
+            for(String expected : expectedStringsInOrder) {
+                final int newPos = content.indexOf(expected);
+                assertTrue("Content (" + content + ") must contain '" + expected + "'", newPos
>= 0);
+                assertTrue("String '" + expected + "' must come after previous expected string",
newPos > pos);
+                pos = newPos;
+            }
+        } finally {
+            for(String s : toDelete) {
+                testClient.delete(s);
+            }
+        }
+    }
+    
+    public void testNonExistentInclude() throws Exception {
+        final Map<String,String> props = new HashMap<String,String>();
+        final String badScript = "nonexistent.esp";
+        props.put("scriptToInclude", badScript);
+        props.put(SLING_RESOURCE_TYPE, getClass().getSimpleName());
+        final TestNode tn = new TestNode(HTTP_BASE_URL + basePath, props);
+        final String toDelete = uploadTestScript(tn.scriptPath, "esp-load/main.esp", "html.esp");
+        try {
+            assertHttpStatus(tn.nodeUrl + ".html", HttpServletResponse.SC_INTERNAL_SERVER_ERROR,
+                    "Including " + badScript + " must fail");
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+}

Propchange: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/EspLoadTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL

Modified: incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java?rev=690209&r1=690208&r2=690209&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
(original)
+++ incubator/sling/trunk/launchpad/testing/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/NodetypeRenderingTest.java
Fri Aug 29 05:37:19 2008
@@ -68,7 +68,19 @@
             testClient.delete(toDelete);
         }
     }
-
+    
+    public void testPrint() throws IOException {
+        final String toDelete = uploadTestScript("print.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            final String expected = "print.esp ends";
+            assertTrue("Content (" + content + ") must contain '" + expected + "'",
+                    content.contains(expected));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+    
     public void testEspHtml() throws IOException {
         final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
         try {

Added: incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/included-a.esp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/included-a.esp?rev=690209&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/included-a.esp
(added)
+++ incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/included-a.esp
Fri Aug 29 05:37:19 2008
@@ -0,0 +1,6 @@
+// Test SLING-428
+included-a.esp before load.
+
+<% load("subfolder/included-b.esp"); %>
+
+included-a.esp after load
\ No newline at end of file

Added: incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/main.esp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/main.esp?rev=690209&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/main.esp
(added)
+++ incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/main.esp
Fri Aug 29 05:37:19 2008
@@ -0,0 +1,6 @@
+// Test SLING-428
+main.esp before load.
+
+<% load(currentNode.scriptToInclude); %>
+
+main.esp after load
\ No newline at end of file

Added: incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/subfolder/included-b.esp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/subfolder/included-b.esp?rev=690209&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/subfolder/included-b.esp
(added)
+++ incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/esp-load/subfolder/included-b.esp
Fri Aug 29 05:37:19 2008
@@ -0,0 +1,2 @@
+// Test SLING-428
+included-b.esp
\ No newline at end of file

Added: incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/print.esp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/print.esp?rev=690209&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/print.esp
(added)
+++ incubator/sling/trunk/launchpad/testing/src/test/resources/integration-test/print.esp
Fri Aug 29 05:37:19 2008
@@ -0,0 +1,3 @@
+// Verify that the print() method compiles
+<% print("something from print.esp"); %>
+print.esp ends
\ No newline at end of file



Mime
View raw message