すべてのマッピングが正しく機能しています:
MvcResult mvcResult = this.mockMvc.perform(get("/company/doSomething"))
.andDo(print())
.andExpect(status().isOk())
.andReturn();
これからOKステータスを返します
@RequestMapping(value = "/company/doSomething", method = RequestMethod.GET,produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public Boolean myMethod() {
return false;
}
コントローラー メソッドにブレークポイントを設定し、test n デバッグ モードを実行すると、テストは成功し (ブレークポイントは呼び出されません)、応答が出力されます。何も返されず、次のようになります。
MockHttpServletResponse:
Status = 200
Error message = null
Headers = {}
Content type = null
Body =
Forwarded URL = default
Redirected URL = null
Cookies = []
実際のリクエストは次のようになります
MockHttpServletRequest:
HTTP Method = GET
Request URI = /company/doSomething
Parameters = {}
Headers = {}
Handler:
Type = org.springframework.web.servlet.resource.DefaultServletHttpRequestHandler