File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Mocking File/OutputStream help

 
Lyane Foly
Greenhorn
Posts: 1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I am testing a function that create a fileOutputStream in the body of the function.
This the simple example I wrote just to show my problem.

Here is my class:

Using EasyMock I test this way



I am getting an assertionError because 2 differents FileOutputStream are getting created. This make sense to me, but I am not sure how to sole this issue.
Any help would be appreciated. Aslo I cannot pass the fileoutputstream to the getFileName() function because that interface is already defined and I can changed it...

Error is here:



Thanks
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 33694
316
Eclipse IDE Java VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Lyane,
Welcome to CodeRanch!

Have you looked into argument matchers? They let you redefine equality in any way you want.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic