incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r619015 - in /incubator/sling/trunk/launchpad/launchpad-webapp: ./ src/test/java/org/apache/sling/launchpad/webapp/integrationtest/ src/test/resources/integration-test/
Date Wed, 06 Feb 2008 15:24:11 GMT
Author: bdelacretaz
Date: Wed Feb  6 07:24:09 2008
New Revision: 619015

URL: http://svn.apache.org/viewvc?rev=619015&view=rev
Log:
Simple JSP scripting tests added, to make sure we test more than one scripting engine

Added:
    incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java
  (with props)
    incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/rendering-test.jsp
  (with props)
Modified:
    incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml
    incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpTestBase.java

Modified: incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml?rev=619015&r1=619014&r2=619015&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml (original)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/pom.xml Wed Feb  6 07:24:09 2008
@@ -469,6 +469,16 @@
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.scripting.jsp</artifactId>
+      <version>2.0.0-incubator-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.scripting.jsp.taglib</artifactId>
+      <version>2.0.0-incubator-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.jcr.jackrabbit.server</artifactId>
       <version>2.0.0-incubator-SNAPSHOT</version>
     </dependency>

Modified: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpTestBase.java?rev=619015&r1=619014&r2=619015&view=diff
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpTestBase.java
(original)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/HttpTestBase.java
Wed Feb  6 07:24:09 2008
@@ -42,6 +42,7 @@
 import org.apache.commons.httpclient.methods.PostMethod;
 import org.apache.sling.launchpad.webapp.integrationtest.helpers.HttpAnyMethod;
 import org.apache.sling.launchpad.webapp.integrationtest.helpers.UslingIntegrationTestClient;
+import org.apache.sling.ujax.UjaxPostServlet;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.ScriptableObject;
 
@@ -59,6 +60,8 @@
     public static final String CONTENT_TYPE_JSON = "application/json";
     public static final String CONTENT_TYPE_JS = "application/x-javascript";
     public static final String CONTENT_TYPE_CSS = "text/css";
+    
+    public static final String SLING_RESOURCE_TYPE = "sling:resourceType";
 
     protected UslingIntegrationTestClient testClient;
     protected HttpClient httpClient;
@@ -66,6 +69,29 @@
     private static boolean slingStartupOk; 
     private static final long startupTime = System.currentTimeMillis();
     
+    /** Class that creates a test node under the given parentPath, and 
+     *  stores useful values for testing. Created for JspScriptingTest,
+     *  older test classes do not use it, but it might simplify them.
+     */
+    protected class TestNode {
+        final String testText;
+        final String nodeUrl;
+        final String resourceType;
+        final String scriptPath;
+        
+        TestNode(String parentPath, Map<String, String> properties) throws IOException
{
+            if(properties == null) {
+                properties = new HashMap<String, String>();
+            }
+            testText = "This is a test node " + System.currentTimeMillis();
+            properties.put("text", testText);
+            nodeUrl = testClient.createNode(parentPath + UjaxPostServlet.DEFAULT_CREATE_SUFFIX,
properties);
+            resourceType = properties.get(SLING_RESOURCE_TYPE);
+            scriptPath = "/apps/" + (resourceType == null ? "nt/unstructured" : resourceType);
+            testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+        }
+    };
+
     @Override
     protected void setUp() throws Exception {
         super.setUp();

Added: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java?rev=619015&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java
(added)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/src/test/java/org/apache/sling/launchpad/webapp/integrationtest/JspScriptingTest.java
Wed Feb  6 07:24:09 2008
@@ -0,0 +1,86 @@
+/*
+ * 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 org.apache.sling.ujax.UjaxPostServlet;
+
+/** Test JSP scripting
+ *  TODO this class can be generalized to be used for any scripting language,
+ *  that would help in testing all scripting engines.
+ */
+public class JspScriptingTest extends HttpTestBase {
+ 
+    private String testRootUrl;
+    private TestNode rtNode;
+    private TestNode unstructuredNode;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        final String testRootPath = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/"
+ System.currentTimeMillis();
+        testRootUrl = testClient.createNode(testRootPath + UjaxPostServlet.DEFAULT_CREATE_SUFFIX,
null);
+        rtNode = new TestNode(testRootPath + "/rt", null);
+        unstructuredNode = new TestNode(testRootPath + "/unstructured", null);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        testClient.delete(testRootUrl);
+        super.tearDown();
+    }
+    
+    public void testRtNoScript() throws Exception {
+        final String content = getContent(rtNode.nodeUrl + ".txt", CONTENT_TYPE_PLAIN);
+        assertTrue(content.contains("PlainTextRendererServlet"));
+        assertTrue("Content contains " + rtNode.testText + " (" + content + ")", content.contains(rtNode.testText));
+    }
+
+    public void testUnstructuredNoScript() throws Exception {
+        final String content = getContent(unstructuredNode.nodeUrl + ".txt", CONTENT_TYPE_PLAIN);
+        assertTrue(content.contains("PlainTextRendererServlet"));
+        assertTrue("Content contains " + unstructuredNode.testText + " (" + content + ")",
content.contains(unstructuredNode.testText));
+    }
+    
+    public void testRtJsp() throws Exception {
+        final String toDelete = uploadTestScript(rtNode.scriptPath, "rendering-test.jsp",
"html.jsp");
+        try {
+            final String content = getContent(rtNode.nodeUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("JSP script executed as expected (" + content + ")", content.contains("JSP
rendering result"));
+            final String expected  = "JSP rendering result:" + rtNode.testText;
+            assertTrue("Content contains " + expected + "(" + content + ")", content.contains(expected));
+        } finally {
+            if(toDelete != null) {
+                testClient.delete(toDelete);
+            }
+        }
+    }
+
+    public void testUnstructuredJsp() throws Exception {
+        final String toDelete = uploadTestScript(unstructuredNode.scriptPath, "rendering-test.jsp",
"html.jsp");
+        try {
+            final String content = getContent(unstructuredNode.nodeUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("JSP script executed as expected (" + content + ")", content.contains("JSP
rendering result"));
+            final String expected  = "JSP rendering result:" + unstructuredNode.testText;
+            assertTrue("Content contains " + expected + "(" + content + ")", content.contains(expected));
+        } finally {
+            if(toDelete != null) {
+                testClient.delete(toDelete);
+            }
+        }
+    }
+}

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

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

Added: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/rendering-test.jsp
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/rendering-test.jsp?rev=619015&view=auto
==============================================================================
--- incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/rendering-test.jsp
(added)
+++ incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/rendering-test.jsp
Wed Feb  6 07:24:09 2008
@@ -0,0 +1,5 @@
+<!-- simple JSP rendering test -->
+<%@page session="false"%>
+<%@taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
+<sling:defineObjects/>
+JSP rendering result:<%= resource.adaptTo(javax.jcr.Node.class).getProperty("text").getValue().getString()
%>
\ No newline at end of file

Propchange: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/rendering-test.jsp
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/sling/trunk/launchpad/launchpad-webapp/src/test/resources/integration-test/rendering-test.jsp
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision Rev URL



Mime
View raw message