Я хочу проверить мою функцию indexFolder (...), которая отвечает за получение файлов с FTP. Файл должен быть более поздней, чем локальная версия для загрузки.
private void indexFolder(FTPClient ftp, FTPFile[] listFiles, File localFolder, FTPFolderAssetSource ftpFolderAssetSource)
{
try
{
for (FTPFile currentFile : listFiles)
{
if (currentFile.isDirectory())
{
if (getAssetSource().getIncludeSubDirectories())
{
ftp.changeWorkingDirectory(currentFile.getName());
File localSubFolder = new File(localFolder.getPath() + "\\" + currentFile.getName());
localSubFolder.mkdir();
indexFolder(ftp, ftp.listFiles(), localSubFolder, assetSource);
ftpCodeGestion(ftp, ftp.getReplyCode());
ftp.cdup();
ftpCodeGestion(ftp, ftp.getReplyCode());
}// if
}// if
else
{
File localFile = new File(localFolder.getPath(), currentFile.getName());
long FTPTimeStamp = currentFile.getTimestamp().getTimeInMillis();
long localTimeStamp = localFile.lastModified();
if (FTPTimeStamp > localTimeStamp)
{
downloadFromFTP(ftp, currentFile, localFile);
indexFile(localFile, localFolder);
}
}// else
}// for
}
catch (SocketException e)
{
connectionSuccess = false;
connectionRetry(ftp);
}
catch (Exception e)
{
e.printStackTrace();
logger.error("Error indexing folder: " + localFolder.getAbsolutePath(), e);
}
}
Я хочу знать, если библиотека
import org.mockftpserver.fake.FakeFtpServer;
может генерировать поддельный файл FTP, чтобы позволить мне подсчитать, сколько раз вызывается функция indexFile (...). с чем-то вроде
verify(ftpFolderTest,times(1)).indexFile(file, localFolder);