i want to create unitest for upload file method, which accepts HttpServletRequest object . But i don't know how to create this object and pass in all the form data without executing servlet. Is there a way to do this?
Asked
Active
Viewed 554 times
-1
-
I personally like httpUnit, another related question http://stackoverflow.com/questions/53532/unit-testing-servlets – Prasanna Talakanti Nov 01 '11 at 13:32
-
can you describe more about your application. Is it client-server based application. – SilentBomb Nov 01 '11 at 12:04
-
I'm actually try to avoid servlet testing, and test inner method. – Andrey Nov 02 '11 at 05:37
3 Answers
1
Create a mock HttpServletRequest instance (using Mockito or another mocking library).
Edit: See also a related question. Actually, subclassing HttpServletRequest is a way as well.
0
I have always used Spring Framework's classes for this, but I do Spring Framework for everything.

Thom
- 14,013
- 25
- 105
- 185