FtpClient extends AbstractEndpoint implements Producer, ReplyConsumer, InitializingBean, DisposableBean { protected FtpMessage listFiles(ListCommand list, TestContext context) { String remoteFilePath = Optional.ofNullable(list.getTarget()) .map(ListCommand.Target::getPath) .map(context::replaceDynamicContentInString) .orElse(""); try { List<String> fileNames = new ArrayList<>(); FTPFile[] ftpFiles; if (StringUtils.hasText(remoteFilePath)) { ftpFiles = ftpClient.listFiles(remoteFilePath); } else { ftpFiles = ftpClient.listFiles(remoteFilePath); } for (FTPFile ftpFile : ftpFiles) { fileNames.add(ftpFile.getName()); } return FtpMessage.result(ftpClient.getReplyCode(), ftpClient.getReplyString(), fileNames); } catch (IOException e) { throw new CitrusRuntimeException(String.format("Failed to list files in path '%s'", remoteFilePath), e); } } FtpClient(); protected  FtpClient(FtpEndpointConfiguration endpointConfiguration); @Override FtpEndpointConfiguration getEndpointConfiguration(); @Override void send(Message message, TestContext context); @Override Message receive(TestContext context); @Override Message receive(String selector, TestContext context); @Override Message receive(TestContext context, long timeout); @Override Message receive(String selector, TestContext context, long timeout); @Override void afterPropertiesSet(); @Override void destroy(); @Override Producer createProducer(); @Override SelectiveConsumer createConsumer(); void setFtpClient(FTPClient ftpClient); FTPClient getFtpClient(); void setCorrelationManager(CorrelationManager<Message> correlationManager);  }
@Test public void testListFiles() { assertTrue(fakeFtpServer.getFileSystem().exists(FOLDER)); FtpMessage ftpMessage = ftpClient.listFiles(listCommand(FOLDER + "/file*"), context); verifyMessage(ftpMessage, ListCommandResult.class, CLOSING_DATA_CONNECTION, "Requested file action successful.", Arrays.asList("file1", "file2")); assertTrue(fakeFtpServer.getFileSystem().exists(FOLDER + "/file1")); assertTrue(fakeFtpServer.getFileSystem().exists(FOLDER + "/file2")); }