views:

12

answers:

1

Hi,

I wrote small FTP Client Applet which uploads files to FTP Server using 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,

Rakesh.A

A: 

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.

karianna