I'm trying to write a unit test for a controller that has a DELETE method that should accept a File and a text param.
I know I can do a simple delete like that:
MvcResult result = mockMvc.perform(MockMvcRequestBuilders.delete(
"/deletecat/catname/Oscar"))
.andExpect(status().isOK)
.andReturn();
And I can do a POST to a Multipart file like that:
MockMultipartFile multipartFile = new MockMultipartFile("file", new FileInputStream(TEST_RESOURCES_FOLDER + "Cats.csv"));
MvcResult result = mockMvc.perform(MockMvcRequestBuilders.multipart("/uploadcats")
.file(multipartFile)
.param("ownerName", "Austin Powers"))
.andExpect(status().isOk())
.andReturn();
But when I tried to combine them together and wrote this:
MvcResult result = mockMvc.perform(
MockMvcRequestBuilders.delete(
"/deletecats",
multipartFile, "Austin Powers"))
.andExpect(status().isOk())
.andReturn();
I get the following error of "Current request is not a multipart request":
org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.web.multipart.MultipartException: Current request is not a multipart request
Is it possible that the HTTP protocol is not supporting to do a DELETE with Multipart file?