Package com.consol.citrus.ftp.client
Class FtpClient
- java.lang.Object
-
- com.consol.citrus.endpoint.AbstractEndpoint
-
- com.consol.citrus.ftp.client.FtpClient
-
- All Implemented Interfaces:
com.consol.citrus.common.InitializingPhase,com.consol.citrus.common.Named,com.consol.citrus.common.ShutdownPhase,com.consol.citrus.endpoint.Endpoint,com.consol.citrus.messaging.Consumer,com.consol.citrus.messaging.Producer,com.consol.citrus.messaging.ReplyConsumer,com.consol.citrus.messaging.SelectiveConsumer
- Direct Known Subclasses:
SftpClient
public class FtpClient extends com.consol.citrus.endpoint.AbstractEndpoint implements com.consol.citrus.messaging.Producer, com.consol.citrus.messaging.ReplyConsumer, com.consol.citrus.common.InitializingPhase, com.consol.citrus.common.ShutdownPhase- Since:
- 2.7.5
- Author:
- Christoph Deppisch
-
-
Constructor Summary
Constructors Modifier Constructor Description FtpClient()Default constructor initializing endpoint configuration.protectedFtpClient(FtpEndpointConfiguration endpointConfiguration)Default constructor using endpoint configuration.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static StringaddFileNameToTargetPath(String sourcePath, String targetPath)If the target path is a directory (ends with "/"), add the file name from the source path to the target path.protected voidconnectAndLogin()Opens a new connection and performs login with user name and password if set.com.consol.citrus.messaging.SelectiveConsumercreateConsumer()Creates a message consumer for this endpoint.com.consol.citrus.messaging.ProducercreateProducer()Creates a message producer for this endpoint for sending messages to this endpoint.protected FtpMessagedeleteFile(DeleteCommand delete, com.consol.citrus.context.TestContext context)Performs delete file operation.voiddestroy()protected FtpMessageexecuteCommand(CommandType ftpCommand, com.consol.citrus.context.TestContext context)FtpEndpointConfigurationgetEndpointConfiguration()org.apache.commons.net.ftp.FTPClientgetFtpClient()Gets the apache ftp client.protected InputStreamgetLocalFileInputStream(String path, String dataType, com.consol.citrus.context.TestContext context)Constructs local file input stream.voidinitialize()protected booleanisDirectory(String remoteFilePath)Check file path type directory or file.protected FtpMessagelistFiles(ListCommand list, com.consol.citrus.context.TestContext context)Perform list files operation and provide file information as response.com.consol.citrus.message.Messagereceive(com.consol.citrus.context.TestContext context)com.consol.citrus.message.Messagereceive(com.consol.citrus.context.TestContext context, long timeout)com.consol.citrus.message.Messagereceive(String selector, com.consol.citrus.context.TestContext context)com.consol.citrus.message.Messagereceive(String selector, com.consol.citrus.context.TestContext context, long timeout)protected FtpMessageretrieveFile(GetCommand command, com.consol.citrus.context.TestContext context)Performs retrieve file operation.voidsend(com.consol.citrus.message.Message message, com.consol.citrus.context.TestContext context)voidsetCorrelationManager(com.consol.citrus.message.correlation.CorrelationManager<com.consol.citrus.message.Message> correlationManager)Sets the correlation manager.voidsetFtpClient(org.apache.commons.net.ftp.FTPClient ftpClient)Sets the apache ftp client.protected FtpMessagestoreFile(PutCommand command, com.consol.citrus.context.TestContext context)Performs store file operation.-
Methods inherited from class com.consol.citrus.endpoint.AbstractEndpoint
getActor, getConsumerName, getName, getProducerName, setActor, setName
-
-
-
-
Constructor Detail
-
FtpClient
public FtpClient()
Default constructor initializing endpoint configuration.
-
FtpClient
protected FtpClient(FtpEndpointConfiguration endpointConfiguration)
Default constructor using endpoint configuration.- Parameters:
endpointConfiguration-
-
-
Method Detail
-
getEndpointConfiguration
public FtpEndpointConfiguration getEndpointConfiguration()
- Specified by:
getEndpointConfigurationin interfacecom.consol.citrus.endpoint.Endpoint- Overrides:
getEndpointConfigurationin classcom.consol.citrus.endpoint.AbstractEndpoint
-
send
public void send(com.consol.citrus.message.Message message, com.consol.citrus.context.TestContext context)- Specified by:
sendin interfacecom.consol.citrus.messaging.Producer
-
executeCommand
protected FtpMessage executeCommand(CommandType ftpCommand, com.consol.citrus.context.TestContext context)
-
listFiles
protected FtpMessage listFiles(ListCommand list, com.consol.citrus.context.TestContext context)
Perform list files operation and provide file information as response.- Parameters:
list-context-- Returns:
-
deleteFile
protected FtpMessage deleteFile(DeleteCommand delete, com.consol.citrus.context.TestContext context)
Performs delete file operation.- Parameters:
delete-context-
-
isDirectory
protected boolean isDirectory(String remoteFilePath) throws IOException
Check file path type directory or file.- Parameters:
remoteFilePath-- Returns:
- Throws:
IOException
-
storeFile
protected FtpMessage storeFile(PutCommand command, com.consol.citrus.context.TestContext context)
Performs store file operation.- Parameters:
command-context-
-
getLocalFileInputStream
protected InputStream getLocalFileInputStream(String path, String dataType, com.consol.citrus.context.TestContext context) throws IOException
Constructs local file input stream. When using ASCII data type the test variable replacement is activated otherwise plain byte stream is used.- Parameters:
path-dataType-context-- Returns:
- Throws:
IOException
-
retrieveFile
protected FtpMessage retrieveFile(GetCommand command, com.consol.citrus.context.TestContext context)
Performs retrieve file operation.- Parameters:
command-
-
addFileNameToTargetPath
protected static String addFileNameToTargetPath(String sourcePath, String targetPath)
If the target path is a directory (ends with "/"), add the file name from the source path to the target path. Otherwise, don't do anything Example:sourcePath="/some/dir/file.pdf"
targetPath="/other/dir/"
returns: "/other/dir/file.pdf"
-
connectAndLogin
protected void connectAndLogin() throws IOExceptionOpens a new connection and performs login with user name and password if set.- Throws:
IOException
-
receive
public com.consol.citrus.message.Message receive(com.consol.citrus.context.TestContext context)
- Specified by:
receivein interfacecom.consol.citrus.messaging.Consumer
-
receive
public com.consol.citrus.message.Message receive(String selector, com.consol.citrus.context.TestContext context)
- Specified by:
receivein interfacecom.consol.citrus.messaging.SelectiveConsumer
-
receive
public com.consol.citrus.message.Message receive(com.consol.citrus.context.TestContext context, long timeout)- Specified by:
receivein interfacecom.consol.citrus.messaging.Consumer
-
receive
public com.consol.citrus.message.Message receive(String selector, com.consol.citrus.context.TestContext context, long timeout)
- Specified by:
receivein interfacecom.consol.citrus.messaging.SelectiveConsumer
-
initialize
public void initialize()
- Specified by:
initializein interfacecom.consol.citrus.common.InitializingPhase
-
destroy
public void destroy()
- Specified by:
destroyin interfacecom.consol.citrus.common.ShutdownPhase
-
createProducer
public com.consol.citrus.messaging.Producer createProducer()
Creates a message producer for this endpoint for sending messages to this endpoint.- Specified by:
createProducerin interfacecom.consol.citrus.endpoint.Endpoint
-
createConsumer
public com.consol.citrus.messaging.SelectiveConsumer createConsumer()
Creates a message consumer for this endpoint. Consumer receives messages on this endpoint.- Specified by:
createConsumerin interfacecom.consol.citrus.endpoint.Endpoint- Returns:
-
setFtpClient
public void setFtpClient(org.apache.commons.net.ftp.FTPClient ftpClient)
Sets the apache ftp client.- Parameters:
ftpClient-
-
getFtpClient
public org.apache.commons.net.ftp.FTPClient getFtpClient()
Gets the apache ftp client.- Returns:
-
setCorrelationManager
public void setCorrelationManager(com.consol.citrus.message.correlation.CorrelationManager<com.consol.citrus.message.Message> correlationManager)
Sets the correlation manager.- Parameters:
correlationManager-
-
-