MockMVC不断抛出HttpMessageNotReadableException

时间:2015-07-14 18:51:27

标签: java spring

我在测试中有以下代码:

mockMvc.perform(get("/bk/getBk?sd=1262296800000&nOD=3"))
                .andDo(print())
                .andExpect(status().isOk())
                .andExpect(content().contentType("application/json;charset=UTF-8"))
                .andExpect((jsonPath("$.", Matchers.hasSize(3))))
                .andDo(print());

我无法理解为什么它不断抛出org.springframework.http.converter.HttpMessageNotReadableException,因为它找到了处理程序并且路径似乎没问题。

以下是print()

的内容
MockHttpServletRequest:
         HTTP Method = GET
         Request URI = /bk/getBk
          Parameters = {sd=[1262296800000], nOD=[3]}
             Headers = {}

             Handler:
                Type = com.ihbs.booking.BkController
              Method = public org.springframework.http.ResponseEntity<java.util.List<com.ihbs.bk.BkDTO>> com.ihbs.booking.BkController.getBk(com.ihbs.bk.GetBkForm,org.springframework.validation.BindingResult) throws com.ihbs.exception.InvalidEmailException,com.ihbs.exception.IDSmallerThanZeroException

               Async:
       Async started = false
        Async result = null

  Resolved Exception:
                Type = org.springframework.http.converter.HttpMessageNotReadableException

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

            FlashMap:

MockHttpServletResponse:
              Status = 400
       Error message = null
             Headers = {}
        Content type = null
                Body = 
       Forwarded URL = null
      Redirected URL = null
             Cookies = []

我不知道如何获得堆栈跟踪。

0 个答案:

没有答案