I wrote a Java class in which one try to access to a FTP.
I work on Eclipse and I want to make a Junit test on that. I know how to test public classes but I'm stuck at testing a static void main method.
Here is my ftp.java class :
public class ftp {
public static void main(String[] args) {
FTPClient client = new FTPClient();
try {
client.connect("host");
// Try to login and return the respective boolean value
boolean login = client.login("login", "pass");
// If login is true notify user
if (login) {
System.out.println("Connection established...");
// Try to logout and return the respective boolean value
boolean logout = client.logout();
// If logout is true notify user
if (logout) {
System.out.println("Connection close...");
}
// Notify user for failure
} else {
System.out.println("Connection fail...");
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
// close connection
client.disconnect();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
I began to create the ftpTest.java like that :
public class ftpTest {
ftp testaccess = new ftp();
FTPClient testclient = ftp.client;
@Test
public void testftp() {
fail("Not yet implemented");
}
}
Any help would be very appreciated.
Thanks !