Spring写入单元测试以上载Rest控制器的文件

Spring写入单元测试以上载Rest控制器的文件,spring,rest,testing,junit,Spring,Rest,Testing,Junit,我正在尝试为我的Rest控制器编写测试用例 @Test public void anonymousUploadControllerTest() throws Exception { MockMultipartFile mockMultipartFile = new MockMultipartFile("file", "test-file.txt", "text/plain","sample da

我正在尝试为我的Rest控制器编写测试用例

    @Test
    public void anonymousUploadControllerTest() throws Exception {
        MockMultipartFile mockMultipartFile = new MockMultipartFile("file", "test-file.txt", "text/plain","sample data1".getBytes());


        mockMvc.perform(MockMvcRequestBuilders.multipart("/upload")
                .file(mockMultipartFile))
                .andExpect(MockMvcResultMatchers.status().is(200))
                .andExpect((ResultMatcher) content().string("File has been uploaded"));


    }
它返回:

MockHttpServletRequest:
      HTTP Method = POST
      Request URI = /upload
       Parameters = {}
          Headers = [Content-Type:"multipart/form-data;charset=UTF-8"]
             Body = null
    Session Attrs = {}

Handler:
             Type = org.sharefiles.root.controllers.UploadController
           Method = org.sharefiles.root.controllers.UploadController#uploadFile(MultipartFile)

Async:
    Async started = false
     Async result = null

Resolved Exception:
             Type = null

ModelAndView:
        View name = null
             View = null
            Model = null

FlashMap:
       Attributes = null

MockHttpServletResponse:
           Status = 500
    Error message = null
          Headers = [Content-Type:"application/json", X-Content-Type-Options:"nosniff", X-XSS-Protection:"1; mode=block", Cache-Control:"no-cache, no-store, max-age=0, must-revalidate", Pragma:"no-cache", Expires:"0", X-Frame-Options:"DENY"]
     Content type = application/json
             Body = {"httpStatus":"INTERNAL_SERVER_ERROR","responseMessage":"Something went wrong with uploading your file!","fileAccessLink":null,"authenticated":false}
    Forwarded URL = null
   Redirected URL = null
          Cookies = []

java.lang.AssertionError: Response status 
Expected :200
Actual   :500
你能帮我找出哪里错了吗? 当我为服务写信时,一切都很好

github上有完整的代码:

如果有什么事,欢迎并感谢你的帮助