Hi,
I have the following code in a JUnit test:
public void testUploadFtp() {
FtpWrapper ftp = null;
try {
ftp = new FtpWrapper(path);
ftp.connectAndLogin(serverName, userName, password);
logger.info("Conectado " + serverName);
String contenido = "contenido";
ftp.uploadFile(contenido, "ficherin.txt");
ftp.disconnect();
} catch(Exception e) {
logger.error(e);
fail(e.getMessage());
}
}
The FtpWrapper class is a subclass of com.enterprisedt.net.ftp.FTPClient. Its code is:
public class FtpWrapper extends FTPClient{
private static Logger logger = Logger.getLogger(FtpWrapper.class);
private String path = null;
public FtpWrapper(String path) throws IOException, FTPException {
super();
this.path = path;
}
public boolean connectAndLogin (String host, String userName, String password)
throws IOException, FTPException {
boolean success = false;
logger.info("Initializing connection.");
setRemoteHost(host);
connect();
login(userName, password);
if(!connected()){
disconnect();
}
return success;
}
public void uploadFile (String content, String serverFile)
throws IOException, FTPException {
logger.info("Transfer file "+serverFile);
if(path!=null){
logger.info("To path "+ chdir(path);
}
put(content.getBytes(), serverFile);
}
public void disconnect() throws IOException, FTPException {
logger.info("Disconnecting...");
quit();
}
}
The error I get is this:
0 [main] INFO - Inicializando par