I have a controller's method with a PUT method, which receives multipart/form-data:
@RequestMapping(value = "/putIn", method = RequestMethod.PUT)
public Foo updateFoo(HttpServletRequest request,
@RequestBody Foo foo,
@RequestParam("foo_icon") MultipartFile file) {
...
}
and I want to test it using MockMvc. Unfortunately MockMvcRequestBuilders.fileUpload creates essentially an instance of MockMultipartHttpServletRequestBuilder which has a POST method:
super(HttpMethod.POST, urlTemplate, urlVariables)
EDIT:
Surely I can I can not create my own implementation of MockHttpServletRequestBuilder, say
public MockPutMultipartHttpServletRequestBuilder(String urlTemplate, Object... urlVariables) {
super(HttpMethod.PUT, urlTemplate, urlVariables);
super.contentType(MediaType.MULTIPART_FORM_DATA);
}
because MockHttpServletRequestBuilder has a package-local constructor.
But I'm wondering is there any more convenient Is any way to do this, may be I missed some existent class or method for doing this?