File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Testing and the fly likes Initialize the request parameter of HttpServlet from any JUnit test class Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » Testing
Reply locked New topic
Author

Initialize the request parameter of 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
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60048
    
  65

Please do not post the same question more than once.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Initialize the request parameter of HttpServlet from any JUnit test class
 
Similar Threads
Initialization in doPost
Problem to initialize the request parameter of the HttpServlet from any JUnit test class
Can some please explain this?
Null values being returned from servlet
http client + thread save conn manager + execute get request time problems