Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Ftp test help

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm in the process of writing a test for a class that downloads a file using ftp and then does some processing on the information in the file after it's been downloaded. My problem is this: how do I test the method that does the actual ftp download? Do I download the file using a completely different method, say the command line, then when I download the file through the code generate a hash for both files and check for equality? I don't have a lot of experience using JUnit, but I'm trying to learn. I can figure out how to test the rest, I just haven't been able to devise a way to test the actual ftp process.

Thanks,
akempo
 
author & internet detective
Posts: 40169
812
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alex,
The best way is to unit test everything else using a mock FTP. EasyMock and JMock are frameworks that help you create these pretend objects.

Once you know everything else is working, you can write an integration or end to end test that actually does the FTP. That way your main unit tests are repeatable and independent of the network, but you are still testing the FTP part for "real."
 
Alex Belt
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks. I had figured out to separate the other tests from the ftp process, but I ran into a wall trying to figure out how to test the ftp. Fortunately, all the ftp code is already isolated to a single method so I won't have to use a mock framework for the other methods, as the only method that calls the ftp method is the class controller method.

Thank you,
akempo
 
    Bookmark Topic Watch Topic
  • New Topic