return (FtpEndpointConfiguration) super.getEndpointConfiguration();
}
@Override
public void send(Message message, TestContext context) {
FtpMessage ftpMessage;
if (message instanceof FtpMessage) {
ftpMessage = (FtpMessage) message;
} else {
ftpMessage = new FtpMessage(message);
}
String correlationKey = getEndpointConfiguration().getCorrelator().getCorrelationKey(ftpMessage);
context.saveCorrelationKey(correlationKey, this);
log.info(String.format("Sending FTP message to: ftp://'%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()));
if (log.isDebugEnabled()) {
log.debug("Message to be sent:\n" + ftpMessage.getPayload().toString());
}
try {
connectAndLogin();
int reply = ftpClient.sendCommand(ftpMessage.getCommand(), ftpMessage.getArguments());
if(!FTPReply.isPositiveCompletion(reply) && !FTPReply.isPositivePreliminary(reply)) {
throw new CitrusRuntimeException(String.format("Failed to send FTP command - reply is: %s:%s", reply, ftpClient.getReplyString()));
}
log.info(String.format("FTP message was successfully sent to: '%s:%s'", getEndpointConfiguration().getHost(), getEndpointConfiguration().getPort()));
onReplyMessage(correlationKey, new FtpMessage(ftpMessage.getCommand(), ftpMessage.getArguments())
.setReplyCode(reply)
.setReplyString(ftpClient.getReplyString()));
} catch (IOException e) {
throw new CitrusRuntimeException("Failed to execute ftp command", e);
}