1 package ch
.cyberduck
.core
.ftp
;
4 * Copyright (c) 2002-2014 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:
18 * feedback@cyberduck.io
21 import ch
.cyberduck
.core
.AbstractTestCase
;
22 import ch
.cyberduck
.core
.AttributedList
;
23 import ch
.cyberduck
.core
.Attributes
;
24 import ch
.cyberduck
.core
.Credentials
;
25 import ch
.cyberduck
.core
.DisabledCancelCallback
;
26 import ch
.cyberduck
.core
.DisabledHostKeyCallback
;
27 import ch
.cyberduck
.core
.DisabledLoginCallback
;
28 import ch
.cyberduck
.core
.DisabledPasswordStore
;
29 import ch
.cyberduck
.core
.DisabledTranscriptListener
;
30 import ch
.cyberduck
.core
.Host
;
31 import ch
.cyberduck
.core
.ListProgressListener
;
32 import ch
.cyberduck
.core
.Path
;
33 import ch
.cyberduck
.core
.Permission
;
34 import ch
.cyberduck
.core
.exception
.AccessDeniedException
;
35 import ch
.cyberduck
.core
.exception
.BackgroundException
;
36 import ch
.cyberduck
.core
.exception
.InteroperabilityException
;
38 import org
.junit
.Test
;
40 import java
.util
.EnumSet
;
42 import static org
.junit
.Assert
.assertEquals
;
47 public class FTPAttributesFeatureTest
extends AbstractTestCase
{
49 @Test(expected
= InteroperabilityException
.class)
50 public void testAttributesUnknownCommand() throws Exception
{
51 final Host host
= new Host(new FTPProtocol(), "test.cyberduck.ch", new Credentials(
52 properties
.getProperty("ftp.user"), properties
.getProperty("ftp.password")
54 final FTPSession session
= new FTPSession(host
) {
56 public AttributedList
<Path
> list(final Path file
, final ListProgressListener listener
) throws BackgroundException
{
57 throw new AccessDeniedException("f");
60 session
.open(new DisabledHostKeyCallback(), new DisabledTranscriptListener());
61 session
.login(new DisabledPasswordStore(), new DisabledLoginCallback(), new DisabledCancelCallback());
62 final FTPAttributesFeature f
= new FTPAttributesFeature(session
);
63 final Path file
= new Path(session
.workdir(), "test", EnumSet
.of(Path
.Type
.file
));
64 final Attributes attributes
= f
.find(file
);
65 assertEquals(0L, attributes
.getSize());
66 assertEquals("1106", attributes
.getOwner());
67 assertEquals(new Permission("-rw-rw-rw-"), attributes
.getPermission());