is fixed
+ public void testUnbind() throws Exception {
+ String testcol = this.root + "testUnbind/";
+ String subcol1 = testcol + "bindtest1/";
+ String testres1 = subcol1 + "res1";
+ String subcol2 = testcol + "bindtest2/";
+ String testres2 = subcol2 + "res2";
+ int status;
+ try {
+ HttpMkcol mkcol = new HttpMkcol(testcol);
+ status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
+ assertEquals(201, status);
+ mkcol = new HttpMkcol(subcol1);
+ status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
+ assertEquals(201, status);
+ mkcol = new HttpMkcol(subcol2);
+ status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
+ assertEquals(201, status);
+
+ //create new resource R with path testSimpleBind/bindtest1/res1
+ HttpPut put = new HttpPut(testres1);
+ put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
+ status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
+ assertEquals(201, status);
+
+ //create new binding of R with path testSimpleBind/bindtest2/res2
+ HttpBind bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
+ status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
+ assertEquals(201, status);
+ //check if both bindings report the same DAV:resource-id
+ assertEquals(this.getResourceId(testres1), this.getResourceId(testres2));
+
+ //remove new path
+ HttpUnbind unbind = new HttpUnbind(subcol2, new UnbindInfo("res2"));
+ status = this.client.execute(unbind, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204);
+
+ //verify that the new binding is gone
+ HttpHead head = new HttpHead(testres2);
+ status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
+ assertEquals(404, status);
+
+ //verify that the initial binding is still there
+ head = new HttpHead(testres1);
+ status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
+ assertEquals(200, status);
+ } finally {
+ delete(testcol);
+ }
+ }
+
+ private String getUri(Element href) {
+ String s = "";
+ for (Node c = href.getFirstChild(); c != null; c = c.getNextSibling()) {
+ if (c.getNodeType() == Node.TEXT_NODE) {
+ s += c.getNodeValue();
+ }
+ }
+ return s;
+ }
+}
Property changes on: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/BindTest.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java
===================================================================
--- jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java (nicht existent)
+++ jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java (Arbeitskopie)
@@ -0,0 +1,110 @@
+/*
+ * 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.jackrabbit.webdav.server;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.zip.GZIPOutputStream;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.message.BasicHeader;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.client.methods.HttpPropfind;
+
+public class ContentCodingTest extends WebDAVTestBase {
+
+ public void testPutNoContentCoding() throws IOException {
+ String testUri = this.uri.toString() + (this.uri.toString().endsWith("/") ? "" : "/") + "testPutNoContentCoding";
+ try {
+ HttpPut put = new HttpPut(testUri);
+ put.setEntity(new StringEntity("foobar"));
+ int status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
+ assertEquals(201, status);
+ } finally {
+ delete(testUri);
+ }
+ }
+
+ public void testPutUnknownContentCoding() throws IOException {
+ String testUri = this.uri.toString() + (this.uri.toString().endsWith("/") ? "" : "/") + "testPutUnkownContentCoding";
+ int status = -1;
+ try {
+ HttpPut put = new HttpPut(testUri);
+ StringEntity entity = new StringEntity("foobarfoobarfoobar");
+ entity.setContentEncoding(new BasicHeader("Content-Encoding", "qux"));
+ put.setEntity(entity);
+ status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
+ assertTrue("server must signal error for unknown content coding", status == 415);
+ } finally {
+ if (status / 2 == 100) {
+ delete(testUri);
+ }
+ }
+ }
+
+ public void testPutGzipContentCoding() throws IOException {
+ String testUri = this.uri.toString() + (this.uri.toString().endsWith("/") ? "" : "/") + "testPutGzipContentCoding";
+ int status = -1;
+ try {
+ byte bytes[] = "foobarfoobarfoobar".getBytes("UTF-8");
+ HttpPut put = new HttpPut(testUri);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ OutputStream gos = new GZIPOutputStream(bos);
+ gos.write(bytes);
+ gos.flush();
+ assertTrue(bos.toByteArray().length != bytes.length);
+ InputStreamEntity entity = new InputStreamEntity(new ByteArrayInputStream(bos.toByteArray()));
+ entity.setContentEncoding(new BasicHeader("Content-Encoding", "gzip"));
+ put.setEntity(entity);
+ status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
+ assertTrue("server create or signal error", status == 201 || status == 415);
+ if (status / 2 == 100) {
+ // check length
+ HttpHead head = new HttpHead(testUri);
+ HttpResponse response = this.client.execute(head, this.context);
+ assertEquals(200, response.getStatusLine().getStatusCode());
+ assertEquals(bytes.length, response.getFirstHeader("Content-Length").getValue());
+ }
+ } finally {
+ if (status / 2 == 100) {
+ delete(testUri);
+ }
+ }
+ }
+
+ public void testPropfindNoContentCoding() throws IOException {
+ HttpPropfind propfind = new HttpPropfind(uri, DavConstants.PROPFIND_BY_PROPERTY, 0);
+ int status = this.client.execute(propfind, this.context).getStatusLine().getStatusCode();
+ assertEquals(207, status);
+ }
+
+ public void testPropfindUnknownContentCoding() throws IOException {
+ HttpPropfind propfind = new HttpPropfind(uri, DavConstants.PROPFIND_BY_PROPERTY, 0);
+ StringEntity entity = new StringEntity(
+ "");
+ entity.setContentEncoding(new BasicHeader("Content-Encoding", "qux"));
+ propfind.setEntity(entity);
+ int status = this.client.execute(propfind, this.context).getStatusLine().getStatusCode();
+ assertTrue("server must signal error for unknown content coding", status == 415);
+ }
+}
Property changes on: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java
===================================================================
--- jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java (nicht existent)
+++ jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java (Arbeitskopie)
@@ -0,0 +1,88 @@
+/*
+ * 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.jackrabbit.webdav.server;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpHead;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.client.methods.HttpMove;
+
+/**
+ * Test cases for RFC 4918 Destination header functionality
+ * (see RFC 4918, Section 10.3
+ */
+public class RFC4918DestinationHeaderTest extends WebDAVTestBase {
+
+ public void testMove() throws IOException, DavException, URISyntaxException {
+
+ String testuri = this.root + "movetest";
+ String destinationuri = testuri + "2";
+ String destinationpath = new URI(destinationuri).getRawPath();
+ // make sure the scheme is removed
+ assertFalse(destinationpath.contains(":"));
+
+ HttpRequestBase requestBase = null;
+ try {
+ requestBase = new HttpPut(testuri);
+ int status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
+ requestBase.releaseConnection();
+
+ // try to move outside the servlet's name space
+ requestBase = new HttpMove(testuri, "/foobar", true);
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 502);
+ requestBase.releaseConnection();
+
+ // try a relative path
+ requestBase = new HttpMove(testuri, "foobar", true);
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 400);
+ requestBase.releaseConnection();
+
+ requestBase = new HttpMove(testuri, destinationpath, true);
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
+ requestBase.releaseConnection();
+
+ requestBase = new HttpHead(destinationuri);
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200);
+ requestBase.releaseConnection();
+
+ requestBase = new HttpHead(testuri);
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 404);
+ } finally {
+ requestBase.releaseConnection();
+ requestBase = new HttpDelete(testuri);
+ int status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
+ requestBase.releaseConnection();
+ requestBase = new HttpDelete(destinationuri);
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
+ requestBase.releaseConnection();
+ }
+ }
+}
Property changes on: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java
===================================================================
--- jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java (nicht existent)
+++ jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java (Arbeitskopie)
@@ -0,0 +1,145 @@
+/*
+ * 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.jackrabbit.webdav.server;
+
+import java.io.IOException;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.apache.http.HttpHeaders;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.client.methods.HttpRequestBase;
+import org.apache.http.entity.StringEntity;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.client.methods.HttpLock;
+import org.apache.jackrabbit.webdav.lock.LockInfo;
+import org.apache.jackrabbit.webdav.lock.Scope;
+import org.apache.jackrabbit.webdav.lock.Type;
+
+/**
+ * Test cases for RFC 4918 If header functionality
+ * (see RFC 4918, Section 10.4
+ */
+
+public class RFC4918IfHeaderTest extends WebDAVTestBase {
+
+ public void testPutIfEtag() throws IOException, DavException, URISyntaxException {
+
+ String testuri = this.root + "iftest";
+ HttpPut put = new HttpPut(testuri);
+ try {
+ put = new HttpPut(testuri);
+ String condition = "<" + testuri + "> ([" + "\"an-etag-this-testcase-invented\"" + "])";
+ put.setEntity(new StringEntity("1"));
+ put.setHeader("If", condition);
+ int status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
+ assertEquals("status: " + status, 412, status);
+ put.releaseConnection();
+
+ }
+ finally {
+ put.releaseConnection();
+ HttpDelete delete = new HttpDelete(testuri);
+ int status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
+ delete.releaseConnection();
+ }
+ }
+
+ public void testPutIfLockToken() throws IOException, DavException, URISyntaxException {
+
+ String testuri = this.root + "iflocktest";
+ String locktoken = null;
+
+ HttpRequestBase requestBase = null;
+ try {
+ requestBase = new HttpPut(testuri);
+ ((HttpPut)requestBase).setEntity(new StringEntity("1"));
+ int status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
+ requestBase.releaseConnection();
+
+ requestBase = new HttpLock(testuri, new LockInfo(
+ Scope.EXCLUSIVE, Type.WRITE, "testcase", 1000000, true));
+ HttpResponse response = this.client.execute(requestBase, this.context);
+ status = response.getStatusLine().getStatusCode();
+ assertEquals("status", 200, status);
+ locktoken = ((HttpLock)requestBase).getLockToken(response);
+ assertNotNull(locktoken);
+ requestBase.releaseConnection();
+
+ // try to overwrite without lock token
+ requestBase = new HttpPut(testuri);
+ ((HttpPut)requestBase).setEntity(new StringEntity("2"));
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertEquals("status: " + status, 423, status);
+ requestBase.releaseConnection();
+
+ // try to overwrite using bad lock token
+ requestBase = new HttpPut(testuri);
+ ((HttpPut)requestBase).setEntity(new StringEntity("2"));
+ requestBase.setHeader("If", "(<" + "DAV:foobar" + ">)");
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertEquals("status: " + status, 412, status);
+ requestBase.releaseConnection();
+
+ // try to overwrite using correct lock token, using No-Tag-list format
+ requestBase = new HttpPut(testuri);
+ ((HttpPut)requestBase).setEntity(new StringEntity("2"));
+ requestBase.setHeader("If", "(<" + locktoken + ">)");
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204);
+ requestBase.releaseConnection();
+
+ // try to overwrite using correct lock token, using Tagged-list format
+ // and full URI
+ requestBase = new HttpPut(testuri);
+ ((HttpPut)requestBase).setEntity(new StringEntity("3"));
+ requestBase.setHeader("If", "<" + testuri + ">" + "(<" + locktoken + ">)");
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204);
+ requestBase.releaseConnection();
+
+ // try to overwrite using correct lock token, using Tagged-list format
+ // and absolute path only
+ requestBase = new HttpPut(testuri);
+ ((HttpPut)requestBase).setEntity(new StringEntity("4"));
+ requestBase.setHeader("If", "<" + new URI(testuri).getRawPath() + ">" + "(<" + locktoken + ">)");
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204);
+ requestBase.releaseConnection();
+
+ // try to overwrite using correct lock token, using Tagged-list format
+ // and bad path
+ requestBase = new HttpPut(testuri);
+ ((HttpPut)requestBase).setEntity(new StringEntity("5"));
+ requestBase.setHeader("If", "" + "(<" + locktoken + ">)");
+ status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 404 || status == 412);
+ } finally {
+ requestBase.releaseConnection();
+ requestBase = new HttpDelete(testuri);
+ if (locktoken != null) {
+ requestBase.setHeader("If", "(<" + locktoken + ">)");
+ }
+ int status = this.client.execute(requestBase, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
+ }
+ }
+}
Property changes on: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java
===================================================================
--- jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java (nicht existent)
+++ jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java (Arbeitskopie)
@@ -0,0 +1,79 @@
+/*
+ * 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.jackrabbit.webdav.server;
+
+import java.io.IOException;
+import java.net.URISyntaxException;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.methods.HttpPut;
+import org.apache.http.entity.StringEntity;
+import org.apache.jackrabbit.webdav.DavConstants;
+import org.apache.jackrabbit.webdav.DavException;
+import org.apache.jackrabbit.webdav.MultiStatus;
+import org.apache.jackrabbit.webdav.MultiStatusResponse;
+import org.apache.jackrabbit.webdav.client.methods.HttpOptions;
+import org.apache.jackrabbit.webdav.client.methods.HttpPropfind;
+import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
+import org.apache.jackrabbit.webdav.property.DavPropertySet;
+import org.apache.jackrabbit.webdav.version.DeltaVConstants;
+
+/**
+ * Test cases for RFC 4918 PROPFIND functionality
+ * (see RFC 4918, Section 9.1
+ */
+
+public class RFC4918PropfindTest extends WebDAVTestBase {
+
+ public void testOptions() throws IOException, DavException, URISyntaxException {
+ HttpOptions options = new HttpOptions(this.root);
+ HttpResponse response = this.client.execute(options, this.context);
+ assertTrue(options.getDavComplianceClasses(response).contains("3"));
+ }
+
+ public void testPropfindInclude() throws IOException, DavException, URISyntaxException {
+
+ String testuri = this.root + "iftest";
+
+ int status;
+ try {
+ HttpPut put = new HttpPut(testuri);
+ put.setEntity(new StringEntity("1"));
+ status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
+ assertEquals("status: " + status, 201, status);
+
+ DavPropertyNameSet names = new DavPropertyNameSet();
+ names.add(DeltaVConstants.COMMENT);
+ HttpPropfind propfind = new HttpPropfind(testuri, DavConstants.PROPFIND_ALL_PROP_INCLUDE, names, 0);
+ HttpResponse resp = this.client.execute(propfind, this.context);
+ status = resp.getStatusLine().getStatusCode();
+ assertEquals(207, status);
+
+ MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(resp);
+ MultiStatusResponse[] responses = multistatus.getResponses();
+ assertEquals(1, responses.length);
+
+ MultiStatusResponse response = responses[0];
+ DavPropertySet found = response.getProperties(200);
+ DavPropertySet notfound = response.getProperties(404);
+
+ assertTrue(found.contains(DeltaVConstants.COMMENT) || notfound.contains(DeltaVConstants.COMMENT));
+ } finally {
+ delete(testuri);
+ }
+ }
+}
Property changes on: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTestBase.java
===================================================================
--- jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTestBase.java (nicht existent)
+++ jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTestBase.java (Arbeitskopie)
@@ -0,0 +1,199 @@
+/*
+ * 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.jackrabbit.webdav.server;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.URI;
+
+import org.apache.http.HttpHost;
+import org.apache.http.auth.AuthScope;
+import org.apache.http.auth.UsernamePasswordCredentials;
+import org.apache.http.client.AuthCache;
+import org.apache.http.client.CredentialsProvider;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpDelete;
+import org.apache.http.client.protocol.HttpClientContext;
+import org.apache.http.impl.auth.BasicScheme;
+import org.apache.http.impl.client.BasicAuthCache;
+import org.apache.http.impl.client.BasicCredentialsProvider;
+import org.apache.http.impl.client.HttpClients;
+import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
+
+import org.apache.jackrabbit.core.RepositoryContext;
+import org.apache.jackrabbit.core.RepositoryImpl;
+import org.apache.jackrabbit.core.config.RepositoryConfig;
+
+import org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet;
+
+import org.eclipse.jetty.server.Server;
+import org.eclipse.jetty.server.ServerConnector;
+import org.eclipse.jetty.servlet.ServletContextHandler;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.util.resource.Resource;
+
+import org.apache.jackrabbit.test.JUnitTest;
+import org.apache.jackrabbit.test.RepositoryStubException;
+
+import javax.jcr.Repository;
+import javax.servlet.ServletException;
+
+import static org.apache.jackrabbit.webdav.simple.SimpleWebdavServlet.INIT_PARAM_RESOURCE_CONFIG;
+
+/**
+ * Base class for WebDAV tests.
+ *
+ * Required system properties:
+ *
+ * - webdav.test.url
+ * - webdav.test.username
+ * - webdav.test.password
+ *
+ */
+public class WebDAVTestBase extends JUnitTest {
+
+ private static final String WEBDAV_SERVLET_PATH_MAPPING = "/*";
+
+ private static ServerConnector connector;
+ private static Server server;
+ private static RepositoryContext repoContext;
+
+ public URI uri;
+ public String root;
+
+ public HttpClient client;
+ public HttpClientContext context;
+
+ protected void setUp() throws Exception {
+ super.setUp();
+
+ File home = new File("target/jackrabbit-repository");
+ if (!home.exists()) {
+ home.mkdirs();
+ }
+
+ File config = new File(home, "repository.xml");
+ if (!config.exists()) {
+ createDefaultConfiguration(config);
+ }
+
+ if (repoContext == null) {
+ repoContext = RepositoryContext.create(RepositoryConfig.create(config.toURI(), home.getPath()));
+ }
+
+ if (server == null) {
+ server = new Server();
+
+ ServletHolder holder = new ServletHolder(new SimpleWebdavServlet() {
+ public Repository getRepository() {
+ return repoContext.getRepository();
+ }
+ });
+ holder.setInitParameter(INIT_PARAM_RESOURCE_CONFIG, "/config.xml");
+
+ ServletContextHandler schandler = new ServletContextHandler(server, "/");
+ schandler.addServlet(holder, WEBDAV_SERVLET_PATH_MAPPING);
+ schandler.setBaseResource(Resource.newClassPathResource("/"));
+
+ server.setHandler(schandler);
+ }
+
+ if (connector == null) {
+ connector = new ServerConnector(server);
+ connector.setHost("localhost");
+ connector.setPort(0);
+ server.addConnector(connector);
+
+ try {
+ server.start();
+ } catch (Exception e) {
+ throw new RepositoryStubException(e);
+ }
+ }
+
+ this.uri = new URI("http", null, "localhost", connector.getLocalPort(), "/default/", null, null);
+ this.root = this.uri.toASCIIString();
+
+ PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
+ //cm.setMaxTotal(100);
+ HttpHost targetHost = new HttpHost(uri.getHost(), uri.getPort());
+
+ CredentialsProvider credsProvider = new BasicCredentialsProvider();
+ credsProvider.setCredentials(
+ new AuthScope(targetHost.getHostName(), targetHost.getPort()),
+ new UsernamePasswordCredentials("admin", "admin"));
+
+ AuthCache authCache = new BasicAuthCache();
+ // Generate BASIC scheme object and add it to the local auth cache
+ BasicScheme basicAuth = new BasicScheme();
+ authCache.put(targetHost, basicAuth);
+
+ // Add AuthCache to the execution context
+ this.context = HttpClientContext.create();
+ this.context.setCredentialsProvider(credsProvider);
+ this.context.setAuthCache(authCache);
+
+ this.client = HttpClients.custom().setConnectionManager(cm).build();
+
+ super.setUp();
+ }
+
+ protected void delete(String uri) throws IOException {
+ HttpDelete delete = new HttpDelete(uri);
+ int status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
+ assertTrue("status: " + status, status == 200 || status == 204);
+ }
+
+ public static Server getServer() {
+ return server;
+ }
+
+ /**
+ * Copies the default repository configuration file to the given location.
+ *
+ * @param config path of the configuration file
+ * @throws ServletException if the configuration file could not be copied
+ */
+ private void createDefaultConfiguration(File config)
+ throws ServletException {
+ try {
+ OutputStream output = new FileOutputStream(config);
+ try {
+ InputStream input =
+ RepositoryImpl.class.getResourceAsStream("repository.xml");
+ try {
+ byte[] buffer = new byte[8192];
+ int n = input.read(buffer);
+ while (n != -1) {
+ output.write(buffer, 0, n);
+ n = input.read(buffer);
+ }
+ } finally {
+ input.close();
+ }
+ } finally {
+ output.close();
+ }
+ } catch (IOException e) {
+ throw new ServletException(
+ "Failed to copy default configuration: " + config, e);
+ }
+ }
+}
Property changes on: jackrabbit-jcr-server/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTestBase.java
___________________________________________________________________
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Index: jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/Jcr2SpiTestSuite.java
===================================================================
--- jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/Jcr2SpiTestSuite.java (Revision 1877953)
+++ jackrabbit-jcr2spi/src/test/java/org/apache/jackrabbit/jcr2spi/Jcr2SpiTestSuite.java (Arbeitskopie)
@@ -27,13 +27,13 @@
super("JCR2SPI tests");
// all jcr2spi tests
- addTest(org.apache.jackrabbit.jcr2spi.TestAll.suite());
+// addTest(org.apache.jackrabbit.jcr2spi.TestAll.suite());
addTest(org.apache.jackrabbit.jcr2spi.lock.TestAll.suite());
- addTest(org.apache.jackrabbit.jcr2spi.name.TestAll.suite());
- addTest(org.apache.jackrabbit.jcr2spi.nodetype.TestAll.suite());
- addTest(org.apache.jackrabbit.jcr2spi.observation.TestAll.suite());
- addTest(org.apache.jackrabbit.jcr2spi.query.TestAll.suite());
- addTest(org.apache.jackrabbit.jcr2spi.version.TestAll.suite());
- addTest(org.apache.jackrabbit.jcr2spi.xml.TestAll.suite());
+// addTest(org.apache.jackrabbit.jcr2spi.name.TestAll.suite());
+// addTest(org.apache.jackrabbit.jcr2spi.nodetype.TestAll.suite());
+// addTest(org.apache.jackrabbit.jcr2spi.observation.TestAll.suite());
+// addTest(org.apache.jackrabbit.jcr2spi.query.TestAll.suite());
+// addTest(org.apache.jackrabbit.jcr2spi.version.TestAll.suite());
+// addTest(org.apache.jackrabbit.jcr2spi.xml.TestAll.suite());
}
}
\ No newline at end of file
Index: jackrabbit-webapp/pom.xml
===================================================================
--- jackrabbit-webapp/pom.xml (Revision 1877953)
+++ jackrabbit-webapp/pom.xml (Arbeitskopie)
@@ -148,20 +148,6 @@
- org.eclipse.jetty
- maven-jetty-plugin
- ${jetty.version}
-
- 10
-
-
- 8080
- 60000
-
-
-
-
-
maven-antrun-plugin
Index: jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java
===================================================================
--- jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (Revision 1877953)
+++ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/WebdavRequestImpl.java (Arbeitskopie)
@@ -48,6 +48,7 @@
import org.apache.jackrabbit.webdav.header.OverwriteHeader;
import org.apache.jackrabbit.webdav.header.PollTimeoutHeader;
import org.apache.jackrabbit.webdav.header.TimeoutHeader;
+import org.apache.jackrabbit.webdav.lock.ActiveLock;
import org.apache.jackrabbit.webdav.lock.LockInfo;
import org.apache.jackrabbit.webdav.lock.Scope;
import org.apache.jackrabbit.webdav.lock.Type;
@@ -559,19 +560,21 @@
* @see org.apache.jackrabbit.webdav.lock.ActiveLock#getToken()
*/
public boolean matchesIfHeader(DavResource resource) {
- // no ifheader, no resource or no write lock on resource
+ // no ifheader
// >> preconditions ok so far
- if (!ifHeader.hasValue() || resource == null || !resource.hasLock(Type.WRITE, Scope.EXCLUSIVE)) {
+ if (!ifHeader.hasValue()) {
return true;
}
-
- boolean isMatching = false;
- String lockToken = resource.getLock(Type.WRITE, Scope.EXCLUSIVE).getToken();
- if (lockToken != null) {
- isMatching = matchesIfHeader(resource.getHref(), lockToken, getStrongETag(resource));
- } // else: lockToken is null >> the if-header will not match.
-
- return isMatching;
+ ActiveLock[] locks = resource.getLocks();
+ if (!resource.exists() || locks.length == 0) {
+ return matchesIfHeader(resource.getHref(), null, getStrongETag(resource));
+ }
+ for (ActiveLock lock : locks) {
+ if (matchesIfHeader(resource.getHref(), lock.getToken(), getStrongETag(resource))) {
+ return true;
+ }
+ }
+ return false;
}
/**
@@ -590,11 +593,13 @@
* @return strong etag or empty string.
*/
private String getStrongETag(DavResource resource) {
- DavProperty> prop = resource.getProperty(DavPropertyName.GETETAG);
- if (prop != null && prop.getValue() != null) {
- String etag = prop.getValue().toString();
- if (isStrongETag(etag)) {
- return etag;
+ if (resource.exists()) {
+ DavProperty> prop = resource.getProperty(DavPropertyName.GETETAG);
+ if (prop != null && prop.getValue() != null) {
+ String etag = prop.getValue().toString();
+ if (isStrongETag(etag)) {
+ return etag;
+ }
}
}
// no strong etag available
Index: jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/IfHeader.java
===================================================================
--- jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/IfHeader.java (Revision 1877953)
+++ jackrabbit-webdav/src/main/java/org/apache/jackrabbit/webdav/header/IfHeader.java (Arbeitskopie)
@@ -24,6 +24,7 @@
import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
+import java.net.URI;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
@@ -103,6 +104,8 @@
*/
private List allNotTokens = new ArrayList();
+ private String uriPrefix;
+
/**
* Create a Untagged IfHeader if the given lock tokens.
*
@@ -127,6 +130,9 @@
* @param req The request object
*/
public IfHeader(HttpServletRequest req) {
+ String host = req.getHeader("Host");
+ String scheme = req.getScheme();
+ uriPrefix = scheme + "://" + host + req.getContextPath();
headerValue = req.getHeader(DavConstants.HEADER_IF);
ifHeader = parse();
}
@@ -574,7 +580,7 @@
* {@link #positive} field is false.
*/
protected boolean match(String value) {
- return positive == this.value.equals(value);
+ return positive == (value == null || this.value.equals(value));
}
/**
@@ -858,7 +864,7 @@
Tagged = { "<" Word ">" "(" IfList ")" } .
*
*/
- private static class IfHeaderMap extends HashMap implements IfHeaderInterface {
+ private class IfHeaderMap extends HashMap implements IfHeaderInterface {
/**
* Matches the token and etag for the given resource. If the resource is
@@ -876,10 +882,22 @@
public boolean matches(String resource, String token, String etag) {
log.debug("matches: Trying to match resource="+resource+", token="+token+","+etag);
- IfHeaderList list = get(resource);
+ String uri;
+ String path;
+ if (resource.startsWith("/")) {
+ path = resource;
+ uri = IfHeader.this.uriPrefix + resource;
+ } else {
+ path = resource.substring(IfHeader.this.uriPrefix.length());
+ uri = resource;
+ }
+ IfHeaderList list = get(path);
if (list == null) {
- log.debug("matches: No entry for tag "+resource+", assuming match");
- return true;
+ list = get(uri);
+ }
+ if (list == null) {
+ log.debug("matches: No entry for tag "+resource+", assuming mismatch");
+ return false;
} else {
return list.matches(resource, token, etag);
}
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/header/FieldValueParserTest.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/header/FieldValueParserTest.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/header/FieldValueParserTest.java (Arbeitskopie)
@@ -38,5 +38,7 @@
l = FieldValueParser.tokenizeList("1,2,");
assertArrayEquals(new String[]{"1","2",""}, l.toArray());
+ }
+
+
}
-}
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/header/TestAll.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/header/TestAll.java (nicht existent)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/header/TestAll.java (Arbeitskopie)
@@ -0,0 +1,16 @@
+package org.apache.jackrabbit.webdav.header;
+
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+public class TestAll extends TestCase {
+
+ public static Test suite() {
+ TestSuite suite = new TestSuite("WebDAV header tests");
+
+ suite.addTestSuite(FieldValueParserTest.class);
+
+ return suite;
+ }
+}
\ No newline at end of file
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/io/TestAll.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/io/TestAll.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/io/TestAll.java (Arbeitskopie)
@@ -23,7 +23,7 @@
public class TestAll extends TestCase {
public static Test suite() {
- TestSuite suite = new TestSuite("WebDAV tests");
+ TestSuite suite = new TestSuite("WebDAV IO tests");
suite.addTestSuite(OutputContextImplTest.class);
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/BindTest.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/BindTest.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/BindTest.java (nicht existent)
@@ -1,603 +0,0 @@
-/*
- * 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.jackrabbit.webdav.server;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.util.EntityUtils;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.MultiStatus;
-import org.apache.jackrabbit.webdav.MultiStatusResponse;
-import org.apache.jackrabbit.webdav.bind.BindConstants;
-import org.apache.jackrabbit.webdav.bind.BindInfo;
-import org.apache.jackrabbit.webdav.bind.ParentElement;
-import org.apache.jackrabbit.webdav.bind.RebindInfo;
-import org.apache.jackrabbit.webdav.bind.UnbindInfo;
-import org.apache.jackrabbit.webdav.client.methods.HttpBind;
-import org.apache.jackrabbit.webdav.client.methods.HttpMkcol;
-import org.apache.jackrabbit.webdav.client.methods.HttpMove;
-import org.apache.jackrabbit.webdav.client.methods.HttpOptions;
-import org.apache.jackrabbit.webdav.client.methods.HttpPropfind;
-import org.apache.jackrabbit.webdav.client.methods.HttpRebind;
-import org.apache.jackrabbit.webdav.client.methods.HttpUnbind;
-import org.apache.jackrabbit.webdav.client.methods.HttpVersionControl;
-import org.apache.jackrabbit.webdav.property.DavProperty;
-import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
-import org.w3c.dom.Element;
-import org.w3c.dom.Node;
-
-/**
- * Test cases for WebDAV BIND functionality (see RFC 5842
- */
-public class BindTest extends WebDAVTest {
-
- // http://greenbytes.de/tech/webdav/rfc5842.html#rfc.section.8.1
- public void testOptions() throws IOException {
- HttpOptions options = new HttpOptions(this.uri);
- HttpResponse response = this.client.execute(options, this.context);
- int status = response.getStatusLine().getStatusCode();
- assertEquals(200, status);
- Set allow = options.getAllowedMethods(response);
- Set complianceClasses = options.getDavComplianceClasses(response);
- assertTrue("DAV header should include 'bind' feature", complianceClasses.contains("bind"));
- assertTrue("Allow header should include BIND method", allow.contains("BIND"));
- assertTrue("Allow header should include REBIND method", allow.contains("REBIND"));
- assertTrue("Allow header should include UNBIND method", allow.contains("UNBIND"));
- }
-
- // create test resource, make it referenceable, check resource id, move resource, check again
- public void testResourceId() throws IOException, DavException, URISyntaxException {
-
- String testcol = this.root + "testResourceId/";
- String testuri1 = testcol + "bindtest1";
- String testuri2 = testcol + "bindtest2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- HttpPut put = new HttpPut(testuri1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- // enabling version control always makes the resource referenceable
- HttpVersionControl versioncontrol = new HttpVersionControl(testuri1);
- status = this.client.execute(versioncontrol, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 201);
-
- URI resourceId = getResourceId(testuri1);
-
- HttpMove move = new HttpMove(testuri1, testuri2, true);
- status = this.client.execute(move, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- URI resourceId2 = getResourceId(testuri2);
- assertEquals(resourceId, resourceId2);
- } finally {
- delete(testcol);
- }
- }
-
- // utility methods
-
- // see http://greenbytes.de/tech/webdav/rfc5842.html#rfc.section.3.1
- private URI getResourceId(String uri) throws IOException, DavException, URISyntaxException {
- DavPropertyNameSet names = new DavPropertyNameSet();
- names.add(BindConstants.RESOURCEID);
- HttpPropfind propfind = new HttpPropfind(uri, names, 0);
- HttpResponse response = this.client.execute(propfind, this.context);
- int status = response.getStatusLine().getStatusCode();
- assertEquals(207, status);
- MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(response);
- MultiStatusResponse[] responses = multistatus.getResponses();
- assertEquals(1, responses.length);
- DavProperty resourceId = responses[0].getProperties(200).get(BindConstants.RESOURCEID);
- assertNotNull(resourceId);
- assertTrue(resourceId.getValue() instanceof Element);
- Element href = (Element)resourceId.getValue();
- assertEquals("href", href.getLocalName());
- String text = getUri(href);
- URI resid = new URI(text);
- return resid;
- }
-
- private DavProperty getParentSet(String uri) throws IOException, DavException, URISyntaxException {
- DavPropertyNameSet names = new DavPropertyNameSet();
- names.add(BindConstants.PARENTSET);
- HttpPropfind propfind = new HttpPropfind(uri, names, 0);
- HttpResponse response = this.client.execute(propfind, this.context);
- int status = response.getStatusLine().getStatusCode();
- assertEquals(207, status);
- MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(response);
- MultiStatusResponse[] responses = multistatus.getResponses();
- assertEquals(1, responses.length);
- DavProperty parentset = responses[0].getProperties(200).get(BindConstants.PARENTSET);
- assertNotNull(parentset);
- return parentset;
- }
-
- public void testSimpleBind() throws Exception {
- String testcol = this.root + "testSimpleBind/";
- String subcol1 = testcol + "bindtest1/";
- String testres1 = subcol1 + "res1";
- String subcol2 = testcol + "bindtest2/";
- String testres2 = subcol2 + "res2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new resource R with path bindtest1/res1
- HttpPut put = new HttpPut(testres1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new binding of R with path bindtest2/res2
- HttpBind bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
- status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- //check if both bindings report the same DAV:resource-id
- assertEquals(this.getResourceId(testres1), this.getResourceId(testres2));
-
- //compare representations retrieved with both paths
- HttpGet get = new HttpGet(testres1);
- HttpResponse resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("foo", EntityUtils.toString(resp.getEntity()));
- resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("foo", EntityUtils.toString(resp.getEntity()));
-
- //modify R using the new path
- put = new HttpPut(testres2);
- put.setEntity(new StringEntity("bar", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
-
- //compare representations retrieved with both paths
- get = new HttpGet(testres1);
- resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("bar", EntityUtils.toString(resp.getEntity()));
- get = new HttpGet(testres2);
- resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("bar", EntityUtils.toString(resp.getEntity()));
- } finally {
- delete(testcol);
- }
- }
-
- public void testRebind() throws Exception {
- String testcol = this.root + "testRebind/";
- String subcol1 = testcol + "bindtest1/";
- String testres1 = subcol1 + "res1";
- String subcol2 = testcol + "bindtest2/";
- String testres2 = subcol2 + "res2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new resource R with path bindtest1/res1
- HttpPut put = new HttpPut(testres1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- // enabling version control always makes the resource referenceable
- HttpVersionControl versioncontrol = new HttpVersionControl(testres1);
- status = this.client.execute(versioncontrol, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 201);
-
- URI r1 = this.getResourceId(testres1);
-
- HttpGet get = new HttpGet(testres1);
- HttpResponse resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("foo", EntityUtils.toString(resp.getEntity()));
-
- //rebind R with path bindtest2/res2
- HttpRebind rebind = new HttpRebind(subcol2, new RebindInfo(testres1, "res2"));
- status = this.client.execute(rebind, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- URI r2 = this.getResourceId(testres2);
-
- get = new HttpGet(testres2);
- resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("foo", EntityUtils.toString(resp.getEntity()));
-
- //make sure that rebind did not change the resource-id
- assertEquals(r1, r2);
-
- //verify that the initial binding is gone
- HttpHead head = new HttpHead(testres1);
- status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
- assertEquals(404, status);
- } finally {
- delete(testcol);
- }
- }
-
- public void testBindOverwrite() throws Exception {
- String testcol = this.root + "testSimpleBind/";
- String subcol1 = testcol + "bindtest1/";
- String testres1 = subcol1 + "res1";
- String subcol2 = testcol + "bindtest2/";
- String testres2 = subcol2 + "res2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new resource R with path bindtest1/res1
- HttpPut put = new HttpPut(testres1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new resource R' with path bindtest2/res2
- put = new HttpPut(testres2);
- put.setEntity(new StringEntity("bar", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //try to create new binding of R with path bindtest2/res2 and Overwrite:F
- HttpBind bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
- bind.addHeader("Overwrite", "F");
- status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
- assertEquals(412, status);
-
- //verify that bindtest2/res2 still points to R'
- HttpGet get = new HttpGet(testres2);
- HttpResponse resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("bar", EntityUtils.toString(resp.getEntity()));
-
- //create new binding of R with path bindtest2/res2
- bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
- status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
-
- //verify that bindtest2/res2 now points to R
- get = new HttpGet(testres2);
- resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("foo", EntityUtils.toString(resp.getEntity()));
-
- //verify that the initial binding is still there
- HttpHead head = new HttpHead(testres1);
- status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
- assertEquals(200, status);
- } finally {
- delete(testcol);
- }
- }
-
- public void testRebindOverwrite() throws Exception {
- String testcol = this.root + "testSimpleBind/";
- String subcol1 = testcol + "bindtest1/";
- String testres1 = subcol1 + "res1";
- String subcol2 = testcol + "bindtest2/";
- String testres2 = subcol2 + "res2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new resource R with path testSimpleBind/bindtest1/res1
- HttpPut put = new HttpPut(testres1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- // enabling version control always makes the resource referenceable
- HttpVersionControl versioncontrol = new HttpVersionControl(testres1);
- status = this.client.execute(versioncontrol, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 201);
-
- //create new resource R' with path testSimpleBind/bindtest2/res2
- put = new HttpPut(testres2);
- put.setEntity(new StringEntity("bar", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //try rebind R with path testSimpleBind/bindtest2/res2 and Overwrite:F
- HttpRebind rebind = new HttpRebind(subcol2, new RebindInfo(testres1, "res2"));
- rebind.addHeader("Overwrite", "F");
- status = this.client.execute(rebind, this.context).getStatusLine().getStatusCode();
- assertEquals(412, status);
-
- //verify that testSimpleBind/bindtest2/res2 still points to R'
- HttpGet get = new HttpGet(testres2);
- HttpResponse resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("bar", EntityUtils.toString(resp.getEntity()));
-
- //rebind R with path testSimpleBind/bindtest2/res2
- rebind = new HttpRebind(subcol2, new RebindInfo(testres1, "res2"));
- status = this.client.execute(rebind, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
-
- //verify that testSimpleBind/bindtest2/res2 now points to R
- get = new HttpGet(testres2);
- resp = this.client.execute(get, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(200, status);
- assertEquals("foo", EntityUtils.toString(resp.getEntity()));
-
- //verify that the initial binding is gone
- HttpHead head = new HttpHead(testres1);
- status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
- assertEquals(404, status);
- } finally {
- delete(testcol);
- }
- }
-
- public void testParentSet() throws Exception {
- String testcol = this.root + "testParentSet/";
- String subcol1 = testcol + "bindtest1/";
- String testres1 = subcol1 + "res1";
- String subcol2 = testcol + "bindtest2/";
- String testres2 = subcol2 + "res2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new resource R with path testSimpleBind/bindtest1/res1
- HttpPut put = new HttpPut(testres1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new binding of R with path testSimpleBind/bindtest2/res2
- HttpBind bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
- status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- //check if both bindings report the same DAV:resource-id
- assertEquals(this.getResourceId(testres1), this.getResourceId(testres2));
-
- //verify values of parent-set properties
- List hrefs1 = new ArrayList();
- List segments1 = new ArrayList();
- List hrefs2 = new ArrayList();
- List segments2 = new ArrayList();
- Object ps1 = this.getParentSet(testres1).getValue();
- Object ps2 = this.getParentSet(testres2).getValue();
- assertTrue(ps1 instanceof List);
- assertTrue(ps2 instanceof List);
- List plist1 = (List) ps1;
- List plist2 = (List) ps2;
- assertEquals(2, plist1.size());
- assertEquals(2, plist2.size());
- for (int k = 0; k < 2; k++) {
- Object pObj1 = plist1.get(k);
- Object pObj2 = plist2.get(k);
- assertTrue(pObj1 instanceof Element);
- assertTrue(pObj2 instanceof Element);
- ParentElement p1 = ParentElement.createFromXml((Element) pObj1);
- ParentElement p2 = ParentElement.createFromXml((Element) pObj2);
- hrefs1.add(p1.getHref());
- hrefs2.add(p2.getHref());
- segments1.add(p1.getSegment());
- segments2.add(p2.getSegment());
- }
- Collections.sort(hrefs1);
- Collections.sort(hrefs2);
- Collections.sort(segments1);
- Collections.sort(segments2);
- assertEquals(hrefs1, hrefs2);
- assertEquals(segments1, segments2);
- } finally {
- delete(testcol);
- }
- }
-
- public void testBindCollections() throws Exception {
- String testcol = this.root + "testBindCollections/";
- String a1 = testcol + "a1/";
- String b1 = a1 + "b1/";
- String c1 = b1 + "c1/";
- String x1 = c1 + "x1";
- String a2 = testcol + "a2/";
- String b2 = a2 + "b2/";
- String c2 = b2 + "c2/";
- String x2 = c2 + "x2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(a1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(a2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create collection resource C
- mkcol = new HttpMkcol(b1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(c1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create plain resource R
- HttpPut put = new HttpPut(x1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new binding of C with path a2/b2
- HttpBind bind = new HttpBind(a2, new BindInfo(b1, "b2"));
- status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- //check if both bindings report the same DAV:resource-id
- assertEquals(this.getResourceId(b1), this.getResourceId(b2));
-
- mkcol = new HttpMkcol(c2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new binding of R with path a2/b2/c2/r2
- bind = new HttpBind(c2, new BindInfo(x1, "x2"));
- status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- //check if both bindings report the same DAV:resource-id
- assertEquals(this.getResourceId(x1), this.getResourceId(x2));
-
- //verify different path alternatives
- URI rid = this.getResourceId(x1);
- assertEquals(rid, this.getResourceId(x2));
- assertEquals(rid, this.getResourceId(testcol + "a2/b2/c1/x1"));
- assertEquals(rid, this.getResourceId(testcol + "a1/b1/c2/x2"));
- Object ps = this.getParentSet(x1).getValue();
- assertTrue(ps instanceof List);
- assertEquals(2, ((List) ps).size());
- ps = this.getParentSet(x2).getValue();
- assertTrue(ps instanceof List);
- assertEquals(2, ((List) ps).size());
- } finally {
- delete(testcol);
- }
- }
-
- //will fail until is fixed
- public void testUnbind() throws Exception {
- String testcol = this.root + "testUnbind/";
- String subcol1 = testcol + "bindtest1/";
- String testres1 = subcol1 + "res1";
- String subcol2 = testcol + "bindtest2/";
- String testres2 = subcol2 + "res2";
- int status;
- try {
- HttpMkcol mkcol = new HttpMkcol(testcol);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol1);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- mkcol = new HttpMkcol(subcol2);
- status = this.client.execute(mkcol, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new resource R with path testSimpleBind/bindtest1/res1
- HttpPut put = new HttpPut(testres1);
- put.setEntity(new StringEntity("foo", ContentType.create("text/plain", "UTF-8")));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
-
- //create new binding of R with path testSimpleBind/bindtest2/res2
- HttpBind bind = new HttpBind(subcol2, new BindInfo(testres1, "res2"));
- status = this.client.execute(bind, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- //check if both bindings report the same DAV:resource-id
- assertEquals(this.getResourceId(testres1), this.getResourceId(testres2));
-
- //remove new path
- HttpUnbind unbind = new HttpUnbind(subcol2, new UnbindInfo("res2"));
- status = this.client.execute(unbind, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
-
- //verify that the new binding is gone
- HttpHead head = new HttpHead(testres2);
- status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
- assertEquals(404, status);
-
- //verify that the initial binding is still there
- head = new HttpHead(testres1);
- status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
- assertEquals(200, status);
- } finally {
- delete(testcol);
- }
- }
-
- private String getUri(Element href) {
- String s = "";
- for (Node c = href.getFirstChild(); c != null; c = c.getNextSibling()) {
- if (c.getNodeType() == Node.TEXT_NODE) {
- s += c.getNodeValue();
- }
- }
- return s;
- }
-}
Property changes on: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/BindTest.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java (nicht existent)
@@ -1,110 +0,0 @@
-/*
- * 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.jackrabbit.webdav.server;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.zip.GZIPOutputStream;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.InputStreamEntity;
-import org.apache.http.entity.StringEntity;
-import org.apache.http.message.BasicHeader;
-import org.apache.jackrabbit.webdav.DavConstants;
-import org.apache.jackrabbit.webdav.client.methods.HttpPropfind;
-
-public class ContentCodingTest extends WebDAVTest {
-
- public void testPutNoContentCoding() throws IOException {
- String testUri = this.uri.toString() + (this.uri.toString().endsWith("/") ? "" : "/") + "testPutNoContentCoding";
- try {
- HttpPut put = new HttpPut(testUri);
- put.setEntity(new StringEntity("foobar"));
- int status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals(201, status);
- } finally {
- delete(testUri);
- }
- }
-
- public void testPutUnknownContentCoding() throws IOException {
- String testUri = this.uri.toString() + (this.uri.toString().endsWith("/") ? "" : "/") + "testPutUnkownContentCoding";
- int status = -1;
- try {
- HttpPut put = new HttpPut(testUri);
- StringEntity entity = new StringEntity("foobarfoobarfoobar");
- entity.setContentEncoding(new BasicHeader("Content-Encoding", "qux"));
- put.setEntity(entity);
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("server must signal error for unknown content coding", status == 415);
- } finally {
- if (status / 2 == 100) {
- delete(testUri);
- }
- }
- }
-
- public void testPutGzipContentCoding() throws IOException {
- String testUri = this.uri.toString() + (this.uri.toString().endsWith("/") ? "" : "/") + "testPutGzipContentCoding";
- int status = -1;
- try {
- byte bytes[] = "foobarfoobarfoobar".getBytes("UTF-8");
- HttpPut put = new HttpPut(testUri);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- OutputStream gos = new GZIPOutputStream(bos);
- gos.write(bytes);
- gos.flush();
- assertTrue(bos.toByteArray().length != bytes.length);
- InputStreamEntity entity = new InputStreamEntity(new ByteArrayInputStream(bos.toByteArray()));
- entity.setContentEncoding(new BasicHeader("Content-Encoding", "gzip"));
- put.setEntity(entity);
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("server create or signal error", status == 201 || status == 415);
- if (status / 2 == 100) {
- // check length
- HttpHead head = new HttpHead(testUri);
- HttpResponse response = this.client.execute(head, this.context);
- assertEquals(200, response.getStatusLine().getStatusCode());
- assertEquals(bytes.length, response.getFirstHeader("Content-Length").getValue());
- }
- } finally {
- if (status / 2 == 100) {
- delete(testUri);
- }
- }
- }
-
- public void testPropfindNoContentCoding() throws IOException {
- HttpPropfind propfind = new HttpPropfind(uri, DavConstants.PROPFIND_BY_PROPERTY, 0);
- int status = this.client.execute(propfind, this.context).getStatusLine().getStatusCode();
- assertEquals(207, status);
- }
-
- public void testPropfindUnknownContentCoding() throws IOException {
- HttpPropfind propfind = new HttpPropfind(uri, DavConstants.PROPFIND_BY_PROPERTY, 0);
- StringEntity entity = new StringEntity(
- "");
- entity.setContentEncoding(new BasicHeader("Content-Encoding", "qux"));
- propfind.setEntity(entity);
- int status = this.client.execute(propfind, this.context).getStatusLine().getStatusCode();
- assertTrue("server must signal error for unknown content coding", status == 415);
- }
-}
Property changes on: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/ContentCodingTest.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java (nicht existent)
@@ -1,79 +0,0 @@
-/*
- * 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.jackrabbit.webdav.server;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpHead;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.client.methods.HttpMove;
-
-/**
- * Test cases for RFC 4918 Destination header functionality
- * (see RFC 4918, Section 10.3
- */
-public class RFC4918DestinationHeaderTest extends WebDAVTest {
-
- public void testMove() throws IOException, DavException, URISyntaxException {
-
- String testuri = this.root + "movetest";
- String destinationuri = testuri + "2";
- String destinationpath = new URI(destinationuri).getRawPath();
- // make sure the scheme is removed
- assertFalse(destinationpath.contains(":"));
-
- try {
- HttpPut put = new HttpPut(testuri);
- int status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
-
- // try to move outside the servlet's name space
- HttpMove move = new HttpMove(testuri, "/foobar", true);
- status = this.client.execute(move, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 502);
-
- // try a relative path
- move = new HttpMove(testuri, "foobar", true);
- status = this.client.execute(move, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 400);
-
- move = new HttpMove(testuri, destinationpath, true);
- status = this.client.execute(move, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
-
- HttpHead head = new HttpHead(destinationuri);
- status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200);
-
- head = new HttpHead(testuri);
- status = this.client.execute(head, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 404);
-
- } finally {
- HttpDelete delete = new HttpDelete(testuri);
- int status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
- delete = new HttpDelete(destinationuri);
- status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
- }
- }
-}
Property changes on: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918DestinationHeaderTest.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java (nicht existent)
@@ -1,132 +0,0 @@
-/*
- * 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.jackrabbit.webdav.server;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.client.methods.HttpLock;
-import org.apache.jackrabbit.webdav.lock.LockInfo;
-import org.apache.jackrabbit.webdav.lock.Scope;
-import org.apache.jackrabbit.webdav.lock.Type;
-
-/**
- * Test cases for RFC 4918 If header functionality
- * (see RFC 4918, Section 10.4
- */
-
-public class RFC4918IfHeaderTest extends WebDAVTest {
-
- public void testPutIfEtag() throws IOException, DavException, URISyntaxException {
-
- String testuri = this.root + "iftest";
-
- try {
- HttpPut put = new HttpPut(testuri);
- String condition = "<" + testuri + "> ([" + "\"an-etag-this-testcase-invented\"" + "])";
- put.setEntity(new StringEntity("1"));
- put.setHeader("If", condition);
- int status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals("status: " + status, 412, status);
- }
- finally {
- HttpDelete delete = new HttpDelete(testuri);
- int status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
- }
- }
-
- public void testPutIfLockToken() throws IOException, DavException, URISyntaxException {
-
- String testuri = this.root + "iflocktest";
- String locktoken = null;
-
- try {
- HttpPut put = new HttpPut(testuri);
- put.setEntity(new StringEntity("1"));
- int status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 201 || status == 204);
-
- HttpLock lock = new HttpLock(testuri, new LockInfo(
- Scope.EXCLUSIVE, Type.WRITE, "testcase", 10000, true));
- HttpResponse response = this.client.execute(lock, this.context);
- status = response.getStatusLine().getStatusCode();
- assertEquals("status", 200, status);
- locktoken = lock.getLockToken(response);
- assertNotNull(locktoken);
- System.out.println(locktoken);
- System.out.println(response.getFirstHeader("lock-token").getValue());
-
- // try to overwrite without lock token
- put = new HttpPut(testuri);
- put.setEntity(new StringEntity("2"));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals("status: " + status, 423, status);
-
- // try to overwrite using bad lock token
- put = new HttpPut(testuri);
- put.setEntity(new StringEntity("2"));
- put.setHeader("If", "(<" + "DAV:foobar" + ">)");
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals("status: " + status, 412, status);
-
- // try to overwrite using correct lock token, using No-Tag-list format
- put = new HttpPut(testuri);
- put.setEntity(new StringEntity("2"));
- put.setHeader("If", "(<" + locktoken + ">)");
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
-
- // try to overwrite using correct lock token, using Tagged-list format
- // and full URI
- put = new HttpPut(testuri);
- put.setEntity(new StringEntity("3"));
- put.setHeader("If", "<" + testuri + ">" + "(<" + locktoken + ">)");
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
-
- // try to overwrite using correct lock token, using Tagged-list format
- // and absolute path only
- put = new HttpPut(testuri);
- put.setEntity(new StringEntity("4"));
- put.setHeader("If", "<" + new URI(testuri).getRawPath() + ">" + "(<" + locktoken + ">)");
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
-
- // try to overwrite using correct lock token, using Tagged-list format
- // and bad path
- put = new HttpPut(testuri);
- put.setEntity(new StringEntity("5"));
- put.setHeader("If", "" + "(<" + locktoken + ">)");
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 404 || status == 412);
- } finally {
- HttpDelete delete = new HttpDelete(testuri);
- if (locktoken != null) {
- delete.setHeader("If", "(<" + locktoken + ">)");
- }
- int status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204 || status == 404);
- }
- }
-}
Property changes on: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918IfHeaderTest.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java (nicht existent)
@@ -1,79 +0,0 @@
-/*
- * 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.jackrabbit.webdav.server;
-
-import java.io.IOException;
-import java.net.URISyntaxException;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpPut;
-import org.apache.http.entity.StringEntity;
-import org.apache.jackrabbit.webdav.DavConstants;
-import org.apache.jackrabbit.webdav.DavException;
-import org.apache.jackrabbit.webdav.MultiStatus;
-import org.apache.jackrabbit.webdav.MultiStatusResponse;
-import org.apache.jackrabbit.webdav.client.methods.HttpOptions;
-import org.apache.jackrabbit.webdav.client.methods.HttpPropfind;
-import org.apache.jackrabbit.webdav.property.DavPropertyNameSet;
-import org.apache.jackrabbit.webdav.property.DavPropertySet;
-import org.apache.jackrabbit.webdav.version.DeltaVConstants;
-
-/**
- * Test cases for RFC 4918 PROPFIND functionality
- * (see RFC 4918, Section 9.1
- */
-
-public class RFC4918PropfindTest extends WebDAVTest {
-
- public void testOptions() throws IOException, DavException, URISyntaxException {
- HttpOptions options = new HttpOptions(this.root);
- HttpResponse response = this.client.execute(options, this.context);
- assertTrue(options.getDavComplianceClasses(response).contains("3"));
- }
-
- public void testPropfindInclude() throws IOException, DavException, URISyntaxException {
-
- String testuri = this.root + "iftest";
-
- int status;
- try {
- HttpPut put = new HttpPut(testuri);
- put.setEntity(new StringEntity("1"));
- status = this.client.execute(put, this.context).getStatusLine().getStatusCode();
- assertEquals("status: " + status, 201, status);
-
- DavPropertyNameSet names = new DavPropertyNameSet();
- names.add(DeltaVConstants.COMMENT);
- HttpPropfind propfind = new HttpPropfind(testuri, DavConstants.PROPFIND_ALL_PROP_INCLUDE, names, 0);
- HttpResponse resp = this.client.execute(propfind, this.context);
- status = resp.getStatusLine().getStatusCode();
- assertEquals(207, status);
-
- MultiStatus multistatus = propfind.getResponseBodyAsMultiStatus(resp);
- MultiStatusResponse[] responses = multistatus.getResponses();
- assertEquals(1, responses.length);
-
- MultiStatusResponse response = responses[0];
- DavPropertySet found = response.getProperties(200);
- DavPropertySet notfound = response.getProperties(404);
-
- assertTrue(found.contains(DeltaVConstants.COMMENT) || notfound.contains(DeltaVConstants.COMMENT));
- } finally {
- delete(testuri);
- }
- }
-}
Property changes on: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/RFC4918PropfindTest.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTest.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTest.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTest.java (nicht existent)
@@ -1,94 +0,0 @@
-/*
- * 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.jackrabbit.webdav.server;
-
-import java.io.IOException;
-import java.net.URI;
-
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.UsernamePasswordCredentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.methods.HttpDelete;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.client.BasicAuthCache;
-import org.apache.http.impl.client.BasicCredentialsProvider;
-import org.apache.http.impl.client.HttpClients;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-
-import junit.framework.TestCase;
-
-/**
- * Base class for WebDAV tests.
- *
- * Required system properties:
- *
- * - webdav.test.url
- * - webdav.test.username
- * - webdav.test.password
- *
- */
-public class WebDAVTest extends TestCase {
-
- private String username, password;
- public URI uri;
- public String root;
-
- public HttpClient client;
- public HttpClientContext context;
-
- protected void setUp() throws Exception {
- this.uri = URI.create(System.getProperty("webdav.test.url", "http://localhost:8080/repository/default/"));
- this.root = this.uri.toASCIIString();
- if (!this.root.endsWith("/")) {
- this.root += "/";
- }
- this.username = System.getProperty("webdav.test.username", "admin");
- this.password = System.getProperty("webdav.test.password", "admin");
-
- PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
- HttpHost targetHost = new HttpHost(uri.getHost(), uri.getPort());
-
- CredentialsProvider credsProvider = new BasicCredentialsProvider();
- credsProvider.setCredentials(
- new AuthScope(targetHost.getHostName(), targetHost.getPort()),
- new UsernamePasswordCredentials(this.username, this.password));
-
- AuthCache authCache = new BasicAuthCache();
- // Generate BASIC scheme object and add it to the local auth cache
- BasicScheme basicAuth = new BasicScheme();
- authCache.put(targetHost, basicAuth);
-
- // Add AuthCache to the execution context
- this.context = HttpClientContext.create();
- this.context.setCredentialsProvider(credsProvider);
- this.context.setAuthCache(authCache);
-
- this.client = HttpClients.custom().setConnectionManager(cm).build();
-
- super.setUp();
- }
-
- protected void delete(String uri) throws IOException {
- HttpDelete delete = new HttpDelete(uri);
- int status = this.client.execute(delete, this.context).getStatusLine().getStatusCode();
- assertTrue("status: " + status, status == 200 || status == 204);
- }
-}
Property changes on: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebDAVTest.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property
Index: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebdavServerTests.java
===================================================================
--- jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebdavServerTests.java (Revision 1877953)
+++ jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebdavServerTests.java (nicht existent)
@@ -1,36 +0,0 @@
-/*
- * 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.jackrabbit.webdav.server;
-
-import junit.framework.Test;
-import junit.framework.TestCase;
-import junit.framework.TestSuite;
-
-public class WebdavServerTests extends TestCase {
-
- public static Test suite() {
- TestSuite suite = new TestSuite("WebDAV Server Tests");
-
- suite.addTestSuite(BindTest.class);
- suite.addTestSuite(ContentCodingTest.class);
- suite.addTestSuite(RFC4918DestinationHeaderTest.class);
- suite.addTestSuite(RFC4918IfHeaderTest.class);
- suite.addTestSuite(RFC4918PropfindTest.class);
-
- return suite;
- }
-}
Property changes on: jackrabbit-webdav/src/test/java/org/apache/jackrabbit/webdav/server/WebdavServerTests.java
___________________________________________________________________
Deleted: svn:eol-style
## -1 +0,0 ##
-native
\ No newline at end of property