-1

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?

Andrey
  • 810
  • 1
  • 9
  • 20

3 Answers3

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.

Community
  • 1
  • 1
david a.
  • 5,283
  • 22
  • 24
0

have you tried easymock or mockito ?

aishwarya
  • 1,970
  • 1
  • 14
  • 22
0

I have always used Spring Framework's classes for this, but I do Spring Framework for everything.

Thom
  • 14,013
  • 25
  • 105
  • 185