@Override
    protected FTPClient connect(final ProxyFinder proxy, final HostKeyCallback callback, final LoginCallback prompt, final CancelCallback cancel) throws BackgroundException {
        try {
            final CustomTrustSSLProtocolSocketFactory f
                    = new CustomTrustSSLProtocolSocketFactory(trust, key, preferences.getProperty("connection.ssl.protocols.ftp").split(","));

            final LoggingProtocolCommandListener listener = new LoggingProtocolCommandListener(this);
            final FTPClient client = new FTPClient(host.getProtocol(), f, f.getSSLContext()) {
                @Override
                public void disconnect() throws IOException {
                    try {
                        super.disconnect();
                    }
                    finally {
                        this.removeProtocolCommandListener(listener);
                    }
                }
            };
            client.addProtocolCommandListener(listener);
            this.configure(client);
            client.connect(new PunycodeConverter().convert(host.getHostname()), host.getPort());
            client.setTcpNoDelay(false);
            return client;
        }
        catch(IOException e) {
            throw new FTPExceptionMappingService().map(e);
        }
    }
@Test
    public void testConnect() throws Exception {
        final Path path = new FTPWorkdirService(session).find();
        assertNotNull(path);
        assertEquals(path, new FTPWorkdirService(session).find());
        assertTrue(session.isConnected());
    }