Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO

how to use retry? an example test?

0 votes
asked Jan 13 in Java FTP by jwilcox (120 points)
It appears as though all I need to do is setRetryCount(>0) and setRetryDelay() and retry should be enabled? But I am trying to create a test in our code to ensure a delete is being retried without success thus far.

1) Please confirm how to enable retry

2) Please include an example how to test retrying a file transfer

Here I am simply trying to see RETRY_COUNT=3 retries take place RETRY_DELAY=5000 ms apart. The test passes without my setting the command handler, after setting the command handler I do not see any retries occur, just one failure. Is this expected?

    public void retry() throws FTPException, IOException {

        //can use RETR for a get() STOR for a put() DELE for del()
        // Fail on DELE command.
        final int REPLY_CODE = 425; //Can't open data connection - 4xx can be retried
        RetrCommandHandler retrCommandHandler = new RetrCommandHandler();
        fakeFtpServer.setCommandHandler(CommandNames.RETR, retrCommandHandler);

        FtpClient ftpClient = connectToServer();



    private FtpClient connectToServer() throws FTPException, IOException {
        DgFtpClientFactory dgFtpClientFactory = new DgFtpClientFactoryImpl();

        FtpClient ftpClient = dgFtpClientFactory.getDgFtpClient();




        ftpClient.login(USER, PASSWORD);

        return ftpClient;
commented Jan 13 by jwilcox (120 points)
I actually am testing a get not a delete but said I was testing delete, sorry.
commented Jan 13 by support2 (141,250 points)
Retry only occurs when there's a network failure during the transfer, i.e. when an IOException is thrown.

Please log in or register to answer this question.