org.mule.transport.ftp.server
Class FTPTestClient

java.lang.Object
  extended by org.mule.transport.ftp.server.FTPTestClient

public class FTPTestClient
extends java.lang.Object

Ftp client wrapper for working with an FTP server.


Field Summary
protected  Log logger
           
static int TIMEOUT
           
 
Constructor Summary
FTPTestClient(java.lang.String server, int port, java.lang.String user, java.lang.String password)
           
 
Method Summary
protected  void connect()
          Initiate a connection to the ftp server
 boolean deleteDir(java.lang.String dir)
          Delete a directory
 boolean deleteFile(java.lang.String name)
          Delete a single file.
 boolean dirExists(java.lang.String path)
          Check if a directory exists by trying to go to it
 void disconnect()
          Disconnect the ftp client
 boolean expectFileCount(java.lang.String directory, int count, long timeout)
          Verify that a number of files exist on the ftp server
 boolean fileExists(java.lang.String file)
          Check if a file exists on the ftp server
 java.lang.String[] getFileList(java.lang.String path)
          Get a list of file names in a given directory for admin
 boolean isConnected()
          Check if the ftp client is connected
 boolean makeDir(java.lang.String dir)
          Create a directory
 boolean putFile(java.lang.String fileName, java.lang.String targetDir)
          Upload a file to the ftp server
 void recursiveDelete(java.lang.String path)
          Delete all files and subdirectories.
 boolean testConnection()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected final transient Log logger

TIMEOUT

public static final int TIMEOUT
See Also:
Constant Field Values
Constructor Detail

FTPTestClient

public FTPTestClient(java.lang.String server,
                     int port,
                     java.lang.String user,
                     java.lang.String password)
Method Detail

testConnection

public boolean testConnection()
                       throws java.io.IOException
Throws:
java.io.IOException

getFileList

public java.lang.String[] getFileList(java.lang.String path)
                               throws java.io.IOException
Get a list of file names in a given directory for admin

Returns:
List of files/directories
Throws:
java.io.IOException

makeDir

public boolean makeDir(java.lang.String dir)
                throws java.io.IOException
Create a directory

Parameters:
dir -
Returns:
true if successful, false if not
Throws:
java.io.IOException

deleteDir

public boolean deleteDir(java.lang.String dir)
                  throws java.io.IOException
Delete a directory

Parameters:
dir - The directory to delete
Returns:
true if successful, false if not
Throws:
java.io.IOException

putFile

public boolean putFile(java.lang.String fileName,
                       java.lang.String targetDir)
                throws java.io.IOException
Upload a file to the ftp server

Parameters:
fileName - The file to upload
Returns:
true if successful, false if not
Throws:
java.io.IOException

dirExists

public boolean dirExists(java.lang.String path)
                  throws java.io.IOException
Check if a directory exists by trying to go to it

Parameters:
path - The directory to try
Returns:
True if the directory exists, false if not
Throws:
java.io.IOException

recursiveDelete

public void recursiveDelete(java.lang.String path)
                     throws java.io.IOException
Delete all files and subdirectories. Note: extra slashes are ignored by the ftp server, so I didn't bother to filter them out

Throws:
java.io.IOException

connect

protected void connect()
                throws java.io.IOException
Initiate a connection to the ftp server

Throws:
java.io.IOException

isConnected

public boolean isConnected()
Check if the ftp client is connected

Returns:
true if connected, false if not

disconnect

public void disconnect()
                throws java.io.IOException
Disconnect the ftp client

Throws:
java.io.IOException

fileExists

public boolean fileExists(java.lang.String file)
                   throws java.io.IOException
Check if a file exists on the ftp server

Parameters:
file - The name of the file to check
Returns:
true if file exists, false if not
Throws:
java.io.IOException

deleteFile

public boolean deleteFile(java.lang.String name)
                   throws java.io.IOException
Delete a single file.

Parameters:
name - The file to delete
Returns:
true if successful, false if not
Throws:
java.io.IOException

expectFileCount

public boolean expectFileCount(java.lang.String directory,
                               int count,
                               long timeout)
                        throws java.lang.InterruptedException,
                               java.io.IOException
Verify that a number of files exist on the ftp server

Parameters:
directory - The remote directory to check
timeout - The max time to wait
Returns:
true if the file count matches before the timeout, false if not
Throws:
java.lang.InterruptedException
java.io.IOException


Copyright © 2003-2010 MuleSoft, Inc.. All Rights Reserved.