Locking unmapped URLs results in creation of that resource now, as specified in http://www.webdav.org/specs/rfc4918.html#rfc.section.9.10.4

This commit is contained in:
Sebastian Stenzel
2016-02-22 13:06:56 +01:00
parent ac4a68649e
commit 5df9f35065
4 changed files with 95 additions and 0 deletions
@@ -45,9 +45,13 @@ import org.apache.jackrabbit.webdav.MultiStatus;
import org.apache.jackrabbit.webdav.MultiStatusResponse;
import org.apache.jackrabbit.webdav.client.methods.CopyMethod;
import org.apache.jackrabbit.webdav.client.methods.DavMethodBase;
import org.apache.jackrabbit.webdav.client.methods.LockMethod;
import org.apache.jackrabbit.webdav.client.methods.MkColMethod;
import org.apache.jackrabbit.webdav.client.methods.MoveMethod;
import org.apache.jackrabbit.webdav.client.methods.PropFindMethod;
import org.apache.jackrabbit.webdav.lock.LockInfo;
import org.apache.jackrabbit.webdav.lock.Scope;
import org.apache.jackrabbit.webdav.lock.Type;
import org.cryptomator.filesystem.FileSystem;
import org.cryptomator.filesystem.ReadableFile;
import org.cryptomator.filesystem.WritableFile;
@@ -173,6 +177,40 @@ public class WebDavServerTest {
Assert.assertTrue(CollectionUtils.containsAll(hrefs, Arrays.asList(servletRoot + "/folder1/", servletRoot + "/folder2/", servletRoot + "/file1")));
}
/* LOCK */
@Test
public void testLockExisting() throws IOException, DavException {
final HttpClient client = new HttpClient();
// create file:
try (WritableFile writable = fs.file("foo.txt").openWritable()) {
writable.write(ByteBuffer.allocate(0));
}
// lock existing file:
LockInfo lockInfo = new LockInfo(Scope.EXCLUSIVE, Type.WRITE, "le me", 3600, false);
final DavMethodBase lockMethod = new LockMethod(servletRoot + "/foo.txt", lockInfo);
final int lockResponse = client.executeMethod(lockMethod);
Assert.assertEquals(200, lockResponse);
lockMethod.releaseConnection();
}
@Test
public void testLockNonExisting() throws IOException, DavException {
final HttpClient client = new HttpClient();
// lock nonexisting file:
LockInfo lockInfo = new LockInfo(Scope.EXCLUSIVE, Type.WRITE, "le me", 3600, false);
final DavMethodBase lockMethod = new LockMethod(servletRoot + "/foo.txt", lockInfo);
final int lockResponse = client.executeMethod(lockMethod);
Assert.assertEquals(201, lockResponse);
Assert.assertTrue(fs.file("foo.txt").exists());
lockMethod.releaseConnection();
}
/* MOVE */
@Test