Using Spring MVC 3.1.x and spring-test-mvc, I was wondering if there is a way to mock the parameters of a function being mapped using @RequestMapping. Please see the code snippet below. I would like to know if I can use spring-test-mvc and mock out the response method below. I know that I can create an instance of the controller class, and then pass in mocked values of the request/response, but that doesn't test out the annotated portions of the code, which is why I would like to know if there is a way to do this using spring-test-mvc. If that is not possible, then is there another way that I can verify that the OutputStream is returning the correct results?
@RequestMapping(value="/", method = RequestMethod.GET)
public void getRequest(ServletRequest request, ServletResponse response){
try{
String destination = destinationRetrievalService.getDestination(request, response);
InputStream input = httpServletRequestDelegationService.delegateGet(request, destination, response);
response.setContentType("text/html");
response.setCharacterEncoding("UTF-8");
OutputStream output = response.getOutputStream();
IOUtils.copy(input, output);
}catch(IOException ioe){
LOG.error("An exception has been thrown while trying to copy the stream back to the page.", ioe);
}
}
Thanks in advance!
Juan