@Override
    public int compareTo(final Host o) {
        if(protocol.compareTo(o.protocol) < 0) {
            return -1;
        }
        else if(protocol.compareTo(o.protocol) > 0) {
            return 1;
        }
        if(port.compareTo(o.port) < 0) {
            return -1;
        }
        else if(port.compareTo(o.port) > 0) {
            return 1;
        }
        if(hostname.compareTo(o.hostname) < 0) {
            return -1;
        }
        else if(hostname.compareTo(o.hostname) > 0) {
            return 1;
        }
        if(credentials.compareTo(o.credentials) < 0) {
            return -1;
        }
        else if(credentials.compareTo(o.credentials) > 0) {
            return 1;
        }
        return StringUtils.compare(defaultpath, o.defaultpath);
    }
@Test
    public void testCompare() {
        assertEquals(0, new Host(new TestProtocol(Scheme.ftp), "a", 33)
            .compareTo(new Host(new TestProtocol(Scheme.ftp), "a", 33)));
        assertEquals(-1, new Host(new TestProtocol(Scheme.ftp), "a", 22)
            .compareTo(new Host(new TestProtocol(Scheme.ftp), "a", 33)));
        assertEquals(1, new Host(new TestProtocol(Scheme.ftp), "a", 33)
            .compareTo(new Host(new TestProtocol(Scheme.ftp), "a", 22)));

        assertEquals(0, new Host(new TestProtocol(Scheme.sftp), "a", 22, new Credentials("u"))
            .compareTo(new Host(new TestProtocol(Scheme.sftp), "a", 22, new Credentials("u"))));
        assertEquals(-1, new Host(new TestProtocol(Scheme.sftp), "a", 22, new Credentials("u"))
                .compareTo(new Host(new TestProtocol(Scheme.sftp), "a", 22, "/path", new Credentials("u"))));
        assertEquals(-1, new Host(new TestProtocol(Scheme.sftp), "a", 22, new Credentials())
            .compareTo(new Host(new TestProtocol(Scheme.sftp), "a", 22, new Credentials("u"))));
        assertEquals(1, new Host(new TestProtocol(Scheme.sftp), "a", 22, new Credentials("u"))
            .compareTo(new Host(new TestProtocol(Scheme.sftp), "a", 22, new Credentials())));

        assertEquals(0, new Host(new TestProtocol(Scheme.ftp), "a")
            .compareTo((new Host(new TestProtocol(Scheme.ftp), "a"))));
        assertEquals(-1, new Host(new TestProtocol(Scheme.ftp), "a")
            .compareTo((new Host(new TestProtocol(Scheme.ftp), "b"))));
        assertEquals(1, new Host(new TestProtocol(Scheme.ftp), "b")
            .compareTo((new Host(new TestProtocol(Scheme.ftp), "a"))));
    }