开发者

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

开发者 https://www.devze.com 2023-01-20 06:58 出处:网络
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 setti

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

精彩评论

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

关注公众号