Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Ravish Srivastava
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to mock it out or call a framework that simulates the real behavior?
 
Ravish Srivastava
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
author & internet detective
Marshal
Posts: 34095
337
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic