I have a method that uses setAttribute on the Request object. I need to test that method to see if the attribute set has the right value. I am using EasyMocks and am new to it. I created a mock request object. But I need some help on how to test the method.
Thanks for any help
views:
23answers:
2
A:
I would use Spring MockHttpServletRequest and MockHttpServletResponse classes.
hvgotcodes
2010-07-27 14:53:44
I am not using the Spring framework. I am working on the J2EE legacy framework.
Milee
2010-07-27 14:57:44
then Peter Torok's answer is the way to go.
hvgotcodes
2010-07-27 15:12:40
+1
A:
Once you created the mock object, you can simply set it up by calling specific methods on it with the expected values. If it needs to return values, you use EasyMock.expect(...)
to configure those. Once you are ready, you call EasyMock.replay(...)
to start the testing phase. After the tests you should call EasyMock.verify(...)
to check that all preconfigured calls have been made with the expected parameters.
See the documentation for more details and examples.
Péter Török
2010-07-27 15:05:22