1 package ch
.cyberduck
.core
.irods
;
4 * Copyright (c) 2002-2015 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
20 import ch
.cyberduck
.core
.AbstractTestCase
;
21 import ch
.cyberduck
.core
.Credentials
;
22 import ch
.cyberduck
.core
.DisabledCancelCallback
;
23 import ch
.cyberduck
.core
.DisabledHostKeyCallback
;
24 import ch
.cyberduck
.core
.DisabledLoginCallback
;
25 import ch
.cyberduck
.core
.DisabledPasswordStore
;
26 import ch
.cyberduck
.core
.DisabledTranscriptListener
;
27 import ch
.cyberduck
.core
.Host
;
28 import ch
.cyberduck
.core
.Local
;
29 import ch
.cyberduck
.core
.Path
;
30 import ch
.cyberduck
.core
.Profile
;
31 import ch
.cyberduck
.core
.ProfileReaderFactory
;
32 import ch
.cyberduck
.core
.exception
.NotfoundException
;
33 import ch
.cyberduck
.core
.features
.Delete
;
34 import ch
.cyberduck
.core
.features
.Directory
;
35 import ch
.cyberduck
.core
.features
.Find
;
37 import org
.junit
.Test
;
39 import java
.util
.Arrays
;
40 import java
.util
.EnumSet
;
41 import java
.util
.UUID
;
43 import static org
.junit
.Assert
.assertFalse
;
44 import static org
.junit
.Assert
.assertTrue
;
49 public class IRODSDeleteFeatureTest
extends AbstractTestCase
{
52 public void testDelete() throws Exception
{
53 final Profile profile
= ProfileReaderFactory
.get().read(
54 new Local("profiles/iRODS (iPlant Collaborative).cyberduckprofile"));
55 final Host host
= new Host(profile
, profile
.getDefaultHostname(), new Credentials(
56 properties
.getProperty("irods.key"), properties
.getProperty("irods.secret")
59 final IRODSSession session
= new IRODSSession(host
);
60 session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
61 session
.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
63 final Path test
= new Path(session
.workdir(), UUID
.randomUUID().toString(), EnumSet
.of(Path
.Type
.directory
));
64 session
.getFeature(Directory
.class).mkdir(test
);
65 assertTrue(session
.getFeature(Find
.class).find(test
));
67 new IRODSDeleteFeature(session
).delete(Arrays
.asList(test
), new DisabledLoginCallback(), new Delete
.Callback() {
69 public void delete(final Path file
) {
72 assertFalse(session
.getFeature(Find
.class).find(test
));
76 @Test(expected
= NotfoundException
.class)
77 public void testDeleteNotFound() throws Exception
{
78 final Profile profile
= ProfileReaderFactory
.get().read(
79 new Local("profiles/iRODS (iPlant Collaborative).cyberduckprofile"));
80 final Host host
= new Host(profile
, profile
.getDefaultHostname(), new Credentials(
81 properties
.getProperty("irods.key"), properties
.getProperty("irods.secret")
84 final IRODSSession session
= new IRODSSession(host
);
85 session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
86 session
.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
88 final Path test
= new Path(session
.workdir(), UUID
.randomUUID().toString(), EnumSet
.of(Path
.Type
.directory
));
90 assertFalse(session
.getFeature(Find
.class).find(test
));
92 new IRODSDeleteFeature(session
).delete(Arrays
.asList(test
), new DisabledLoginCallback(), new Delete
.Callback() {
94 public void delete(final Path file
) {