Add callback for delete operation.
[cyberduck.git] / test / ch / cyberduck / core / dav / DAVDeleteFeatureTest.java
blob1d2f8597f20e6106e96af04cc1e3f7474290e069
1 package ch.cyberduck.core.dav;
3 import ch.cyberduck.core.AbstractTestCase;
4 import ch.cyberduck.core.Credentials;
5 import ch.cyberduck.core.DisabledCancelCallback;
6 import ch.cyberduck.core.DisabledHostKeyCallback;
7 import ch.cyberduck.core.DisabledLoginCallback;
8 import ch.cyberduck.core.DisabledPasswordStore;
9 import ch.cyberduck.core.DisabledTranscriptListener;
10 import ch.cyberduck.core.Host;
11 import ch.cyberduck.core.Path;
12 import ch.cyberduck.core.exception.NotfoundException;
13 import ch.cyberduck.core.features.Delete;
14 import ch.cyberduck.core.features.Find;
15 import ch.cyberduck.core.shared.DefaultHomeFinderService;
16 import ch.cyberduck.core.shared.DefaultTouchFeature;
18 import org.junit.Test;
20 import java.util.Collections;
21 import java.util.EnumSet;
22 import java.util.UUID;
24 import static org.junit.Assert.assertFalse;
25 import static org.junit.Assert.assertTrue;
27 /**
28 * @version $Id$
30 public class DAVDeleteFeatureTest extends AbstractTestCase {
32 @Test
33 public void testDeleteDirectory() throws Exception {
34 final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch", new Credentials(
35 properties.getProperty("webdav.user"), properties.getProperty("webdav.password")
36 ));
37 host.setDefaultPath("/dav/basic");
38 final DAVSession session = new DAVSession(host);
39 session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
40 session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
41 final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory));
42 new DAVDirectoryFeature(session).mkdir(test, null);
43 assertTrue(session.getFeature(Find.class).find(test));
44 new DefaultTouchFeature(session).touch(new Path(test, UUID.randomUUID().toString(), EnumSet.of(Path.Type.file)));
45 new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.Callback() {
46 @Override
47 public void delete(final Path file) {
49 });
50 assertFalse(session.getFeature(Find.class).find(test));
51 session.close();
54 @Test(expected = NotfoundException.class)
55 public void testDeleteNotFound() throws Exception {
56 final Host host = new Host(new DAVProtocol(), "test.cyberduck.ch", new Credentials(
57 properties.getProperty("webdav.user"), properties.getProperty("webdav.password")
58 ));
59 host.setDefaultPath("/dav/basic");
60 final DAVSession session = new DAVSession(host);
61 session.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
62 session.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
63 final Path test = new Path(new DefaultHomeFinderService(session).find(), UUID.randomUUID().toString(), EnumSet.of(Path.Type.file));
64 new DAVDeleteFeature(session).delete(Collections.singletonList(test), new DisabledLoginCallback(), new Delete.Callback() {
65 @Override
66 public void delete(final Path file) {
68 });