Now I am writing the test case of my class. I want to pass the HttpServletRequest object parameter to my test case method to check whether the method is working or not. So any one give me the suggestion to that.
public void testCheckBatchExecutionSchedule() throws Exception { assertTrue("Batch is Completed :", returnPointsRatingDisputeFrom.checkBatchExecutionSchedule(request)); }
The request and response classes aren't designed to be cloned or accessed from multiple threads. If you try to do so, you're bound to run into problems.
getParameter. Returns the value of a request parameter as a String , or null if the parameter does not exist. Request parameters are extra information sent with the request. For HTTP servlets, parameters are contained in the query string or posted form data.
In a typical Servlet container implementation if an HTTP request comes in, an HttpServletRequest is created right when the HTTP input data of the request is parsed by the Servlet container.
The ServletRequest and HttpServletRequest classes hold all of the accessible information about the client and the server. HttpServletRequest is a subclass of ServletRequest, and is passed to each servlet handler method (such as doGet(..), doPut(..), etc.)
Spring provides a class called MockHttpServletRequest, which can be used to test code that needs a HttpServletRequest.
public void testCheckBatchExecutionSchedule() throws Exception { MockHttpServletRequest request = new MockHttpServletRequest(); request.addParameter("parameterName", "someValue"); assertTrue("Batch is Completed :", returnPointsRatingDisputeFrom.checkBatchExecutionSchedule(request)); }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With