-
-
Notifications
You must be signed in to change notification settings - Fork 296
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
70 additions
and
0 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
ctera/src/test/java/ch/cyberduck/core/ctera/CteraDeleteFeatureTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package ch.cyberduck.core.ctera; | ||
|
||
import ch.cyberduck.core.AlphanumericRandomStringService; | ||
import ch.cyberduck.core.DisabledLoginCallback; | ||
import ch.cyberduck.core.Path; | ||
import ch.cyberduck.core.dav.DAVDeleteFeature; | ||
import ch.cyberduck.core.dav.DAVDirectoryFeature; | ||
import ch.cyberduck.core.dav.DAVFindFeature; | ||
import ch.cyberduck.core.dav.DAVLockFeature; | ||
import ch.cyberduck.core.dav.DAVTouchFeature; | ||
import ch.cyberduck.core.exception.InteroperabilityException; | ||
import ch.cyberduck.core.exception.NotfoundException; | ||
import ch.cyberduck.core.features.Delete; | ||
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.Collections; | ||
import java.util.EnumSet; | ||
|
||
import static org.junit.Assert.assertFalse; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
@Category(IntegrationTest.class) | ||
public class CteraDeleteFeatureTest extends AbstractCteraTest { | ||
|
||
@Test | ||
public void testDeleteFile() 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()); | ||
assertTrue(new DAVFindFeature(session).find(test)); | ||
new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); | ||
assertFalse(new DAVFindFeature(session).find(test)); | ||
} | ||
|
||
@Test | ||
public void testDeleteFileWithLock() 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()); | ||
String lock = null; | ||
try { | ||
lock = new DAVLockFeature(session).lock(test); | ||
} | ||
catch(InteroperabilityException e) { | ||
// Not supported | ||
} | ||
assertTrue(new DAVFindFeature(session).find(test)); | ||
new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus().withLockId(lock)), new DisabledLoginCallback(), new Delete.DisabledCallback()); | ||
assertFalse(new DAVFindFeature(session).find(test)); | ||
} | ||
|
||
@Test | ||
public void testDeleteDirectory() throws Exception { | ||
final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)); | ||
new DAVDirectoryFeature(session).mkdir(test, new TransferStatus()); | ||
assertTrue(new DAVFindFeature(session).find(test)); | ||
new DAVTouchFeature(session).touch(new Path(test, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus()); | ||
new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); | ||
assertFalse(new DAVFindFeature(session).find(test)); | ||
} | ||
|
||
@Test(expected = NotfoundException.class) | ||
public void testDeleteNotFound() throws Exception { | ||
final Path test = new Path(new DefaultHomeFinderService(session).find(), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)); | ||
new DAVDeleteFeature(session).delete(Collections.singletonMap(test, new TransferStatus()), new DisabledLoginCallback(), new Delete.DisabledCallback()); | ||
} | ||
} |