aspose file tools*
The moose likes Testing and the fly likes How to Junit test a servlet method which has multipart form request. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Testing
Bookmark "How to Junit test a servlet method which has multipart form request." Watch "How to Junit test a servlet method which has multipart form request." New topic
Author

How to Junit test a servlet method which has multipart form request.

Ravish Srivastava
Greenhorn

Joined: Sep 05, 2011
Posts: 23

Hi,

I have a method "doUploadFile(request, response)". This method accept multipart form request from a JSP file and save the file uploaded into to a local directory say C:/uploaded.

My Requiremnt is to Junit test doUploadFile() method.

How can I achieve this?

Help..


Thanks & Regards,
RS
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

Do you want to mock it out or call a framework that simulates the real behavior?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Ravish Srivastava
Greenhorn

Joined: Sep 05, 2011
Posts: 23
I want to write a Java code which calls my "doUploadFile(request, response)" method. I want to construct a Multipart request so that I can pass to doUploadFile().
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

It sounds like you'd want a mock one then. You could write a class that extends it. Or use a mock one that already exists like Spring's MockMultipartHttpServletRequest.
 
wood burning stoves
 
subject: How to Junit test a servlet method which has multipart form request.