This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Testing and the fly likes Problem to initialize the request parameter of the HttpServlet from any JUnit test class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » Testing
Bookmark "Problem to initialize the request parameter of the HttpServlet from any JUnit test class" Watch "Problem to initialize the request parameter of the HttpServlet from any JUnit test class" New topic
Author

Problem to initialize the request parameter of the HttpServlet from any JUnit test class

hama tum
Greenhorn

Joined: Sep 15, 2011
Posts: 2
Hi there...
I am trying to make a JUnit for my doPost method in a class HttpGet that extends HttpServlet...
I am new with JUnit and I have already implemented the test class TestHttpGet with the method testdoPost(){}
in the test method I want to call the method doPost(), which I want to test! the problem is the method's parameters (request, response)! how can I initialize these parameters??
for ex. if I want to test just the request... I will put the response equal null and the request should be assigned a request parameter. My question is, how can I initialize the request parameter???

HttpGet tester = new HttpGet();
HttpServletRequest parameter = ???;
tester.doPost(parameter, null);

Many Thanks!
hama
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Problem to initialize the request parameter of the HttpServlet from any JUnit test class
 
It's not a secret anymore!