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 Details

    • FtpClient

      public FtpClient()
      Default constructor initializing endpoint configuration.
    • FtpClient

      protected FtpClient(FtpEndpointConfiguration endpointConfiguration)
      Default constructor using endpoint configuration.
      Parameters:
      endpointConfiguration -
  • Method Details

    • getEndpointConfiguration

      public FtpEndpointConfiguration getEndpointConfiguration()
      Specified by:
      getEndpointConfiguration in interface Endpoint
      Overrides:
      getEndpointConfiguration in class AbstractEndpoint
    • send

      public void send(Message message, TestContext context)
      Specified by:
      send in interface org.citrusframework.messaging.Producer
    • executeCommand

      protected FtpMessage executeCommand(CommandType ftpCommand, TestContext context)
    • listFiles

      protected FtpMessage listFiles(ListCommand list, TestContext context)
      Perform list files operation and provide file information as response.
      Parameters:
      list -
      context -
      Returns:
    • deleteFile

      protected FtpMessage deleteFile(DeleteCommand delete, 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, TestContext context)
      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

      protected FtpMessage retrieveFile(GetCommand command, 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 IOException
      Opens a new connection and performs login with user name and password if set.
      Throws:
      IOException
    • receive

      public Message receive(TestContext context)
      Specified by:
      receive in interface org.citrusframework.messaging.Consumer
    • receive

      public Message receive(String selector, TestContext context)
      Specified by:
      receive in interface org.citrusframework.messaging.SelectiveConsumer
    • receive

      public Message receive(TestContext context, long timeout)
      Specified by:
      receive in interface org.citrusframework.messaging.Consumer
    • receive

      public Message receive(String selector, TestContext context, long timeout)
      Specified by:
      receive in interface org.citrusframework.messaging.SelectiveConsumer
    • initialize

      public void initialize()
      Specified by:
      initialize in interface InitializingPhase
    • destroy

      public void destroy()
      Specified by:
      destroy in interface ShutdownPhase
    • createProducer

      public org.citrusframework.messaging.Producer createProducer()
      Creates a message producer for this endpoint for sending messages to this endpoint.
      Specified by:
      createProducer in interface Endpoint
    • createConsumer

      public org.citrusframework.messaging.SelectiveConsumer createConsumer()
      Creates a message consumer for this endpoint. Consumer receives messages on this endpoint.
      Specified by:
      createConsumer in interface 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(CorrelationManager<Message> correlationManager)
      Sets the correlation manager.
      Parameters:
      correlationManager -