incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r612830 [1/2] - in /incubator/sling/trunk/usling/usling-webapp: ./ src/test/java/org/apache/sling/usling/webapp/integrationtest/ src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/ src/test/resources/integration-test/
Date Thu, 17 Jan 2008 14:42:32 GMT
Author: bdelacretaz
Date: Thu Jan 17 06:41:57 2008
New Revision: 612830

URL: http://svn.apache.org/viewvc?rev=612830&view=rev
Log:
SLING-149 - merge usling into Sling - integration tests 'ported' from microsling, tests which don't pass yet disabled using TODO_FAILS function name prefix

Added:
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GeneratedNodeNameTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GetWithSuffixTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/IncludeTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/JsonRenderingTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/MkdirTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/NodetypeRenderingTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostParameterTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostRedirectTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PropertyRenderingTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ScriptBuiltinObjectsTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SlingResourceTypeRenderingTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StaticContentTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StreamServletTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SyntheticResourceTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ValueFromTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/package.html   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/PostServletCreateTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/PostServletDeleteTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/PostServletOrderTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/PostServletUpdateTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/UjaxAutoPropertiesTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ujax/UjaxSessionInfoTest.java   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/builtin-objects.esp
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/include-test.esp
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/post-test.esp
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test-2.esp
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test-3.esp
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test.erb
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test.esp
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test.ftl
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test.js   (with props)
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test.jst
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/rendering-test.vlt
    incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/testfile.html   (with props)
Modified:
    incubator/sling/trunk/usling/usling-webapp/pom.xml
    incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/UslingHttpTestBase.java

Modified: incubator/sling/trunk/usling/usling-webapp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/pom.xml?rev=612830&r1=612829&r2=612830&view=diff
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/pom.xml (original)
+++ incubator/sling/trunk/usling/usling-webapp/pom.xml Thu Jan 17 06:41:57 2008
@@ -445,6 +445,11 @@
     </dependency>
     <dependency>
       <groupId>org.apache.sling</groupId>
+      <artifactId>org.apache.sling.scripting.api</artifactId>
+      <version>2.0.0-incubator-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.sling</groupId>
       <artifactId>org.apache.sling.scripting.resolver</artifactId>
       <version>2.0.0-incubator-SNAPSHOT</version>
     </dependency>

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GeneratedNodeNameTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GeneratedNodeNameTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GeneratedNodeNameTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GeneratedNodeNameTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,63 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Test the generation of node names for POST requests to URLS
+ *  ending in / *
+ */
+public class GeneratedNodeNameTest extends UslingHttpTestBase {
+    
+    private final String postUrl = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + System.currentTimeMillis() + "/UJAX_create";
+
+    public void testTitle() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("title", "Hello There");
+        final String location = testClient.createNode(postUrl, props);
+        final String expect = "hello_there";
+        assertTrue("Location " + location + " ends with " + expect,location.endsWith(expect));
+    }
+    
+    public void testTitleWithSavePrefix() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("./title", "Hello There 2");
+        props.put("title", "not this one");
+        final String location = testClient.createNode(postUrl, props);
+        final String expect = "hello_there_2";
+        assertTrue("Location " + location + " ends with " + expect,location.endsWith(expect));
+    }
+    
+    public void testCollision() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("title", "Hello There");
+        
+        // posting twice with the same title must work, and return different locations
+        final String locationA = testClient.createNode(postUrl, props);
+        final String locationB = testClient.createNode(postUrl, props);
+        
+        assertFalse("Locations A and B must be different (" + locationA + "," + locationB + ")",
+                locationA.equals(locationB));
+    }
+    
+    public void testNoParams() throws IOException {
+        final String location = testClient.createNode(postUrl, null);
+        assertTrue("Location end with a digit",Character.isDigit(location.charAt(location.length() - 1)));
+    }
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GetWithSuffixTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GetWithSuffixTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GetWithSuffixTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/GetWithSuffixTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,84 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+/** GET requests with a suffix should fail with a 404, otherwise
+ *  we get a lot of extra possible URLs which point to the same
+ *  content.
+ */
+public class GetWithSuffixTest extends RenderingTestBase {
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set test values
+        testText = "This is a test " + System.currentTimeMillis();
+
+        // create the test node, under a path that's specific to this class to allow collisions
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "." + System.currentTimeMillis();
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("text", testText);
+        displayUrl = testClient.createNode(url, props);
+
+        // the rendering script goes under /apps in the repository
+        scriptPath = "/apps/nt/unstructured";
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+    }
+    
+    public void testNothing() {
+        // TODO remove this once all TODO_FAILS are gone
+    }
+    
+    public void TODO_FAILS_testWithExactUrl() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testWithExtraPathA() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
+        try {
+            assertHttpStatus(displayUrl + "/extra.html", HttpServletResponse.SC_NOT_FOUND);
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+    
+    /** behavior seems slightly different if using GET.esp vs. html.esp for the
+     *  script name, verify that both give a 404
+     */
+    public void TODO_FAILS_testWithExtraPathB() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","GET.esp");
+        try {
+            assertHttpStatus(displayUrl + "/extra/more.a4.html", HttpServletResponse.SC_NOT_FOUND);
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/IncludeTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/IncludeTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/IncludeTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/IncludeTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,95 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.servlet.http.HttpServletResponse;
+
+/** Test the {link ScriptHelper#include) functionality */
+ public class IncludeTest extends UslingHttpTestBase {
+
+    private String nodeUrlA;
+    private String testTextA;
+    private String nodeUrlB;
+    private String testTextB;
+    private String nodeUrlC;
+    private String scriptPath;
+    private String toDelete;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        // Create the test nodes under a path that's specific to this class to
+        // allow collisions
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + System.currentTimeMillis() + "/UJAX_create";
+        final Map<String,String> props = new HashMap<String,String>();
+        
+        // Create two test nodes and store their paths
+        testTextA = "Text A " + System.currentTimeMillis();
+        props.put("text", testTextA);
+        nodeUrlA = testClient.createNode(url, props);
+        
+        // Node B stores the path of A, so that the test script can
+        // include A when rendering B
+        testTextB = "Text B " + System.currentTimeMillis();
+        props.put("text", testTextB);
+        props.put("pathToInclude", new URL(nodeUrlA).getPath());
+        nodeUrlB = testClient.createNode(url, props);
+        
+        // Node C is used for the infinite loop detection test
+        props.remove("pathToInclude");
+        props.put("testInfiniteLoop","true");
+        nodeUrlC = testClient.createNode(url, props);
+
+        // the rendering script goes under /apps in the repository
+        scriptPath = "/apps/nt/unstructured";
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+        toDelete = uploadTestScript(scriptPath,"include-test.esp","html.esp");
+    }
+    
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+        testClient.delete(toDelete);
+    }
+
+    public void testWithoutInclude() throws IOException {
+        final String content = getContent(nodeUrlA + ".html", CONTENT_TYPE_HTML);
+        assertTrue("Content includes ESP marker",content.contains("ESP template"));
+        assertTrue("Content contains formatted test text",content.contains("<p class=\"main\">" + testTextA + "</p>"));
+        assertFalse("Nothing has been included",content.contains("<p>Including"));
+    }
+
+    public void testWithInclude() throws IOException {
+        final String content = getContent(nodeUrlB + ".html", CONTENT_TYPE_HTML);
+        assertTrue("Content includes ESP marker",content.contains("ESP template"));
+        assertTrue("Content contains formatted test text",content.contains("<p class=\"main\">" + testTextB + "</p>"));
+        assertTrue("Include has been used",content.contains("<p>Including"));
+    }
+    
+    public void TODO_FAILS_testInfiniteLoopDetection() throws IOException {
+        // Node C has a property that causes an infinite include loop,
+        // microsling must return an error 500 in this case
+        assertHttpStatus(nodeUrlC + ".html", HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
+    }
+
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/JsonRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/JsonRenderingTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/JsonRenderingTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/JsonRenderingTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,123 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Test creating Nodes and rendering them in JSON */
+public class JsonRenderingTest extends UslingHttpTestBase {
+
+    private String postUrl; 
+    private String testText;
+    private String jsonUrl;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        // set test values
+        testText = "This is a test " + System.currentTimeMillis();
+        
+        // create the test node, under a path that's specific to this class to allow collisions
+        postUrl = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "_" + System.currentTimeMillis() + "/UJAX_create";
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("text", testText);
+        jsonUrl = testClient.createNode(postUrl, props) + ".json";
+    }
+    
+    /** test our assertJavascript method with static json */ 
+    public void testAssertJavascript() throws IOException {
+        final String json = "{ 'a' : '123', 'b' : '456' }";
+        assertJavascript("123456", json ,"out.println(data.a + data.b)");
+    }
+    
+    public void testNonRecursive() throws IOException {
+        final String json = getContent(jsonUrl, CONTENT_TYPE_JSON);
+        assertJavascript(testText, json ,"out.println(data.text)");
+    }
+    
+    /**  Create a node with children, verify that we get them back in JSON format */ 
+    public void testRecursiveOneLevel() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("text", testText);
+        
+        final String parentNodeUrl = testClient.createNode(postUrl, props);
+        final String [] children = { "A", "B", "C" };
+        for(String child : children) {
+            props.put("child", child);
+            testClient.createNode(parentNodeUrl + "/" + child, props);
+        }
+        
+        final String json = getContent(parentNodeUrl + ".json?maxlevels=1", CONTENT_TYPE_JSON);
+        assertJavascript(testText, json, "out.print(data.text)");
+        for(String child : children) {
+            assertJavascript(child, json, "out.print(data['" + child + "'].child)");
+            assertJavascript(testText, json, "out.print(data['" + child + "'].text)");
+        }
+    }
+    
+    /**  Create a node with children, verify that we do not get them back in 
+     *   JSON format if using recursion level=0 */ 
+    public void testRecursiveZeroLevels() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("text", testText);
+        
+        final String parentNodeUrl = testClient.createNode(postUrl, props);
+        final String [] children = { "A", "B", "C" };
+        for(String child : children) {
+            props.put("child", child);
+            testClient.createNode(parentNodeUrl + "/" + child, props);
+        }
+        
+        final String json = getContent(parentNodeUrl + ".json?maxlevels=0", CONTENT_TYPE_JSON);
+        assertJavascript(testText, json, "out.print(data.text)");
+        for(String child : children) {
+            assertJavascript("undefined", json, "out.print(typeof data['" + child + "'])");
+        }
+    }
+    
+    public void testEscapedStrings() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("dq", "Some text with \"double quotes\"");
+        props.put("sq", "Some text with 'single quotes'");
+        props.put("cb", "Some text with {curly brackets}");
+        props.put("sb", "Some text with [square brackets]");
+        props.put("eol", "Some text with end\nof\nlines\nand\ttabs");
+        
+        final String location = testClient.createNode(postUrl, props);
+        final String json = getContent(location + ".json", CONTENT_TYPE_JSON);
+        
+        for(String key : props.keySet()) {
+            assertJavascript(props.get(key),json,"out.println(data." + key + ")");
+        }
+    }
+    
+    public void testAccentedStrings() throws IOException {
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("a", "Les amis en \u000C9t\u000C9 au ch\u000Eteau");
+        props.put("b", "The \u000B0 degree sign and \u000F5 ntilde");
+        
+        final String location = testClient.createNode(postUrl, props);
+        final String json = getContent(location + ".json", CONTENT_TYPE_JSON);
+        
+        for(String key : props.keySet()) {
+            assertJavascript(props.get(key),json,"out.println(data." + key + ")");
+        }
+    }
+ }
\ No newline at end of file

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/MkdirTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/MkdirTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/MkdirTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/MkdirTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,62 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+
+/** Test the MicroslingIntegrationTestClient's mkdir functions */ 
+public class MkdirTest extends UslingHttpTestBase {
+    
+    /** Try creating a directory via WebDAV */
+    public void testMkdir() throws IOException {
+        final String testDirUrl = WEBDAV_BASE_URL + TEST_PATH + System.currentTimeMillis();
+        
+        assertHttpStatus(testDirUrl, 404, testDirUrl);
+        
+        try {
+            testClient.mkdir(testDirUrl);
+        } catch(IOException ioe) {
+            fail(ioe.getMessage());
+        }
+        
+        assertHttpStatus(testDirUrl, 200, testDirUrl);
+        
+        try {
+            testClient.mkdir(testDirUrl);
+        } catch(IOException ioe) {
+            fail("mkdir must succeed on an existing directory, got IOException:" + ioe);
+        }
+        
+        assertHttpStatus(testDirUrl, 200, testDirUrl);
+        
+        testClient.delete(testDirUrl);
+        assertHttpStatus(testDirUrl, 404, testDirUrl + " must be gone after DELETE");
+    }
+    
+    /** Try creating a deep directory structure */
+    public void testMkdirDeep() throws IOException {
+        final String path = TEST_PATH + "/mkdir-test-" + System.currentTimeMillis() + "/something";
+        final String url = WEBDAV_BASE_URL + path;
+        assertHttpStatus(url,404,url + " must not exist before test");
+        try {
+            testClient.mkdirs(WEBDAV_BASE_URL, path);
+        } catch(IOException ioe) {
+            fail("mkdirs failed:" + ioe);
+        }
+        assertHttpStatus(url,200,url + " must exist after test");
+    }
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/NodetypeRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/NodetypeRenderingTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/NodetypeRenderingTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/NodetypeRenderingTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,157 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Test creating a Node and rendering it using scripts in
+ *  various supported languages, using nodetype-based
+ *  script resolution
+ */
+public class NodetypeRenderingTest extends RenderingTestBase {
+
+    private String secondFolderOfContentPath;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set test values
+        testText = "This is a test " + System.currentTimeMillis();
+
+        // create the test node, under a path that's specific to this class to allow collisions
+        secondFolderOfContentPath = "" + System.currentTimeMillis();
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + secondFolderOfContentPath + "/UJAX_create";
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("text", testText);
+        displayUrl = testClient.createNode(url, props);
+
+        // the rendering script goes under /apps in the repository
+        scriptPath = "/apps/nt/unstructured";
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+    }
+
+    public void testWithoutScriptTxt() throws IOException {
+        final String content = getContent(displayUrl + ".txt", CONTENT_TYPE_PLAIN);
+        assertTrue("Content includes PlainTextRendererServlet marker",content.contains("dumped by PlainTextRendererServlet"));
+    }
+
+    public void testWithoutScriptHtml() throws IOException {
+        final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+        assertTrue("Content contains default rendering",content.contains("Node dumped by DefaultHtmlRenderer"));
+    }
+
+    public void testEspHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspXml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","xml.esp");
+        try {
+            final String content = getContent(displayUrl + ".xml", CONTENT_TYPE_XML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+    
+    public void TODO_FAILS_testEspHtmlWithContentBasedPath() throws IOException {
+        
+        // make sure there's no leftover rendering script
+        {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertFalse("Content must not include ESP marker before test",content.contains("ESP template"));
+        }
+        
+        // put our script in the /apps/<second folder level of content> (SLING-125)
+        final String path = "/apps/" + secondFolderOfContentPath;
+        testClient.mkdirs(WEBDAV_BASE_URL, path);
+        final String toDelete = uploadTestScript(path,"rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspPlain() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","txt.esp");
+        try {
+            final String content = getContent(displayUrl + ".txt", CONTENT_TYPE_PLAIN);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testVltHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.vlt","html.vlt");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes VLT marker",content.contains("Velocity template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><b>" + testText + "</b></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testJsHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.js","html.js");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes JS marker",content.contains("Raw javascript template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><em>" + testText + "</em></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testFtlHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.ftl","html.ftl");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes FreeMarker marker",content.contains("FreeMarker template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><span>" + testText + "</span></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testErbHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.erb","html.erb");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes Ruby marker",content.contains("Ruby template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><span>" + testText + "</span></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostParameterTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostParameterTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostParameterTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostParameterTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,75 @@
+package org.apache.sling.usling.webapp.integrationtest;
+
+import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.commons.httpclient.methods.MultipartPostMethod;
+import org.apache.commons.httpclient.NameValuePair;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.Map;
+import java.util.HashMap;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+
+/**
+ * Check if multipart post request are handled well
+ */
+public class PostParameterTest extends RenderingTestBase {
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set test values
+        testText = "This is a test " + System.currentTimeMillis();
+
+        // create the test node, under a path that's specific to this class to allow collisions
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "." + System.currentTimeMillis();
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("text", testText);
+        displayUrl = testClient.createNode(url, props);
+
+        // the rendering script goes under /apps in the repository
+        scriptPath = "/apps/nt/unstructured";
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+    }
+    
+    public void testNothing() {
+        // TODO remove this all TODO_FAILS_ are gone 
+    }
+
+    public void TODO_FAILS_testBinaryUpload() throws IOException {
+        final String toDelete = uploadTestScript("post-test.esp","POST.esp");
+        File f = null;
+        try {
+
+            MultipartPostMethod post = new MultipartPostMethod(displayUrl);
+            post.setFollowRedirects(false);
+
+            // create simple test file
+            f = File.createTempFile("posttest",".txt");
+            FileWriter fstream = new FileWriter(f.getAbsolutePath());
+            BufferedWriter out = new BufferedWriter(fstream);
+            out.write("Hello uSling");
+            out.close();
+
+            post.addParameter("file", f);
+
+            final int status = httpClient.executeMethod(post);
+            final String response = post.getResponseBodyAsString();
+
+            // check confirmed file length sent from script
+            assertEquals(200, status);
+            assertEquals(f.length(), (long) Double.parseDouble(response));
+
+            post.releaseConnection();
+        } finally {
+            if (f != null) {
+                f.delete();
+            }
+            testClient.delete(toDelete);
+        }
+    }
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostRedirectTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostRedirectTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostRedirectTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PostRedirectTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,66 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+
+/** Test the various redirect options for POST, SLING-126 */
+public class PostRedirectTest extends UslingHttpTestBase {
+
+    private String postPath = "CreateNodeTest/" + System.currentTimeMillis();
+    private String postUrl = HTTP_BASE_URL + "/" + postPath + "/UJAX_create";
+    
+    public void testForcedRedirect() throws IOException {
+        final Map<String,String> params = new HashMap<String,String>();
+        params.put("ujax:redirect","http://forced/");
+        final Map<String,String> headers = new HashMap<String,String>();
+        headers.put("Referer", "http://referer/");
+        
+        final String location = testClient.createNode(postUrl, params, headers, false);
+        assertEquals("With forced redirect and Referer, redirect must be forced","http://forced/",location);
+    }
+    
+    public void testDefaultRedirect() throws IOException {
+        final String location = testClient.createNode(postUrl, null, null, false);
+        assertTrue(
+                "With no headers or parameters, redirect (" + location 
+                + ") must point to created node (path=" + postPath + ")",
+                location.contains(postPath));
+    }
+    
+    public void testRefererRedirect() throws IOException {
+        final Map<String,String> headers = new HashMap<String,String>();
+        headers.put("Referer", "http://referer/");
+        final String location = testClient.createNode(postUrl, null, headers, true);
+        assertEquals("With Referer, redirect must point to referer","http://referer/",location);
+    }
+    
+    public void testMagicStarRedirect() throws IOException {
+        final Map<String,String> params = new HashMap<String,String>();
+        params.put("ujax:redirect","*");
+        final Map<String,String> headers = new HashMap<String,String>();
+        headers.put("Referer", "http://referer/");
+        final String location = testClient.createNode(postUrl, params, headers, false);
+        assertTrue(
+                "With magic star, redirect (" + location 
+                + ") must point to created node (path=" + postPath + ")",
+                location.contains(postPath));
+    }
+}
\ No newline at end of file

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PropertyRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PropertyRenderingTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PropertyRenderingTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/PropertyRenderingTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,75 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Test the rendering of JCR Properties, directly addressed by URLs.
+ *  See SLING-133
+ */
+public class PropertyRenderingTest extends RenderingTestBase {
+
+    private String slingResourceType;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set test values
+        testText = "This is a test " + System.currentTimeMillis();
+        slingResourceType = getClass().getName();
+
+        // create the test node, under a path that's specific to this class to allow collisions
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + System.currentTimeMillis() + "/UJAX_create";
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("sling:resourceType", slingResourceType);
+        props.put("text", testText);
+        displayUrl = testClient.createNode(url, props);
+    }
+
+    public void testNodeAccess() throws IOException {
+        final String json = getContent(displayUrl + ".json", CONTENT_TYPE_JSON);
+        assertJavascript(testText, json, "out.println(data.text)");
+    }
+    
+    public void TODO_FAILS_testTextJson() throws IOException {
+        final String json = getContent(displayUrl + "/text.json", CONTENT_TYPE_JSON);
+        assertEquals("{\"text\":\"" + testText + "\"}",json);
+    }
+
+    public void TODO_FAILS_testTextHtml() throws IOException {
+        final String data = getContent(displayUrl + "/text.html", CONTENT_TYPE_HTML);
+        assertEquals(testText, data);
+    }
+    
+    public void TODO_FAILS_testTextTxt() throws IOException {
+        final String data = getContent(displayUrl + "/text.txt", CONTENT_TYPE_PLAIN);
+        assertEquals(testText, data);
+    }
+    
+    public void TODO_FAILS_testTextNoExt() throws IOException {
+        final String data = getContent(displayUrl + "/text", CONTENT_TYPE_PLAIN);
+        assertEquals(testText, data);
+    }
+    
+    public void TODO_FAILS_testResourceTypeNoExt() throws IOException {
+        final String data = getContent(displayUrl + "/sling:resourceType", CONTENT_TYPE_PLAIN);
+        assertEquals(slingResourceType, data);
+    }
+}
\ No newline at end of file

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ScriptBuiltinObjectsTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ScriptBuiltinObjectsTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ScriptBuiltinObjectsTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/ScriptBuiltinObjectsTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,48 @@
+package org.apache.sling.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ScriptBuiltinObjectsTest extends RenderingTestBase {
+    
+    private String slingResourceType;
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set test values
+        slingResourceType = "integration-test/srt." + System.currentTimeMillis();
+        testText = "This is a test " + System.currentTimeMillis();
+
+        // create the test node, under a path that's specific to this class to allow collisions
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + System.currentTimeMillis() + "/UJAX_create";
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("sling:resourceType", slingResourceType);
+        props.put("text", testText);
+        displayUrl = testClient.createNode(url, props);
+
+        // the rendering script goes under /apps in the repository
+        scriptPath = "/apps/" + slingResourceType;
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+    }
+
+    public void testNothing() {
+        // TODO remove this all TODO_FAILS_ are gone 
+    }
+ 
+    public void TODO_FAILS_testEspBuiltinObjects() throws IOException {
+        final String toDelete = uploadTestScript("builtin-objects.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content includes test text", content.contains(testText));
+            assertTrue("Content includes ServletContext data",content.contains("ServletContext:text/plain"));
+            assertTrue("Content includes response data",content.contains("SlingHttpServletResponse:false"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+    
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SlingResourceTypeRenderingTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SlingResourceTypeRenderingTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SlingResourceTypeRenderingTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SlingResourceTypeRenderingTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,303 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+/** Test creating a Node and rendering it using scripts in
+ *  various supported languages, using slingResourceType-based
+ *  script resolution
+ */
+public class SlingResourceTypeRenderingTest extends RenderingTestBase {
+
+    private String slingResourceType;
+    private String secondFolderOfContentPath;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+
+        // set test values
+        slingResourceType = "integration-test/srt." + System.currentTimeMillis();
+        testText = "This is a test " + System.currentTimeMillis();
+
+        // create the test node, under a path that's specific to this class to allow collisions
+        secondFolderOfContentPath = "" + System.currentTimeMillis();
+        final String url = HTTP_BASE_URL + "/" + getClass().getSimpleName() + "/" + secondFolderOfContentPath + "/UJAX_create";
+        final Map<String,String> props = new HashMap<String,String>();
+        props.put("sling:resourceType", slingResourceType);
+        props.put("text", testText);
+        displayUrl = testClient.createNode(url, props);
+
+        // the rendering script goes under /apps in the repository
+        scriptPath = "/apps/" + slingResourceType;
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+    }
+
+    public void testWithoutScriptTxt() throws IOException {
+        final String content = getContent(displayUrl + ".txt", CONTENT_TYPE_PLAIN);
+        assertTrue("Content includes PlainTextRendererServlet marker",content.contains("dumped by PlainTextRendererServlet"));
+    }
+
+    public void testWithoutScriptHtml() throws IOException {
+        final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+        assertTrue("Content contains default rendering",content.contains("Node dumped by DefaultHtmlRenderer"));
+    }
+
+    public void testEspHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+            assertTrue("Content (" + content + ") contains attribute generated with simplified syntax",
+                    content.contains("<div class=\"SLING-142\" id=\"22\"/>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspJavaCode() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains java code output",content.contains("TestLinkedListTest"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspHtmlInAppsFolder() throws IOException {
+        // make sure there's no leftover rendering script
+        {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertFalse("Content must not include ESP marker before test",content.contains("ESP template"));
+        }
+
+        // put our script under /apps/<resource type>
+        final String path = "/apps/" + slingResourceType;
+        testClient.mkdirs(WEBDAV_BASE_URL, path);
+        final String toDelete = uploadTestScript(path,"rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testEspHtmlWithContentBasedPath() throws IOException {
+        
+        // make sure there's no leftover rendering script
+        {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertFalse("Content must not include ESP marker before test",content.contains("ESP template"));
+        }
+        
+        // put our script in the /apps/<second folder level of content> (SLING-125)
+        final String path = "/apps/" + secondFolderOfContentPath;
+        testClient.mkdirs(WEBDAV_BASE_URL, path);
+        final String toDelete = uploadTestScript(path,"rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspHtmlWithSelectors() throws IOException {
+        final String toDeleteA = uploadTestScript("rendering-test.esp","html.esp");
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath + "/a4/print");
+        final String toDeleteB = uploadTestScript(scriptPath + "/a4","rendering-test-2.esp","html.esp");
+        final String toDeleteC = uploadTestScript(scriptPath + "/a4/print","rendering-test-3.esp","html.esp");
+        
+        try {
+            String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Without selectors, content includes standard marker",content.contains("ESP template"));
+            assertTrue("Without selectors, content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+            
+            content = getContent(displayUrl + ".a4.print.html", CONTENT_TYPE_HTML);
+            assertTrue("With a4.print selectors, content includes marker 3",content.contains("Template #3 for ESP tests"));
+            assertTrue("With a4.print selectors, content contains italic text",content.contains("<em>" + testText + "</em>"));
+            
+            content = getContent(displayUrl + ".a4.html", CONTENT_TYPE_HTML);
+            assertTrue("With a4 selector, content includes marker 2",content.contains("Template #2 for ESP tests"));
+            assertTrue("With a4 selector, content contains bold text",content.contains("<b>" + testText + "</b>"));
+            
+            content = getContent(displayUrl + ".different.html", CONTENT_TYPE_HTML);
+            assertTrue("With different selector only, content includes standard marker",content.contains("ESP template"));
+            assertTrue("With different selector only, content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDeleteA);
+            testClient.delete(toDeleteB);
+            testClient.delete(toDeleteC);
+        }
+    }
+
+    public void TODO_FAILS_testJstHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.jst","html.jst");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes JST marker",content.contains("JST template"));
+            assertTrue("Content contains JSON data",content.contains("\"text\":\"" + testText + "\""));
+            assertTrue("Content contains default rendering",content.contains("div id=\"JstDefaultRendering"));
+            assertTrue("Content contains javascript rendering code",content.contains("out.write( currentNode.text )"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testJstScriptTagA() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.jst","html.jst");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes JST marker",content.contains("JST template"));
+            assertTrue("Content contains scripted stuff (" + content + ")",
+                    content.contains("something scripted"));
+            assertFalse("Script opening tag must be broken in two in content (" + content + ")",
+                    content.contains("<script>something")); 
+            assertFalse("Script closing tag must be broken in two in content (" + content + ")",
+                    content.contains("scripted</script>")); 
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    /** TODO this test currently fails, see SLING-114 */
+    public void TODO_FAILS_testJstHtmlScriptTagB() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.jst","html.jst");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes JST marker",content.contains("JST template"));
+            assertTrue("Content contains scripted stuff (" + content + ")",
+                    content.contains("more scripting"));
+            assertFalse("Script opening tag must be broken in two in content (" + content + ")",
+                    content.contains("<script>more")); 
+            assertFalse("Script closing tag must be broken in two in content (" + content + ")",
+                    content.contains("scripting</script>")); 
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testEspHtmlUppercase() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","html.esp");
+        try {
+            final String content = getContent(displayUrl + ".HTML", CONTENT_TYPE_HTML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspNoExtension() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","GET.esp");
+        try {
+            final String content = getContent(displayUrl, CONTENT_TYPE_PLAIN);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    /** SLING-107, verify that extension is used instead of Content-Type for script name */
+    public void testEspJs() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","js.esp");
+        try {
+            final String content = getContent(displayUrl + ".js", CONTENT_TYPE_JS);
+            // template makes no JS sense, that's not a problem for this test
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspXml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","xml.esp");
+        try {
+            final String content = getContent(displayUrl + ".xml", CONTENT_TYPE_XML);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void testEspPlain() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.esp","txt.esp");
+        try {
+            final String content = getContent(displayUrl + ".txt", CONTENT_TYPE_PLAIN);
+            assertTrue("Content includes ESP marker",content.contains("ESP template"));
+            assertTrue("Content contains formatted test text",content.contains("<p>" + testText + "</p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testVltHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.vlt","html.vlt");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes VLT marker",content.contains("Velocity template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><b>" + testText + "</b></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testJsHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.js","html.js");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes JS marker",content.contains("Raw javascript template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><em>" + testText + "</em></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testFtlHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.ftl","html.ftl");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes FreeMarker marker",content.contains("FreeMarker template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><span>" + testText + "</span></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testErbHtml() throws IOException {
+        final String toDelete = uploadTestScript("rendering-test.erb","html.erb");
+        try {
+            final String content = getContent(displayUrl + ".html", CONTENT_TYPE_HTML);
+            assertTrue("Content includes Ruby marker",content.contains("Ruby template"));
+            assertTrue("Content contains formatted test text",content.contains("<p><span>" + testText + "</span></p>"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+}
\ No newline at end of file

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StaticContentTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StaticContentTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StaticContentTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StaticContentTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,48 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+
+/** Test static content served from the microsling webapp resources */
+public class StaticContentTest extends UslingHttpTestBase {
+    public void TODO_FAILS_testContentTypeHtml() throws IOException {
+        getContent(HTTP_BASE_URL + "/index.html", CONTENT_TYPE_HTML);
+    }
+    
+    public void TODO_FAILS_testContentTypeCss() throws IOException {
+        getContent(HTTP_BASE_URL + "/usling.css", CONTENT_TYPE_CSS);
+    }
+    
+    public void TODO_FAILS_testContentTypeJs() throws IOException {
+        getContent(HTTP_BASE_URL + "/ujax/ujax.js", CONTENT_TYPE_JS);
+    }
+    
+    public void testWebInfForbidden() throws IOException {
+        // if DefaultSlingServlet handled this we'd get an SC_FORBIDDEN, but it looks
+        // like the servlet container blocks it already
+        assertHttpStatus(HTTP_BASE_URL + "/WEB-INF/web.xml", HttpServletResponse.SC_NOT_FOUND);
+    }
+    
+    public void testMetaInfForbidden() throws IOException {
+        // if DefaultSlingServlet handled this we'd get an SC_FORBIDDEN, but it looks
+        // like the servlet container blocks it already
+        assertHttpStatus(HTTP_BASE_URL + "/META-INF/somefile.txt", HttpServletResponse.SC_NOT_FOUND);
+    }
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StreamServletTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StreamServletTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StreamServletTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/StreamServletTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,68 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+
+/** Test the StreamServlet by reading an uploaded file with a GET
+ */
+public class StreamServletTest extends RenderingTestBase {
+    
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        scriptPath = TEST_PATH + "/StreamServletTest." + System.currentTimeMillis();
+        displayUrl = HTTP_BASE_URL + scriptPath;
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+    }
+    
+    public void testNothing() {
+        // TODO remove this all TODO_FAILS_ are gone 
+    }
+
+    public void TODO_FAILS_testPlainTextFile() throws Exception {
+        final String filename = "testfile.txt";
+        final String toDelete = uploadTestScript(filename,filename);
+        try {
+            final String url = displayUrl + "/" + filename;
+            // TODO why don't we get a content-type here?
+            final String content = getContent(url, null);
+            assertTrue(
+                    "Content at " + url + " must include expected marker, got " + content,
+                    content.contains("This is just some text in an ASCII file.")
+            );
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+    public void TODO_FAILS_testHtmlTextFile() throws Exception {
+        final String filename = "testfile.html";
+        final String toDelete = uploadTestScript(filename,filename);
+        try {
+            // TODO this should really be text/html, not sure why it is not
+            final String url = displayUrl + "/" + filename;
+            // TODO why don't we get a content-type here?
+            final String content = getContent(url, null);
+            assertTrue(
+                    "Content at " + url + " must include expected marker, got " + content,
+                    content.contains("This is <em>testfile.html</em>.")
+            );
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+}

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

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

Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SyntheticResourceTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SyntheticResourceTest.java?rev=612830&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SyntheticResourceTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/SyntheticResourceTest.java Thu Jan 17 06:41:57 2008
@@ -0,0 +1,98 @@
+/*
+ * 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.usling.webapp.integrationtest;
+
+import java.io.IOException;
+
+import org.apache.sling.jcr.resource.SyntheticResource;
+
+/** Test the SLING-129 {@link SyntheticResources}, by requesting
+ *  non-existent Nodes that match the "configured" path
+ *  patterns of the  {@link SyntheticResourceProvider}.
+ */
+public class SyntheticResourceTest extends UslingHttpTestBase {
+
+    /** recurse random URLs under basePath, going nLevels deep,
+     *  and check that we get the specified status for every URL
+     * @throws IOException 
+     */ 
+    private void assertDeepGetStatus(String basePath, int nLevels, int expectedStatus, String urlSuffix) throws IOException {
+        String path = basePath;
+        for(int level=1; level <= nLevels; level++) {
+            final String url = HTTP_BASE_URL + path + urlSuffix; 
+            assertHttpStatus(url, expectedStatus,"Unexpected status at URL=" + url);
+            basePath += "/level_" + level + "_" + (int)(Math.random() * Integer.MAX_VALUE);
+        }
+    }
+    
+    public void TODO_FAILS_testSearchSyntheticResource() throws IOException {
+        // build a very random deep URL under /search and
+        // verify that we get a 200 every time
+        assertDeepGetStatus("/search",10,200,"");
+    }
+    
+    public void TODO_FAILS_testSearchSyntheticResourceHtml() throws IOException {
+        // build a very random deep URL under /search and
+        // verify that we get a 200 every time
+        assertDeepGetStatus("/search",10,200,".html");
+        assertDeepGetStatus("/search",10,200,".a4.print.html");
+    }
+    
+    public void TODO_FAILS_testSearchSyntheticResourceJson() throws IOException {
+        // build a very random deep URL under /search and
+        // verify that we get a 200 every time
+        assertDeepGetStatus("/search",10,200,".json");
+        assertDeepGetStatus("/search",10,200,".a4.print.json");
+    }
+    
+    public void TODO_FAILS_testSearchSyntheticResourceTxt() throws IOException {
+        // build a very random deep URL under /search and
+        // verify that we get a 200 every time
+        assertDeepGetStatus("/search",10,200,".txt");
+        assertDeepGetStatus("/search",10,200,".a4.print.txt");
+    }
+    
+    public void testNoSyntheticResourceTest() throws IOException {
+        // walk down a random path, verify that we 
+        // get 404s all the time
+        final String basePath = "/" + getClass().getSimpleName() + "_" + System.currentTimeMillis() + "/" + (int)(Math.random() * Integer.MAX_VALUE);
+        assertDeepGetStatus(basePath,10,404,"");
+    }
+    
+    public void TODO_FAILS_testSyntheticResourceWithJstTemplate() throws IOException {
+        final String synthResourceUrl = HTTP_BASE_URL + "/search/something.SyntheticResourceTest.html";
+        {
+            final String content = getContent(synthResourceUrl, CONTENT_TYPE_HTML);
+            assertFalse("Content must not include JST marker before test",content.contains("JST template"));
+        }
+        
+        //final String scriptPath = "/apps/" + SyntheticResource.DEFAULT_RESOURCE_TYPE + "/SyntheticResourceTest";
+        final String scriptPath = "TODO";
+        testClient.mkdirs(WEBDAV_BASE_URL, scriptPath);
+        final String toDelete = uploadTestScript(scriptPath,"rendering-test.jst","html.jst");
+        try {
+            final String content = getContent(synthResourceUrl, CONTENT_TYPE_HTML);
+            assertTrue("Content includes JST marker: " + content,content.contains("JST template"));
+        } finally {
+            testClient.delete(toDelete);
+        }
+    }
+
+
+}

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

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

Modified: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/UslingHttpTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/UslingHttpTestBase.java?rev=612830&r1=612829&r2=612830&view=diff
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/UslingHttpTestBase.java (original)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/UslingHttpTestBase.java Thu Jan 17 06:41:57 2008
@@ -39,6 +39,7 @@
 import org.apache.commons.httpclient.auth.AuthScope;
 import org.apache.commons.httpclient.methods.GetMethod;
 import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.sling.usling.webapp.integrationtest.helpers.HttpAnyMethod;
 import org.apache.sling.usling.webapp.integrationtest.helpers.UslingIntegrationTestClient;
 import org.mozilla.javascript.Context;
 import org.mozilla.javascript.ScriptableObject;
@@ -157,16 +158,20 @@
         
         // Also check that the WebDAV root is ready
         {
-            final GetMethod get = new GetMethod(WEBDAV_BASE_URL);
-            final int status = httpClient.executeMethod(get);
+            final HttpAnyMethod options = new HttpAnyMethod("OPTIONS",WEBDAV_BASE_URL);
+            final int status = httpClient.executeMethod(options);
             if(status!=200) {
-                throw new IOException("Expected status 200 but got " + status + " for URL=" + WEBDAV_BASE_URL);
+                throw new IOException("Expected status 200 but got " + status + " for OPTIONS at URL=" + WEBDAV_BASE_URL);
             }
             
-            final String expected = "jcr:system";
-            final String content = get.getResponseBodyAsString();
-            if(!content.contains(expected)) {
-                throw new IOException("Content does not contain '" + expected + "' (" + content + ") at URL=" + WEBDAV_BASE_URL);
+            // The Allow header tells us that we're talking to a WebDAV server
+            final Header h = options.getResponseHeader("Allow");
+            if(h == null) {
+                throw new IOException("Response does not contain Allow header, at URL=" + WEBDAV_BASE_URL);
+            } else if(h.getValue() == null) {
+                throw new IOException("Allow header has null value at URL=" + WEBDAV_BASE_URL);
+            } else if(!h.getValue().contains("PROPFIND")) {
+                throw new IOException("Allow header (" + h.getValue() + " does not contain PROPFIND, at URL=" + WEBDAV_BASE_URL);
             }
         }
         
@@ -179,7 +184,7 @@
     protected void assertHttpStatus(String urlString, int expectedStatusCode, String assertMessage) throws IOException {
         final int status = httpClient.executeMethod(new GetMethod(urlString));
         if(assertMessage == null) {
-            assertEquals(expectedStatusCode, status);
+            assertEquals(urlString,expectedStatusCode, status);
         } else {
             assertEquals(assertMessage, expectedStatusCode, status);
         }
@@ -222,6 +227,11 @@
             if(h!=null) {
                 fail("Expected null Content-Type, got " + h.getValue());
             }
+        } else if(h==null) {
+            fail(
+                    "Expected Content-Type that starts with '" + expectedContentType 
+                    +" but got no Content-Type header at " + url
+            );
         } else {
             assertTrue(
                 "Expected Content-Type that starts with '" + expectedContentType 
@@ -237,6 +247,9 @@
         final String url = WEBDAV_BASE_URL + scriptPath + "/" + filenameOnServer;
         final String testFile = "/integration-test/" + localFilename;
         final InputStream data = getClass().getResourceAsStream(testFile);
+        if(data==null) {
+            fail("Test file not found:" + testFile);
+        }
         try {
             testClient.upload(url, data);
         } finally {



Mime
View raw message