Package org.citrusframework.ftp.client
Class FtpClient
java.lang.Object
org.citrusframework.endpoint.AbstractEndpoint
org.citrusframework.ftp.client.FtpClient
- All Implemented Interfaces:
InitializingPhase,Named,ShutdownPhase,Endpoint,org.citrusframework.messaging.Consumer,org.citrusframework.messaging.Producer,org.citrusframework.messaging.ReplyConsumer,org.citrusframework.messaging.SelectiveConsumer
- Direct Known Subclasses:
SftpClient
public class FtpClient
extends AbstractEndpoint
implements org.citrusframework.messaging.Producer, org.citrusframework.messaging.ReplyConsumer, InitializingPhase, ShutdownPhase
- Since:
- 2.7.5
- Author:
- Christoph Deppisch
-
Constructor Summary
ConstructorsModifierConstructorDescriptionDefault constructor initializing endpoint configuration.protectedFtpClient(FtpEndpointConfiguration endpointConfiguration) Default constructor using endpoint configuration. -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 voidOpens a new connection and performs login with user name and password if set.org.citrusframework.messaging.SelectiveConsumerCreates a message consumer for this endpoint.org.citrusframework.messaging.ProducerCreates a message producer for this endpoint for sending messages to this endpoint.protected FtpMessagedeleteFile(DeleteCommand delete, TestContext context) Performs delete file operation.voiddestroy()protected FtpMessageexecuteCommand(CommandType ftpCommand, TestContext context) org.apache.commons.net.ftp.FTPClientGets the apache ftp client.protected InputStreamgetLocalFileInputStream(String path, String dataType, TestContext context) Constructs local file input stream.voidprotected booleanisDirectory(String remoteFilePath) Check file path type directory or file.protected FtpMessagelistFiles(ListCommand list, TestContext context) Perform list files operation and provide file information as response.receive(String selector, TestContext context) receive(String selector, TestContext context, long timeout) receive(TestContext context) receive(TestContext context, long timeout) protected FtpMessageretrieveFile(GetCommand command, TestContext context) Performs retrieve file operation.voidsend(Message message, TestContext context) voidsetCorrelationManager(CorrelationManager<Message> correlationManager) Sets the correlation manager.voidsetFtpClient(org.apache.commons.net.ftp.FTPClient ftpClient) Sets the apache ftp client.protected FtpMessagestoreFile(PutCommand command, TestContext context) Performs store file operation.Methods inherited from class org.citrusframework.endpoint.AbstractEndpoint
getActor, getConsumerName, getName, getProducerName, setActor, setNameMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.citrusframework.messaging.Consumer
getNameMethods inherited from interface org.citrusframework.messaging.Producer
getName
-
Constructor Details
-
FtpClient
public FtpClient()Default constructor initializing endpoint configuration. -
FtpClient
Default constructor using endpoint configuration.- Parameters:
endpointConfiguration-
-
-
Method Details
-
getEndpointConfiguration
- Specified by:
getEndpointConfigurationin interfaceEndpoint- Overrides:
getEndpointConfigurationin classAbstractEndpoint
-
send
- Specified by:
sendin interfaceorg.citrusframework.messaging.Producer
-
executeCommand
-
listFiles
Perform list files operation and provide file information as response.- Parameters:
list-context-- Returns:
-
deleteFile
Performs delete file operation.- Parameters:
delete-context-
-
isDirectory
Check file path type directory or file.- Parameters:
remoteFilePath-- Returns:
- Throws:
IOException
-
storeFile
Performs store file operation.- Parameters:
command-context-
-
getLocalFileInputStream
protected InputStream getLocalFileInputStream(String path, String dataType, 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
Performs retrieve file operation.- Parameters:
command-
-
addFileNameToTargetPath
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 anythingExample:
sourcePath="/some/dir/file.pdf"
targetPath="/other/dir/"
returns: "/other/dir/file.pdf" -
connectAndLogin
Opens a new connection and performs login with user name and password if set.- Throws:
IOException
-
receive
- Specified by:
receivein interfaceorg.citrusframework.messaging.Consumer
-
receive
- Specified by:
receivein interfaceorg.citrusframework.messaging.SelectiveConsumer
-
receive
- Specified by:
receivein interfaceorg.citrusframework.messaging.Consumer
-
receive
- Specified by:
receivein interfaceorg.citrusframework.messaging.SelectiveConsumer
-
initialize
public void initialize()- Specified by:
initializein interfaceInitializingPhase
-
destroy
public void destroy()- Specified by:
destroyin interfaceShutdownPhase
-
createProducer
public org.citrusframework.messaging.Producer createProducer()Creates a message producer for this endpoint for sending messages to this endpoint.- Specified by:
createProducerin interfaceEndpoint
-
createConsumer
public org.citrusframework.messaging.SelectiveConsumer createConsumer()Creates a message consumer for this endpoint. Consumer receives messages on this endpoint.- Specified by:
createConsumerin interfaceEndpoint- 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
Sets the correlation manager.- Parameters:
correlationManager-
-