开发者

How to test file transfer restarting code [setRestartOffset(offset) in Commons NET API]?

I wrote small FTP Client Applet which uploads files to FTP Server u开发者_JS百科sing Commons Net API. In my code I handled 'CopyStreamException' and trying to restart the same file transfer by setting the offset using FTPClient.setRestartOffset() method.

Is there any proper way to test this part of the code?

I tried by disconnecting my internet connection and the the applet did restarted the same file transfer with proper offset but the server gave a 550 reply with description 'The process cannot access the file because it is being used by another process.'!!!

Any help is appreciated

Thanks.


You could install something like FileZilla Server locally and use that to test against. You then have much greater control over testing various scenarios to do with the destination server (e.g. Losing a connection, not having permission to write, wrong default home dir etc). It's how we test our FTP client anyhow :).

Alternatively you can start looking at mocking aspects (using JMock/Mockito/EasyMock/your own substitute component) of the server (not easy to do) which can then throw the Exception that you want at your leisure.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜