I tried to learn a mocking framework for testing with JUnit. EasyMock seems to be a good one, but I keep having problems with it. I am attaching the code as follows:
Basically, verify in tearDown cannot catch that stream.close() not being called, while it is supposed to be because "stream.close()" is specified before replay(stream) in testGetContentOk. Any idea is greatly appreciated.
I used EasyMock pre-Java 5. Some collegues used jMock which was more powerful, but I didn't want my project to be using 2 mock frameworks and people have to switch back and forth. I did use jMock on JavaRanch proejcts and liked it better. It was easier to control and more powerful.
When we migrated to Java 5, there was an opportunity to change to something different. (easyMock and jMock both changed a lot with Java 5.) I took that as an opportunity to switch to jMock. EasyMock is a lot better now, but I still like the matchers in jMock more.