1 package ch
.cyberduck
.core
.ftp
;
4 * Copyright (c) 2002-2013 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
.DisabledListProgressListener
;
25 import ch
.cyberduck
.core
.DisabledLoginCallback
;
26 import ch
.cyberduck
.core
.DisabledPasswordStore
;
27 import ch
.cyberduck
.core
.DisabledTranscriptListener
;
28 import ch
.cyberduck
.core
.Host
;
29 import ch
.cyberduck
.core
.ListService
;
30 import ch
.cyberduck
.core
.Path
;
31 import ch
.cyberduck
.core
.ftp
.parser
.CompositeFileEntryParser
;
33 import org
.apache
.commons
.net
.ftp
.parser
.UnixFTPEntryParser
;
34 import org
.junit
.Test
;
36 import java
.util
.Arrays
;
37 import java
.util
.EnumSet
;
39 import static org
.junit
.Assert
.assertTrue
;
44 public class FTPDefaultListServiceTest
extends AbstractTestCase
{
47 public void testListDefault() throws Exception
{
48 final Host host
= new Host(new FTPTLSProtocol(), "test.cyberduck.ch", new Credentials(
49 properties
.getProperty("ftp.user"), properties
.getProperty("ftp.password")
51 final FTPSession session
= new FTPSession(host
);
52 session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
53 session
.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
54 final ListService list
= new FTPDefaultListService(session
,
55 new CompositeFileEntryParser(Arrays
.asList(new UnixFTPEntryParser())),
56 FTPListService
.Command
.list
);
57 final Path directory
= session
.workdir();
58 assertTrue(list
.list(directory
, new DisabledListProgressListener()).contains(new Path(directory
, "test", EnumSet
.of(Path
.Type
.file
))));
63 public void testListDefaultFlag() throws Exception
{
64 final Host host
= new Host(new FTPTLSProtocol(), "test.cyberduck.ch", new Credentials(
65 properties
.getProperty("ftp.user"), properties
.getProperty("ftp.password")
67 final FTPSession session
= new FTPSession(host
);
68 session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
69 session
.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
70 final ListService list
= new FTPDefaultListService(session
,
71 new CompositeFileEntryParser(Arrays
.asList(new UnixFTPEntryParser())),
72 FTPListService
.Command
.lista
);
73 final Path directory
= session
.workdir();
74 assertTrue(list
.list(directory
, new DisabledListProgressListener()).contains(new Path(directory
, "test", EnumSet
.of(Path
.Type
.file
))));