Given I have inherited some Spring MVC controller code with signature
@RequestMapping(value = \"/upload\", method = RequestMethod.POST)
public ModelAndView u
You can add a RequestPostProcessor. Which you can then pass in to the mockmvc stuff by using the with()
method.
mockMvc().perform(
fileUpload("/upload")
.file(FileFactory.stringContent("myFile"))
.with(new RequestPostProcessor() {
public MockHttpServletRequest postProcessRequest(MockHttpServletRequest request) {
request.setRemoteAddr("12345");
return request;
}}));
Something like that should work.