Cyberduck Mountain Duck CLI

Changeset 41298


Ignore:
Timestamp:
Jun 7, 2017 9:00:18 PM (13 months ago)
Author:
dkocher
Message:

Fix tests.

Location:
shelves/02.06.2017
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • shelves/02.06.2017/ftp/src/main/java/ch/cyberduck/core/ftp/FTPProtocol.java

    r41265 r41298  
    2525import org.apache.commons.lang3.StringUtils;
    2626
    27 public final class FTPProtocol extends AbstractProtocol {
     27public class FTPProtocol extends AbstractProtocol {
    2828
    2929    @Override
  • shelves/02.06.2017/ftp/src/test/java/ch/cyberduck/core/HostParserTest.java

    r35652 r41298  
    1313    @Test
    1414    public void testParseURLEmpty() {
    15         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("");
     15        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("");
    1616        assertEquals("", h.getHostname());
    1717    }
     
    1919    @Test
    2020    public void testParseHostnameOnly() {
    21         assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("hostname").getHostname());
    22         assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("hostname ").getHostname());
    23         assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get(" hostname").getHostname());
     21        assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("hostname").getHostname());
     22        assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("hostname ").getHostname());
     23        assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get(" hostname").getHostname());
    2424    }
    2525
    2626    @Test
    2727    public void testParseHostnameOnlyRemoveTrailingSlash() {
    28         assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("hostname/").getHostname());
    29         assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("hostname//").getHostname());
    30         assertEquals("", new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("/hostname").getHostname());
     28        assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("hostname/").getHostname());
     29        assertEquals("hostname", new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("hostname//").getHostname());
     30        assertEquals("", new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("/hostname").getHostname());
    3131    }
    3232
     
    3434    public void testParseNoProtocolAndCustomPath() {
    3535        String url = "user@hostname/path/to/file";
    36         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get(url);
     36        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get(url);
    3737        assertEquals("hostname", h.getHostname());
    3838        assertNotNull(h.getCredentials().getUsername());
     
    4545    public void testParseNoProtocol() {
    4646        String url = "user@hostname";
    47         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get(url);
     47        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get(url);
    4848        assertEquals("hostname", h.getHostname());
    4949        assertNotNull(h.getCredentials().getUsername());
     
    5555    public void testParseWithTwoAtSymbol() {
    5656        String url = "user@name@hostname";
    57         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get(url);
     57        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get(url);
    5858        assertEquals("hostname", h.getHostname());
    5959        assertNotNull(h.getCredentials().getUsername());
     
    6565    public void testParseWithTwoAtSymbolAndPassword() {
    6666        String url = "user@name:password@hostname";
    67         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get(url);
     67        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get(url);
    6868        assertEquals("hostname", h.getHostname());
    6969        assertNotNull(h.getCredentials().getUsername());
     
    7575    public void testParseWithDefaultPath() {
    7676        String url = "user@hostname/path/to/file";
    77         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get(url);
     77        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get(url);
    7878        assertEquals("/path/to/file", h.getDefaultPath());
    7979    }
     
    8282    public void testParseWithDefaultPathAndCustomPort() {
    8383        String url = "user@hostname:999/path/to/file";
    84         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get(url);
     84        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get(url);
    8585        assertEquals("/path/to/file", h.getDefaultPath());
    8686    }
     
    8888    @Test
    8989    public void testInvalidPortnumber() {
    90         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("ftp://hostname:21a");
     90        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("ftp://hostname:21a");
    9191        assertEquals("hostname", host.getHostname());
    9292        assertEquals(Protocol.Type.ftp, host.getProtocol().getType());
     
    9696    @Test
    9797    public void testMissingPortNumber() {
    98         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("ftp://hostname:~/sandbox");
     98        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("ftp://hostname:~/sandbox");
    9999        assertEquals("hostname", host.getHostname());
    100100        assertEquals(Protocol.Type.ftp, host.getProtocol().getType());
     
    105105    @Test
    106106    public void testParseIpv6() throws Exception {
    107         final HostParser parser = new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol())));
     107        final HostParser parser = new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol())));
    108108        assertEquals("fc01:2:3:4:5::1", parser.get("ftp://fc01:2:3:4:5::1/~/sandbox").getHostname());
    109109        assertEquals(Protocol.Type.ftp, parser.get("ftp://fc01:2:3:4:5::1/~/sandbox").getProtocol().getType());
     
    121121    @Test
    122122    public void testParseIpv6LinkLocalZoneIndex() throws Exception {
    123         assertEquals("fe80::c62c:3ff:fe0b:8670%en0", new HostParser(new ProtocolFactory(Collections.singleton(new FTPProtocol()))).get("ftp://fe80::c62c:3ff:fe0b:8670%en0/~/sandbox").getHostname());
     123        assertEquals("fe80::c62c:3ff:fe0b:8670%en0", new HostParser(new ProtocolFactory(Collections.singleton(new TestFTPProtocol()))).get("ftp://fe80::c62c:3ff:fe0b:8670%en0/~/sandbox").getHostname());
     124    }
     125
     126    private static class TestFTPProtocol extends FTPProtocol {
     127        @Override
     128        public boolean isEnabled() {
     129            return true;
     130        }
    124131    }
    125132}
  • shelves/02.06.2017/s3/src/main/java/ch/cyberduck/core/s3/S3Protocol.java

    r41270 r41298  
    3232import java.util.Set;
    3333
    34 public final class S3Protocol extends AbstractProtocol {
     34public class S3Protocol extends AbstractProtocol {
    3535    private static final Logger log = Logger.getLogger(S3Protocol.class);
    3636
  • shelves/02.06.2017/s3/src/test/java/ch/cyberduck/core/HostParserTest.java

    r35652 r41298  
    1414    @Test
    1515    public void testParseS3Scheme() throws Exception {
    16         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new S3Protocol()))).get("s3://bucketname/key");
     16        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestS3Protocol()))).get("s3://bucketname/key");
    1717        assertEquals("s3.amazonaws.com", host.getHostname());
    1818        assertEquals(Protocol.Type.s3, host.getProtocol().getType());
     
    2323    public void testParseS3SchemeAccessKey() throws Exception {
    2424        assertTrue(new Host(new S3Protocol(), "s3.amazonaws.com", 443, "/cyberduck-test/key", new Credentials("AWS456", null))
    25                 .compareTo(new HostParser(new ProtocolFactory(Collections.singleton(new S3Protocol()))).get("s3://AWS456@cyberduck-test/key")) == 0);
     25                .compareTo(new HostParser(new ProtocolFactory(Collections.singleton(new TestS3Protocol()))).get("s3://AWS456@cyberduck-test/key")) == 0);
     26    }
     27
     28    private static class TestS3Protocol extends S3Protocol {
     29        @Override
     30        public boolean isEnabled() {
     31            return true;
     32        }
    2633    }
    2734}
  • shelves/02.06.2017/webdav/src/main/java/ch/cyberduck/core/dav/DAVProtocol.java

    r41291 r41298  
    22
    33/*
    4  * Copyright (c) 2002-2013 David Kocher. All rights reserved.
    5  * http://cyberduck.ch/
     4 * Copyright (c) 2002-2017 iterate GmbH. All rights reserved.
     5 * https://cyberduck.io/
    66 *
    77 * This program is free software; you can redistribute it and/or modify
     
    1414 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1515 * GNU General Public License for more details.
    16  *
    17  * Bug fixes, suggestions and comments should be sent to feedback@cyberduck.ch
    1816 */
    1917
     
    2321import org.apache.commons.lang3.StringUtils;
    2422
    25 public final class DAVProtocol extends AbstractProtocol {
     23public class DAVProtocol extends AbstractProtocol {
    2624    @Override
    2725    public String getName() {
  • shelves/02.06.2017/webdav/src/main/java/ch/cyberduck/core/dav/DAVSSLProtocol.java

    r41291 r41298  
    2323import org.apache.commons.lang3.StringUtils;
    2424
    25 public final class DAVSSLProtocol extends AbstractProtocol {
     25public class DAVSSLProtocol extends AbstractProtocol {
    2626    @Override
    2727    public String getName() {
  • shelves/02.06.2017/webdav/src/test/java/ch/cyberduck/core/HostParserTest.java

    r35652 r41298  
    1616    @Test
    1717    public void testParseURLEmpty() {
    18         Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol()).get("");
     18        Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol()).get("");
    1919        assertTrue(h.getHostname().equals(PreferencesFactory.get().getProperty("connection.hostname.default")));
    2020    }
     
    2222    @Test
    2323    public void testParseHostnameOnly() {
    24         final HostParser parser = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol());
     24        final HostParser parser = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol());
    2525        assertEquals("hostname", parser.get("hostname").getHostname());
    2626        assertEquals("hostname", parser.get("hostname ").getHostname());
     
    3030    @Test
    3131    public void testParseHostnameOnlyRemoveTrailingSlash() {
    32         final HostParser parser = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol());
     32        final HostParser parser = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol());
    3333        assertEquals("hostname", parser.get("hostname/").getHostname());
    3434        assertEquals("hostname", parser.get("hostname//").getHostname());
     
    3838    @Test
    3939    public void testHostnameAppendPort() {
    40         final HostParser parser = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol());
     40        final HostParser parser = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol());
    4141        assertEquals("s3.amazonaws.com", parser.get("s3.amazonaws.com:443").getHostname());
    4242        assertEquals("s3.amazonaws.com", parser.get("s3.amazonaws.com:443/").getHostname());
     
    4848    public void testParseHttp() {
    4949        String url = "http://www.testrumpus.com/";
    50         Host h = new HostParser(new ProtocolFactory(Collections.singleton(new DAVProtocol()))).get(url);
     50        Host h = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVProtocol()))).get(url);
    5151        assertEquals("www.testrumpus.com", h.getHostname());
    52         assertEquals(new DAVProtocol(), h.getProtocol());
     52        assertEquals(new TestDAVProtocol(), h.getProtocol());
    5353        assertNotNull(h.getCredentials().getUsername());
    5454        assertEquals("/", h.getDefaultPath());
     
    5858    public void testParseNoProtocolAndCustomPath() {
    5959        String url = "user@hostname/path/to/file";
    60         Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol()).get(url);
     60        Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol()).get(url);
    6161        assertEquals("hostname", h.getHostname());
    6262        assertNotNull(h.getCredentials().getUsername());
     
    6969    public void testParseNoProtocol() {
    7070        String url = "user@hostname";
    71         Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol()).get(url);
     71        Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol()).get(url);
    7272        assertEquals("hostname", h.getHostname());
    7373        assertNotNull(h.getCredentials().getUsername());
     
    7979    public void testParseWithTwoAtSymbol() {
    8080        String url = "user@name@hostname";
    81         Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol()).get(url);
     81        Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol()).get(url);
    8282        assertEquals("hostname", h.getHostname());
    8383        assertNotNull(h.getCredentials().getUsername());
     
    8989    public void testParseWithTwoAtSymbolAndPassword() {
    9090        String url = "user@name:password@hostname";
    91         Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol()).get(url);
     91        Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol()).get(url);
    9292        assertEquals("hostname", h.getHostname());
    9393        assertNotNull(h.getCredentials().getUsername());
     
    9999    public void testParseWithDefaultPath() {
    100100        String url = "user@hostname/path/to/file";
    101         Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol()).get(url);
     101        Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol()).get(url);
    102102        assertEquals("/path/to/file", h.getDefaultPath());
    103103    }
     
    106106    public void testParseWithDefaultPathAndCustomPort() {
    107107        String url = "user@hostname:999/path/to/file";
    108         Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new DAVProtocol()).get(url);
     108        Host h = new HostParser(new ProtocolFactory(new HashSet<Protocol>()), new TestDAVProtocol()).get(url);
    109109        assertEquals("/path/to/file", h.getDefaultPath());
    110110    }
     
    112112    @Test
    113113    public void testParseDefaultPathWithAtSign() {
    114         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new DAVSSLProtocol()))).get("https://mail.sgbio.com/dav/YourEmail@sgbio.com/Briefcase");
     114        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVSSLProtocol()))).get("https://mail.sgbio.com/dav/YourEmail@sgbio.com/Briefcase");
    115115        assertEquals("mail.sgbio.com", host.getHostname());
    116116        assertEquals(new DAVSSLProtocol(), host.getProtocol());
     
    122122    @Test
    123123    public void testParseUsernameDefaultPathWithAtSign() {
    124         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new DAVSSLProtocol()))).get("https://u@mail.sgbio.com/dav/YourEmail@sgbio.com/Briefcase");
     124        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVSSLProtocol()))).get("https://u@mail.sgbio.com/dav/YourEmail@sgbio.com/Briefcase");
    125125        assertEquals("mail.sgbio.com", host.getHostname());
    126         assertEquals(new DAVSSLProtocol(), host.getProtocol());
     126        assertEquals(new TestDAVSSLProtocol(), host.getProtocol());
    127127        assertEquals(Scheme.https, host.getProtocol().getScheme());
    128128        assertEquals("/dav/YourEmail@sgbio.com/Briefcase", host.getDefaultPath());
     
    132132    @Test
    133133    public void testParseUsernamePasswordDefaultPathWithAtSign() {
    134         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new DAVSSLProtocol()))).get("https://u:p@mail.sgbio.com/dav/YourEmail@sgbio.com/Briefcase");
     134        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVSSLProtocol()))).get("https://u:p@mail.sgbio.com/dav/YourEmail@sgbio.com/Briefcase");
    135135        assertEquals("mail.sgbio.com", host.getHostname());
    136         assertEquals(new DAVSSLProtocol(), host.getProtocol());
     136        assertEquals(new TestDAVSSLProtocol(), host.getProtocol());
    137137        assertEquals(Scheme.https, host.getProtocol().getScheme());
    138138        assertEquals("/dav/YourEmail@sgbio.com/Briefcase", host.getDefaultPath());
     
    143143    @Test
    144144    public void testParseColonInPath() {
    145         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new DAVProtocol()))).get("http://cdn.duck.sh/duck-4.6.2.16174:16179M.pkg");
     145        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVProtocol()))).get("http://cdn.duck.sh/duck-4.6.2.16174:16179M.pkg");
    146146        assertEquals(80, host.getPort());
    147147        assertEquals("/duck-4.6.2.16174:16179M.pkg", host.getDefaultPath());
     
    150150    @Test
    151151    public void testParseColonInPathPlusPort() {
    152         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new DAVProtocol()))).get("http://cdn.duck.sh:444/duck-4.6.2.16174:16179M.pkg");
     152        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVProtocol()))).get("http://cdn.duck.sh:444/duck-4.6.2.16174:16179M.pkg");
    153153        assertEquals(444, host.getPort());
    154154        assertEquals("/duck-4.6.2.16174:16179M.pkg", host.getDefaultPath());
     
    157157    @Test
    158158    public void testInvalidPortnumber() {
    159         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new DAVProtocol()))).get("http://hostname:21a");
     159        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVProtocol()))).get("http://hostname:21a");
    160160        assertEquals("hostname", host.getHostname());
    161161        assertEquals(80, host.getPort());
     
    164164    @Test
    165165    public void testMissingPortNumber() {
    166         final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new DAVProtocol()))).get("http://hostname:~/sandbox");
     166        final Host host = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVProtocol()))).get("http://hostname:~/sandbox");
    167167        assertEquals("hostname", host.getHostname());
    168168        assertEquals(80, host.getPort());
     
    172172    @Test
    173173    public void testParseIpv6() throws Exception {
    174         final HostParser parser = new HostParser(new ProtocolFactory(Collections.singleton(new DAVProtocol())));
     174        final HostParser parser = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVProtocol())));
    175175        assertEquals("fc01:2:3:4:5::1", parser.get("http://fc01:2:3:4:5::1/~/sandbox").getHostname());
    176176        assertEquals(80, parser.get("http://fc01:2:3:4:5::1/~/sandbox").getPort());
     
    187187    @Test
    188188    public void testParseIpv6LinkLocalZoneIndex() throws Exception {
    189         final HostParser parser = new HostParser(new ProtocolFactory(Collections.singleton(new DAVProtocol())));
     189        final HostParser parser = new HostParser(new ProtocolFactory(Collections.singleton(new TestDAVProtocol())));
    190190        assertEquals("fe80::c62c:3ff:fe0b:8670%en0", parser.get("http://fe80::c62c:3ff:fe0b:8670%en0/~/sandbox").getHostname());
    191191    }
     192
     193    private static class TestDAVProtocol extends DAVProtocol {
     194        @Override
     195        public boolean isEnabled() {
     196            return true;
     197        }
     198    }
     199
     200    private static class TestDAVSSLProtocol extends DAVSSLProtocol {
     201        @Override
     202        public boolean isEnabled() {
     203            return true;
     204        }
     205    }
    192206}
Note: See TracChangeset for help on using the changeset viewer.
swiss made software