Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 70298 invoked from network); 29 Aug 2008 12:37:41 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 29 Aug 2008 12:37:41 -0000 Received: (qmail 91804 invoked by uid 500); 29 Aug 2008 12:37:39 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 91758 invoked by uid 500); 29 Aug 2008 12:37:39 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 91749 invoked by uid 99); 29 Aug 2008 12:37:39 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2008 05:37:39 -0700 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 29 Aug 2008 12:36:50 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 6DCC92388988; Fri, 29 Aug 2008 05:37:20 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: sling-commits@incubator.apache.org From: bdelacretaz@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20080829123720.6DCC92388988@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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 props = new HashMap(); + 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 props = new HashMap(); + 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