I have a failure in my JUnit testing testing trace.
The error is java.lang.NullPointerException and it occurs into these line of code:
@AfterClass
public static void after()
{
stopServer();
}
and
static void stopServer()
{
ftp.stop();
}
What I want to do is to have my @AfterClass to stop my fakeFTPServer, initiate into the @BeforeClass
@BeforeClass
public static void before()
{
FakeFtpServer ftp = new FakeFtpServer();
ftp.addUserAccount(new UserAccount("user", "password", "c:\\data"));
FileSystem fileSystem = new WindowsFakeFileSystem();
fileSystem.add(new DirectoryEntry("c:\\data"));
fileSystem.add(new FileEntry("c:\\data\\file1.txt", "abcdef 1234567890"));
fileSystem.add(new FileEntry("c:\\data\\run.exe"));
ftp.setFileSystem(fileSystem);
ftp.start();
ftpClient = new FTPClient();}
Thanks for your help!
It looks like you have more than one variable named
ftp.This is one of them:
This
ftpis local tobefore()and therefore can’t be the variable referenced instopServer(). The latter must be using a different variable namedftp, which nevers get initialized. At a guess, that otherftpis a static member of your class.I suspect the above line was meant to read: