You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by bd...@apache.org on 2008/01/17 10:48:59 UTC
svn commit: r612776 - in /incubator/sling/trunk/usling/usling-webapp: ./
src/test/java/org/apache/sling/usling/webapp/integrationtest/
src/test/resources/ src/test/resources/integration-test/
Author: bdelacretaz
Date: Thu Jan 17 01:48:43 2008
New Revision: 612776
URL: http://svn.apache.org/viewvc?rev=612776&view=rev
Log:
SLING-149 - merge usling into Sling - Sling WebDAV server bundle and basic test added
Added:
incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/FileUploadTest.java (with props)
incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/RenderingTestBase.java (with props)
incubator/sling/trunk/usling/usling-webapp/src/test/resources/
incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/
incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/testfile.txt (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=612776&r1=612775&r2=612776&view=diff
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/pom.xml (original)
+++ incubator/sling/trunk/usling/usling-webapp/pom.xml Thu Jan 17 01:48:43 2008
@@ -200,7 +200,7 @@
</property>
<property>
<name>usling.webdav.server.url</name>
- <value>http://localhost:8080/repository/default</value>
+ <value>http://localhost:8080/dav/default</value>
</property>
</systemProperties>
</configuration>
@@ -256,7 +256,7 @@
</property>
<property>
<name>usling.webdav.server.url</name>
- <value>http://localhost:8080/${project.build.finalName}/repository/default</value>
+ <value>http://localhost:8080/${project.build.finalName}/dav/default</value>
</property>
</systemProperties>
</configuration>
@@ -459,6 +459,11 @@
<version>2.0.0-incubator-SNAPSHOT</version>
</dependency>
<dependency>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>org.apache.sling.jcr.webdav</artifactId>
+ <version>2.0.0-incubator-SNAPSHOT</version>
+ </dependency>
+ <dependency>
<groupId>org.apache.felix.commons</groupId>
<artifactId>org.apache.felix.commons.xml-apis</artifactId>
<version>1.3.4-0002-SNAPSHOT</version>
@@ -515,5 +520,11 @@
<version>2.0.2-0001-SNAPSHOT</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.felix.commons</groupId>
+ <artifactId>org.apache.felix.commons.commons-httpclient</artifactId>
+ <version>3.0.1-0001-SNAPSHOT</version>
+ </dependency>
+
</dependencies>
</project>
Added: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/FileUploadTest.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/FileUploadTest.java?rev=612776&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/FileUploadTest.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/FileUploadTest.java Thu Jan 17 01:48:43 2008
@@ -0,0 +1,52 @@
+/*
+ * 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.io.InputStream;
+
+/** Test uploading files to the Sling repository
+ * via WebDAV, as a first step towards testing the
+ * complete content creation and rendering scenario.
+ */
+public class FileUploadTest extends UslingHttpTestBase {
+
+ /** This only tests the WebDAV interface. We know it works, so
+ * we're mostly testing our test code here ;-)
+ */
+ public void testUploadAndDelete() throws IOException {
+ final String testFile = "/integration-test/testfile.txt";
+ final InputStream data = getClass().getResourceAsStream(testFile);
+ try {
+ assertNotNull("Local test file " + testFile + " must be found",data);
+
+ final String webdavUrl = WEBDAV_BASE_URL + "/FileUploadTest." + System.currentTimeMillis() + ".txt";
+
+ // Upload a file via WebDAV, verify, delete and verify
+ assertHttpStatus(webdavUrl, 404, "Resource " + webdavUrl + " must not exist before test");
+ int status = testClient.upload(webdavUrl, data);
+ assertEquals("upload must return status code 201",201,status);
+ assertHttpStatus(webdavUrl, 200, "Resource " + webdavUrl + " must exist after upload");
+ testClient.delete(webdavUrl);
+ assertHttpStatus(webdavUrl, 404, "Resource " + webdavUrl + " must not exist anymore after deleting");
+ } finally {
+ if(data!=null) {
+ data.close();
+ }
+ }
+ }
+}
Propchange: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/FileUploadTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/FileUploadTest.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/RenderingTestBase.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/RenderingTestBase.java?rev=612776&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/RenderingTestBase.java (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/RenderingTestBase.java Thu Jan 17 01:48:43 2008
@@ -0,0 +1,31 @@
+/*
+ * 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;
+
+/** Base class for rendering tests
+ */
+class RenderingTestBase extends UslingHttpTestBase {
+ protected String scriptPath;
+ protected String testText;
+ protected String displayUrl;
+
+ protected String uploadTestScript(String localFilename,String filenameOnServer) throws IOException {
+ return uploadTestScript(scriptPath, localFilename, filenameOnServer);
+ }
+}
\ No newline at end of file
Propchange: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/RenderingTestBase.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/trunk/usling/usling-webapp/src/test/java/org/apache/sling/usling/webapp/integrationtest/RenderingTestBase.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=612776&r1=612775&r2=612776&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 01:48:43 2008
@@ -134,24 +134,42 @@
final Map<String,String> props = new HashMap<String,String>();
props.put("time", time);
- // POST, get URL of created node and get content
- final String urlOfNewNode = testClient.createNode(url, props, null, true);
- final GetMethod get = new GetMethod(urlOfNewNode);
- final int status = httpClient.executeMethod(get);
- if(status!=200) {
- throw new IOException("Expected status 200 but got " + status + " for URL=" + urlOfNewNode);
+ // POST, get URL of created node and get content
+ {
+ final String urlOfNewNode = testClient.createNode(url, props, null, true);
+ final GetMethod get = new GetMethod(urlOfNewNode);
+ final int status = httpClient.executeMethod(get);
+ if(status!=200) {
+ throw new IOException("Expected status 200 but got " + status + " for URL=" + urlOfNewNode);
+ }
+
+ final Header h = get.getResponseHeader("Content-Type");
+ final String contentType = h==null ? "" : h.getValue();
+ if(!contentType.startsWith("text/plain")) {
+ throw new IOException("Expected Content-Type=text/plain but got '" + contentType + "' for URL=" + urlOfNewNode);
+ }
+
+ final String content = get.getResponseBodyAsString();
+ if(!content.contains(time)) {
+ throw new IOException("Content does not contain '" + time + "' (" + content + ") at URL=" + urlOfNewNode);
+ }
}
- final Header h = get.getResponseHeader("Content-Type");
- final String contentType = h==null ? "" : h.getValue();
- if(!contentType.startsWith("text/plain")) {
- throw new IOException("Expected Content-Type=text/plain but got '" + contentType + "' for URL=" + urlOfNewNode);
+ // Also check that the WebDAV root is ready
+ {
+ final GetMethod get = new GetMethod(WEBDAV_BASE_URL);
+ final int status = httpClient.executeMethod(get);
+ if(status!=200) {
+ throw new IOException("Expected status 200 but got " + status + " for 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);
+ }
}
- final String content = get.getResponseBodyAsString();
- if(!content.contains(time)) {
- throw new IOException("Content does not contain '" + time + "' (" + content + ")");
- }
return true;
}
Added: incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/testfile.txt
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/testfile.txt?rev=612776&view=auto
==============================================================================
--- incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/testfile.txt (added)
+++ incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/testfile.txt Thu Jan 17 01:48:43 2008
@@ -0,0 +1 @@
+This is just some text in an ASCII file.
\ No newline at end of file
Propchange: incubator/sling/trunk/usling/usling-webapp/src/test/resources/integration-test/testfile.txt
------------------------------------------------------------------------------
svn:eol-style = native