Search in sources :

Example 1 with FTPParserSelector

use of ch.cyberduck.core.ftp.FTPParserSelector in project cyberduck by iterate-ch.

the class FTPListResponseReaderTest method testListNoRead.

@Test(expected = FTPInvalidListException.class)
public void testListNoRead() throws Exception {
    final Path directory = new Path("/sandbox/noread", EnumSet.of(Path.Type.directory));
    final String[] lines = new String[] { "213-Status follows:", "d-w--w----    2 1003     1003         4096 Nov 06  2013 noread", "213 End of status" };
    final AttributedList<Path> list = new FTPListResponseReader(new FTPParserSelector().getParser("UNIX"), true).read(directory, Arrays.asList(lines), new DisabledListProgressListener());
    assertEquals(0, list.size());
}
Also used : Path(ch.cyberduck.core.Path) FTPParserSelector(ch.cyberduck.core.ftp.FTPParserSelector) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 2 with FTPParserSelector

use of ch.cyberduck.core.ftp.FTPParserSelector in project cyberduck by iterate-ch.

the class FTPListResponseReaderTest method testLimit.

@Test(expected = ListCanceledException.class)
@Ignore
public void testLimit() throws Exception {
    final CompositeFileEntryParser parser = new FTPParserSelector().getParser("NETWARE  Type : L8");
    final AttributedList<Path> list = new FTPListResponseReader(parser).read(new Path("/", EnumSet.of(Path.Type.directory)), Collections.singletonList("lrwxrwxrwx    1 ftp      ftp            23 Feb 05 06:51 debian -> ../pool/4/mirror/debian"), new DisabledListProgressListener() {

        @Override
        public void chunk(final Path parent, AttributedList<Path> list) throws ListCanceledException {
            throw new ListCanceledException(AttributedList.<Path>emptyList());
        }
    });
}
Also used : FTPParserSelector(ch.cyberduck.core.ftp.FTPParserSelector) Path(ch.cyberduck.core.Path) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) CompositeFileEntryParser(ch.cyberduck.core.ftp.parser.CompositeFileEntryParser) ListCanceledException(ch.cyberduck.core.exception.ListCanceledException) Ignore(org.junit.Ignore) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 3 with FTPParserSelector

use of ch.cyberduck.core.ftp.FTPParserSelector in project cyberduck by iterate-ch.

the class FTPListResponseReaderTest method testParseAbsolutePaths.

@Test
public void testParseAbsolutePaths() throws Exception {
    Path path = new Path("/data/FTP_pub", EnumSet.of(Path.Type.directory));
    String[] replies = new String[] { "- [RWCEAFMS] Petersm                             0 May 05  2004 /data/FTP_pub/WelcomeTo_PeakFTP" };
    final CompositeFileEntryParser parser = new FTPParserSelector().getParser("NETWARE  Type : L8");
    final AttributedList<Path> list = new FTPListResponseReader(parser).read(path, Arrays.asList(replies), new DisabledListProgressListener());
    assertEquals(1, list.size());
    final Path parsed = list.get(0);
    assertEquals("WelcomeTo_PeakFTP", parsed.getName());
    assertEquals("/data/FTP_pub", parsed.getParent().getAbsolute());
    assertFalse(parsed.attributes().getPermission().isSticky());
    assertFalse(parsed.attributes().getPermission().isSetuid());
    assertFalse(parsed.attributes().getPermission().isSetgid());
}
Also used : Path(ch.cyberduck.core.Path) FTPParserSelector(ch.cyberduck.core.ftp.FTPParserSelector) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) CompositeFileEntryParser(ch.cyberduck.core.ftp.parser.CompositeFileEntryParser) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 4 with FTPParserSelector

use of ch.cyberduck.core.ftp.FTPParserSelector in project cyberduck by iterate-ch.

the class FTPListResponseReaderTest method test3243.

@Test(expected = FTPInvalidListException.class)
public void test3243() throws Exception {
    Path path = new Path("/SunnyD", EnumSet.of(Path.Type.directory));
    assertEquals("SunnyD", path.getName());
    assertEquals("/SunnyD", path.getAbsolute());
    final AttributedList<Path> list = new AttributedList<Path>();
    new FTPListResponseReader(new FTPParserSelector().getParser("UNIX")).read(path, Collections.singletonList(" drwxrwx--x 1 owner group          512 Jun 12 15:40 SunnyD"), new DisabledListProgressListener());
}
Also used : Path(ch.cyberduck.core.Path) FTPParserSelector(ch.cyberduck.core.ftp.FTPParserSelector) AttributedList(ch.cyberduck.core.AttributedList) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Example 5 with FTPParserSelector

use of ch.cyberduck.core.ftp.FTPParserSelector in project cyberduck by iterate-ch.

the class FTPListResponseReaderTest method testParseSymbolicLink.

@Test
public void testParseSymbolicLink() throws Exception {
    Path path = new Path("/", EnumSet.of(Path.Type.directory));
    assertEquals("/", path.getName());
    assertEquals("/", path.getAbsolute());
    final AttributedList<Path> list = new FTPListResponseReader(new FTPParserSelector().getParser("UNIX")).read(path, Collections.singletonList("lrwxrwxrwx    1 mk basicgrp       27 Sep 23  2004 www -> /www/basic/mk"), new DisabledListProgressListener());
    assertFalse(list.isEmpty());
    final Path parsed = list.get(0);
    assertTrue(parsed.isSymbolicLink());
    assertEquals("/www/basic/mk", parsed.getSymlinkTarget().getAbsolute());
    assertEquals(new Permission("rwxrwxrwx"), parsed.attributes().getPermission());
}
Also used : Path(ch.cyberduck.core.Path) FTPParserSelector(ch.cyberduck.core.ftp.FTPParserSelector) DisabledListProgressListener(ch.cyberduck.core.DisabledListProgressListener) Permission(ch.cyberduck.core.Permission) Test(org.junit.Test) IntegrationTest(ch.cyberduck.test.IntegrationTest)

Aggregations

FTPParserSelector (ch.cyberduck.core.ftp.FTPParserSelector)34 Test (org.junit.Test)32 FTPFile (org.apache.commons.net.ftp.FTPFile)19 FTPFileEntryParser (org.apache.commons.net.ftp.FTPFileEntryParser)18 DisabledListProgressListener (ch.cyberduck.core.DisabledListProgressListener)14 Path (ch.cyberduck.core.Path)14 IntegrationTest (ch.cyberduck.test.IntegrationTest)14 CompositeFileEntryParser (ch.cyberduck.core.ftp.parser.CompositeFileEntryParser)3 Ignore (org.junit.Ignore)3 Permission (ch.cyberduck.core.Permission)2 AttributedList (ch.cyberduck.core.AttributedList)1 ListCanceledException (ch.cyberduck.core.exception.ListCanceledException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Before (org.junit.Before)1