FtpClient extends AbstractEndpoint implements Producer, ReplyConsumer, InitializingBean, DisposableBean { protected FtpMessage storeFile(PutCommand command, TestContext context) { try { String localFilePath = context.replaceDynamicContentInString(command.getFile().getPath()); String remoteFilePath = addFileNameToTargetPath(localFilePath, context.replaceDynamicContentInString(command.getTarget().getPath())); String dataType = context.replaceDynamicContentInString(Optional.ofNullable(command.getFile().getType()).orElse(DataType.BINARY.name())); try (InputStream localFileInputStream = getLocalFileInputStream(command.getFile().getPath(), dataType, context)) { ftpClient.setFileType(getFileType(dataType)); if (!ftpClient.storeFile(remoteFilePath, localFileInputStream)) { throw new IOException("Failed to put file to FTP server. Remote path: " + remoteFilePath + ". Local file path: " + localFilePath + ". FTP reply: " + ftpClient.getReplyString()); } } } catch (IOException e) { throw new CitrusRuntimeException("Failed to put file to FTP server", e); } return FtpMessage.putResult(ftpClient.getReplyCode(), ftpClient.getReplyString(), isPositive(ftpClient.getReplyCode())); } 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 testStoreFile() throws Exception { assertFalse(fakeFtpServer.getFileSystem().exists("/" + UPLOAD_FILE)); Path uploadFile = Paths.get(targetPath, UPLOAD_FILE); Files.write(uploadFile, "Upload content\n".getBytes()); FtpMessage ftpMessage = ftpClient.storeFile(putCommand(Paths.get(targetPath, UPLOAD_FILE).toString(), "/" + UPLOAD_FILE), context); verifyMessage(ftpMessage, PutCommandResult.class, CLOSING_DATA_CONNECTION, "226 Created file /upload_file."); assertTrue(fakeFtpServer.getFileSystem().exists("/" + UPLOAD_FILE)); fakeFtpServer.getFileSystem().delete("/" + UPLOAD_FILE); }
@Test public void testStoreFileImplicitFilename() throws Exception { assertFalse(fakeFtpServer.getFileSystem().exists("/" + UPLOAD_FILE)); Path uploadFile = Paths.get(targetPath, UPLOAD_FILE); Files.write(uploadFile, "Upload content\n".getBytes()); FtpMessage ftpMessage = ftpClient.storeFile(putCommand(Paths.get(targetPath, UPLOAD_FILE).toString(), "/"), context); verifyMessage(ftpMessage, PutCommandResult.class, CLOSING_DATA_CONNECTION, "226 Created file /upload_file."); assertTrue(fakeFtpServer.getFileSystem().exists("/" + UPLOAD_FILE)); fakeFtpServer.getFileSystem().delete("/" + UPLOAD_FILE); }