Search in sources :

Example 21 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FtpConnectionTest method testConnect_WithAccount.

@Test
public void testConnect_WithAccount() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    FtpConnectionImp connection = createConnection();
    connection.setDefaultAccount(getName());
    try {
        start(connection);
        FileTransferClient client = connection.connect(getDestinationString());
    } finally {
        stop(connection);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) Test(org.junit.Test)

Example 22 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FtpCase method tearDown.

@After
public void tearDown() throws Exception {
    if (areTestsEnabled()) {
        FileTransferClient client = connectRawClient();
        cleanup(client, getRemoteDirectory() + DEFAULT_WORK_DIR);
        cleanup(client, getRemoteDirectory() + DEFAULT_BUILD_DIR);
        client.disconnect();
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) After(org.junit.After)

Example 23 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FtpConnectionCase method testCachedConnection_ExceedsMaxSize.

@Test
public void testCachedConnection_ExceedsMaxSize() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    FileTransferConnection connection = createConnection();
    connection.setCacheConnection(true);
    connection.setMaxClientCache(1);
    try {
        start(connection);
        FileTransferClient client = connection.connect(getDestinationString());
        // Should be cached, and equivalent.
        FileTransferClient cached = connection.connect(getDestinationString());
        assertEquals(client, cached);
        FileTransferClient client2 = connection.connect(getDestinationStringWithOverride());
        // This should have emptied the cache (and disconnected client1)...
        cached = connection.connect(getDestinationString());
        assertNotSame(client, cached);
        assertFalse(client.isConnected());
    } finally {
        stop(connection);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) Test(org.junit.Test)

Example 24 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FtpConnectionCase method testConnection_NoCache_Disconnect.

@Test
public void testConnection_NoCache_Disconnect() throws Exception {
    Assume.assumeTrue(areTestsEnabled());
    FileTransferConnection connection = createConnection();
    connection.setCacheConnection(false);
    try {
        start(connection);
        FileTransferClient client = null;
        client = connection.connect(getDestinationString());
        connection.disconnect(client);
        assertFalse(client.isConnected());
    } finally {
        stop(connection);
    }
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) Test(org.junit.Test)

Example 25 with FileTransferClient

use of com.adaptris.filetransfer.FileTransferClient in project interlok by adaptris.

the class FileTransferConnection method create.

private FileTransferClient create(String hostUrl) throws FileTransferException, IOException, PasswordException {
    String remoteHost = hostUrl;
    UserInfo ui = createUserInfo();
    int port = defaultControlPort();
    try {
        URI uri = new URI(hostUrl);
        if (acceptProtocol(uri.getScheme())) {
            remoteHost = uri.getHost();
            port = uri.getPort() != -1 ? uri.getPort() : defaultControlPort();
            ui.parse(uri.getRawUserInfo());
        }
    } catch (URISyntaxException e) {
        ;
    }
    FileTransferClient client = create(remoteHost, port, ui);
    return client;
}
Also used : FileTransferClient(com.adaptris.filetransfer.FileTransferClient) URISyntaxException(java.net.URISyntaxException) URI(java.net.URI)

Aggregations

FileTransferClient (com.adaptris.filetransfer.FileTransferClient)39 Test (org.junit.Test)30 File (java.io.File)4 IOException (java.io.IOException)4 AdaptrisMessage (com.adaptris.core.AdaptrisMessage)3 PasswordException (com.adaptris.security.exc.PasswordException)3 CoreException (com.adaptris.core.CoreException)2 ProduceException (com.adaptris.core.ProduceException)2 CommonsNetFtpClient (com.adaptris.ftp.CommonsNetFtpClient)2 InputStream (java.io.InputStream)2 ArrayList (java.util.ArrayList)2 Date (java.util.Date)2 After (org.junit.After)2 InputFieldHint (com.adaptris.annotation.InputFieldHint)1 FileNameCreator (com.adaptris.core.FileNameCreator)1 ServiceException (com.adaptris.core.ServiceException)1 FileTransferException (com.adaptris.filetransfer.FileTransferException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Random (java.util.Random)1