mockftp serverfake FakeFtpServer; comprobar si se llama a la función

I want to test my function indexFolder(...) that is responsible of retrieving files from a FTP. File has to be more recent than the local version to be download.

    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);
    }
}

I want to know if the library

import org.mockftpserver.fake.FakeFtpServer;

can generate fake FTP file to permit me to count the amount of time the function indexFile(...) is called. with something like

verify(ftpFolderTest,times(1)).indexFile(file, localFolder);

preguntado el 01 de febrero de 12 a las 14:02

I suspect you may get more help from the MockFtpServer discussion forum. I strongly recommend that you post both of your questions there. -

0 Respuestas

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.