diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/DAVCopyFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/DAVCopyFeatureTest.java index 972feb48c01..58a0d86d251 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/DAVCopyFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/DAVCopyFeatureTest.java @@ -22,6 +22,7 @@ import ch.cyberduck.core.DisabledLoginCallback; import ch.cyberduck.core.Path; import ch.cyberduck.core.exception.ConflictException; +import ch.cyberduck.core.exception.InteroperabilityException; import ch.cyberduck.core.features.Delete; import ch.cyberduck.core.features.Find; import ch.cyberduck.core.io.DisabledStreamListener; @@ -55,6 +56,13 @@ public void testCopyFile() throws Exception { new DAVDeleteFeature(session).delete(Collections.singletonList(copy), new DisabledLoginCallback(), new Delete.DisabledCallback()); } + @Test + public void testCopyWithLock() throws Exception { + final Path test = new DAVTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); + assertThrows(InteroperabilityException.class, () -> new DAVLockFeature(session).lock(test)); + new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + @Test public void testCopyToExistingFile() throws Exception { final Path folder = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/DAVMoveFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/DAVMoveFeatureTest.java index c9424dedeb1..1e703e41468 100644 --- a/webdav/src/test/java/ch/cyberduck/core/dav/DAVMoveFeatureTest.java +++ b/webdav/src/test/java/ch/cyberduck/core/dav/DAVMoveFeatureTest.java @@ -24,6 +24,7 @@ import ch.cyberduck.core.PathAttributes; import ch.cyberduck.core.exception.ConflictException; import ch.cyberduck.core.exception.InteroperabilityException; +import ch.cyberduck.core.exception.LockedException; import ch.cyberduck.core.exception.NotfoundException; import ch.cyberduck.core.features.Delete; import ch.cyberduck.core.http.HttpResponseOutputStream; @@ -58,26 +59,14 @@ public void testMove() throws Exception { assertTrue(new DAVFindFeature(session).find(target)); assertEquals(status.getResponse(), target.attributes()); assertEquals(attr, new DAVAttributesFinderFeature(session).find(target)); - new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); } @Test public void testMoveWithLock() throws Exception { final Path test = new DAVTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); - String lock = null; - try { - lock = new DAVLockFeature(session).lock(test); - } - catch(InteroperabilityException e) { - // Not supported - } - assertEquals(TransferStatus.UNKNOWN_LENGTH, test.attributes().getSize()); - final Path target = new DAVMoveFeature(session).move(test, - new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus().withLockId(lock), new Delete.DisabledCallback(), new DisabledConnectionCallback()); - assertFalse(new DAVFindFeature(session).find(test)); - assertTrue(new DAVFindFeature(session).find(target)); - assertEquals(test.attributes(), target.attributes()); - new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + assertThrows(InteroperabilityException.class, () -> new DAVLockFeature(session).lock(test)); + new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); } @Test @@ -105,7 +94,7 @@ public void testMoveDirectory() throws Exception { assertEquals(attr, new DAVAttributesFinderFeature(session).find(new Path(target, test.getName(), EnumSet.of(Path.Type.file)))); assertEquals(attr.getModificationDate(), new DAVAttributesFinderFeature(session).find(new Path(target, test.getName(), EnumSet.of(Path.Type.file))).getModificationDate()); assertNotEquals(attr.getETag(), new DAVAttributesFinderFeature(session).find(new Path(target, test.getName(), EnumSet.of(Path.Type.file))).getETag()); - new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); } @Test @@ -118,7 +107,7 @@ public void testMoveOverride() throws Exception { new DAVMoveFeature(session).move(test, target, new TransferStatus().exists(true), new Delete.DisabledCallback(), new DisabledConnectionCallback()); assertFalse(new DAVFindFeature(session).find(test)); assertTrue(new DAVFindFeature(session).find(target)); - new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); } @Test(expected = NotfoundException.class) diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVCopyFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVCopyFeatureTest.java new file mode 100644 index 00000000000..7118cee1387 --- /dev/null +++ b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVCopyFeatureTest.java @@ -0,0 +1,129 @@ +package ch.cyberduck.core.dav.microsoft; + +/* + * Copyright (c) 2002-2013 David Kocher. All rights reserved. + * http://cyberduck.ch/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch + */ + +import ch.cyberduck.core.AlphanumericRandomStringService; +import ch.cyberduck.core.DisabledConnectionCallback; +import ch.cyberduck.core.DisabledLoginCallback; +import ch.cyberduck.core.Path; +import ch.cyberduck.core.dav.AbstractDAVTest; +import ch.cyberduck.core.dav.DAVAttributesFinderFeature; +import ch.cyberduck.core.dav.DAVCopyFeature; +import ch.cyberduck.core.dav.DAVDeleteFeature; +import ch.cyberduck.core.dav.DAVDirectoryFeature; +import ch.cyberduck.core.dav.DAVLockFeature; +import ch.cyberduck.core.dav.DAVTouchFeature; +import ch.cyberduck.core.exception.ConflictException; +import ch.cyberduck.core.features.Delete; +import ch.cyberduck.core.features.Find; +import ch.cyberduck.core.io.DisabledStreamListener; +import ch.cyberduck.core.shared.DefaultFindFeature; +import ch.cyberduck.core.shared.DefaultHomeFinderService; +import ch.cyberduck.core.transfer.TransferStatus; +import ch.cyberduck.test.IntegrationTest; + +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.util.Arrays; +import java.util.Collections; +import java.util.EnumSet; + +import static org.junit.Assert.*; + +@Category(IntegrationTest.class) +public class MicrosoftIISDAVCopyFeatureTest extends AbstractMicrosoftIISDAVTest { + + @Test + public void testCopyFile() throws Exception { + final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(test, new TransferStatus()); + final Path copy = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVCopyFeature(session).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()); + assertEquals(new DAVAttributesFinderFeature(session).find(test), new DAVAttributesFinderFeature(session).find(copy)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(test)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(copy)); + new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.DisabledCallback()); + new DAVDeleteFeature(session).delete(Collections.singletonList(copy), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testCopyWithLock() throws Exception { + final Path test = new DAVTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); + final String lock = new DAVLockFeature(session).lock(test); + assertEquals(TransferStatus.UNKNOWN_LENGTH, test.attributes().getSize()); + final Path target = new DAVCopyFeature(session).copy(test, + new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus().withLockId(lock), new DisabledConnectionCallback(), new DisabledStreamListener()); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(test)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(target)); + assertEquals(test.attributes(), target.attributes()); + new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus().withLockId(lock)), new DisabledLoginCallback(), new Delete.DisabledCallback()); + new DAVDeleteFeature(session).delete(Collections.singletonMap(target, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testCopyToExistingFile() throws Exception { + final Path folder = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); + new DAVDirectoryFeature(session).mkdir(folder, new TransferStatus()); + final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(test, new TransferStatus()); + final Path copy = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(copy, new TransferStatus()); + assertThrows(ConflictException.class, () -> new DAVCopyFeature(session).copy(test, copy, new TransferStatus().exists(false), new DisabledConnectionCallback(), new DisabledStreamListener())); + new DAVCopyFeature(session).copy(test, copy, new TransferStatus().exists(true), new DisabledConnectionCallback(), new DisabledStreamListener()); + final Find find = new DefaultFindFeature(session); + assertTrue(find.find(test)); + assertTrue(find.find(copy)); + new DAVDeleteFeature(session).delete(Arrays.asList(test, copy), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testCopyWithLockToExistingFile() throws Exception { + final Path folder = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); + new DAVDirectoryFeature(session).mkdir(folder, new TransferStatus()); + final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(test, new TransferStatus()); + final String lock = new DAVLockFeature(session).lock(test); + final Path copy = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(copy, new TransferStatus()); + assertThrows(ConflictException.class, () -> new DAVCopyFeature(session).copy(test, copy, new TransferStatus().exists(false), new DisabledConnectionCallback(), new DisabledStreamListener())); + new DAVCopyFeature(session).copy(test, copy, new TransferStatus().exists(true).withLockId(lock), new DisabledConnectionCallback(), new DisabledStreamListener()); + final Find find = new DefaultFindFeature(session); + assertTrue(find.find(test)); + assertTrue(find.find(copy)); + new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus().withLockId(lock)), new DisabledLoginCallback(), new Delete.DisabledCallback()); + new DAVDeleteFeature(session).delete(Collections.singletonMap(copy, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testCopyDirectory() throws Exception { + final Path directory = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); + final String name = new AlphanumericRandomStringService().random(); + final Path file = new Path(directory, name, EnumSet.of(Path.Type.file)); + new DAVDirectoryFeature(session).mkdir(directory, new TransferStatus()); + new DAVTouchFeature(session).touch(file, new TransferStatus()); + final Path copy = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); + new DAVDirectoryFeature(session).mkdir(copy, new TransferStatus()); + assertThrows(ConflictException.class, () -> new DAVCopyFeature(session).copy(directory, copy, new TransferStatus().exists(false), new DisabledConnectionCallback(), new DisabledStreamListener())); + new DAVCopyFeature(session).copy(directory, copy, new TransferStatus().exists(true), new DisabledConnectionCallback(), new DisabledStreamListener()); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(file)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(copy)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(new Path(copy, name, EnumSet.of(Path.Type.file)))); + new DAVDeleteFeature(session).delete(Arrays.asList(copy, directory), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } +} diff --git a/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVMoveFeatureTest.java b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVMoveFeatureTest.java new file mode 100644 index 00000000000..c86bcd87178 --- /dev/null +++ b/webdav/src/test/java/ch/cyberduck/core/dav/microsoft/MicrosoftIISDAVMoveFeatureTest.java @@ -0,0 +1,147 @@ +package ch.cyberduck.core.dav.microsoft; + +/* + * Copyright (c) 2002-2013 David Kocher. All rights reserved. + * http://cyberduck.ch/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch + */ + +import ch.cyberduck.core.AlphanumericRandomStringService; +import ch.cyberduck.core.DisabledConnectionCallback; +import ch.cyberduck.core.DisabledLoginCallback; +import ch.cyberduck.core.Path; +import ch.cyberduck.core.PathAttributes; +import ch.cyberduck.core.dav.DAVAttributesFinderFeature; +import ch.cyberduck.core.dav.DAVDeleteFeature; +import ch.cyberduck.core.dav.DAVDirectoryFeature; +import ch.cyberduck.core.dav.DAVLockFeature; +import ch.cyberduck.core.dav.DAVMoveFeature; +import ch.cyberduck.core.dav.DAVTimestampFeature; +import ch.cyberduck.core.dav.DAVTouchFeature; +import ch.cyberduck.core.dav.DAVWriteFeature; +import ch.cyberduck.core.exception.ConflictException; +import ch.cyberduck.core.exception.LockedException; +import ch.cyberduck.core.exception.NotfoundException; +import ch.cyberduck.core.features.Delete; +import ch.cyberduck.core.http.HttpResponseOutputStream; +import ch.cyberduck.core.io.StreamCopier; +import ch.cyberduck.core.shared.DefaultHomeFinderService; +import ch.cyberduck.core.transfer.TransferStatus; +import ch.cyberduck.test.IntegrationTest; + +import org.apache.commons.lang3.RandomUtils; +import org.junit.Test; +import org.junit.experimental.categories.Category; + +import java.io.ByteArrayInputStream; +import java.util.Collections; +import java.util.EnumSet; + +import static org.junit.Assert.*; + +@Category(IntegrationTest.class) +public class MicrosoftIISDAVMoveFeatureTest extends AbstractMicrosoftIISDAVTest { + + @Test + public void testMove() throws Exception { + final Path test = new DAVTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); + assertEquals(TransferStatus.UNKNOWN_LENGTH, test.attributes().getSize()); + final TransferStatus status = new TransferStatus(); + new DAVTimestampFeature(session).setTimestamp(test, status.withModified(5000L)); + final PathAttributes attr = new DAVAttributesFinderFeature(session).find(test); + final Path target = new DAVMoveFeature(session).move(test.withAttributes(status.getResponse()), + new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); + assertFalse(new MicrosoftIISDAVFindFeature(session).find(test)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(target)); + assertEquals(status.getResponse(), target.attributes()); + assertEquals(attr, new DAVAttributesFinderFeature(session).find(target)); + new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testMoveWithLock() throws Exception { + final Path test = new DAVTouchFeature(session).touch(new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); + final String lock = new DAVLockFeature(session).lock(test); + assertEquals(TransferStatus.UNKNOWN_LENGTH, test.attributes().getSize()); + final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + assertThrows(LockedException.class, () -> new DAVMoveFeature(session).move(test, target, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback())); + new DAVMoveFeature(session).move(test, target, new TransferStatus().withLockId(lock), new Delete.DisabledCallback(), new DisabledConnectionCallback()); + assertFalse(new MicrosoftIISDAVFindFeature(session).find(test)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(target)); + assertEquals(test.attributes(), target.attributes()); + new DAVDeleteFeature(session).delete(Collections.singletonMap(target, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testMoveDirectory() throws Exception { + final Path folder = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); + new DAVDirectoryFeature(session).mkdir(folder, new TransferStatus()); + final Path test = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + { + final byte[] content = RandomUtils.nextBytes(3547); + final TransferStatus status = new TransferStatus(); + status.setOffset(0L); + status.setLength(1024L); + final HttpResponseOutputStream out = new DAVWriteFeature(session).write(test, status, new DisabledConnectionCallback()); + // Write first 1024 + new StreamCopier(status, status).withOffset(status.getOffset()).withLimit(status.getLength()).transfer(new ByteArrayInputStream(content), out); + out.close(); + } + final PathAttributes attr = new DAVAttributesFinderFeature(session).find(test); + final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); + new DAVMoveFeature(session).move(folder, target, new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); + assertFalse(new MicrosoftIISDAVFindFeature(session).find(folder)); + assertFalse(new MicrosoftIISDAVFindFeature(session).find(test)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(target)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(new Path(target, test.getName(), EnumSet.of(Path.Type.file)))); + assertEquals(attr, new DAVAttributesFinderFeature(session).find(new Path(target, test.getName(), EnumSet.of(Path.Type.file)))); + assertEquals(attr.getModificationDate(), new DAVAttributesFinderFeature(session).find(new Path(target, test.getName(), EnumSet.of(Path.Type.file))).getModificationDate()); + assertEquals(attr.getETag(), new DAVAttributesFinderFeature(session).find(new Path(target, test.getName(), EnumSet.of(Path.Type.file))).getETag()); + new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testMoveOverride() throws Exception { + final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(test, new TransferStatus()); + final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(target, new TransferStatus()); + assertThrows(ConflictException.class, () -> new DAVMoveFeature(session).move(test, target, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback())); + new DAVMoveFeature(session).move(test, target, new TransferStatus().exists(true), new Delete.DisabledCallback(), new DisabledConnectionCallback()); + assertFalse(new MicrosoftIISDAVFindFeature(session).find(test)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(target)); + new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test + public void testMoveOverrideWithLock() throws Exception { + final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(test, new TransferStatus()); + final Path target = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVTouchFeature(session).touch(target, new TransferStatus()); + assertThrows(ConflictException.class, () -> new DAVMoveFeature(session).move(test, target, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback())); + final String lock = new DAVLockFeature(session).lock(test); + assertThrows(LockedException.class, () -> new DAVMoveFeature(session).move(test, target, new TransferStatus().exists(false), new Delete.DisabledCallback(), new DisabledConnectionCallback())); + new DAVMoveFeature(session).move(test, target, new TransferStatus().exists(true).withLockId(lock), new Delete.DisabledCallback(), new DisabledConnectionCallback()); + assertFalse(new MicrosoftIISDAVFindFeature(session).find(test)); + assertTrue(new MicrosoftIISDAVFindFeature(session).find(target)); + new DAVDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback()); + } + + @Test(expected = NotfoundException.class) + public void testMoveNotFound() throws Exception { + final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); + new DAVMoveFeature(session).move(test, new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus(), new Delete.DisabledCallback(), new DisabledConnectionCallback()); + } +}