title: How to unit test a ResponseBody or ResponseEntity sent by a spring mvc Controller?
body: <p>When I do junit tests, I do something like this to test spring mvc controllers :</p>
  
  <pre><code>request.setRequestURI("/projects/"+idProject+"/modify");
  ModelAndView mv = handlerAdapter.handle(request, response, controller);
  </code></pre>
  
  <p>where controller tested is like :</p>
  
  <pre><code>@RequestMapping(value = "{id}/modify")
  public String content(ModelMap model, @PathVariable("id") Project object) {
  </code></pre>
  
  <p>But I don't find how to get the <code>ResponseBody</code> answer of request handlers defined like this :</p>
  
  <pre><code>@RequestMapping("/management/search")
  public @ResponseBody ArrayList&lt;SearchData&gt; search(@RequestParam("q")) {
          ....
                  ....
          ArrayList&lt;SearchData&gt; datas = ....;
  
          return datas;
      }
  </code></pre>