title: Testing Spring asyncResult() and jsonPath() together
body: <p>I'm using a restful url to kick off a long-running backend process (it is normally on a cron schedule, but we want the ability to kick it off manually).</p>
  
  <p>The code below works and I see the result in the browser when I test manually.</p>
  
  <pre><code>@ResponseBody
  @RequestMapping(value = "/trigger/{jobName}", method = RequestMethod.GET)
  public Callable&lt;TriggerResult&gt; triggerJob(@PathVariable final String jobName) {
  
      return new Callable&lt;TriggerResult&gt;() {
          @Override
          public TriggerResult call() throws Exception {
              // Code goes here to locate relevant job and kick it off, waiting for result
              String message = &lt;result from my job&gt;;
              return new TriggerResult(SUCCESS, message);
          }
      };
  }
  </code></pre>
  
  <p>When I test this without the <code>Callable</code> I used the code below and it all works (I changed the expected error message to simplify post).</p>
  
  <pre><code>mockMvc.perform(get("/trigger/job/xyz"))
      .andExpect(status().isOk())
      .andDo(print())
      .andExpect(jsonPath("status").value("SUCCESS"))
      .andExpect(jsonPath("message").value("A meaningful message appears"));
  </code></pre>
  
  <p>When I added the <code>Callable</code> however it does not work. I also tried below but it did not work. Anyone else had success?</p>
  
  <pre><code>mockMvc.perform(get("/trigger/job/xyz"))
      .andExpect(status().isOk())
      .andDo(print())
      .andExpect(request().asyncResult(jsonPath("status").value("SUCCESS")))
      .andExpect(request().asyncResult(jsonPath("message").value("A meaningful message appears")));
  </code></pre>
  
  <p>Below is the relevant part from my print(). Looks like mockMvc can't untangle the Json correctly in this case (even though it works in my browser)? When I do this without <code>Callable</code> I see full JSON. </p>
  
  <pre><code>MockHttpServletRequest:
       HTTP Method = GET
       Request URI = /trigger/job/xyz
        Parameters = {}
           Headers = {}
  
           Handler:
              Type = foo.bar.web.controller.TriggerJobController
            Method = public java.util.concurrent.Callable&lt;foo.bar.myproject.web.model.TriggerResult&gt; foo.bar.myproject.web.controller.TriggerJobController.triggerJob(java.lang.String)
  
             Async:
   Was async started = true
        Async result = foo.bar.myproject.web.model.TriggerResult@67aa1e71
  
  
  Resolved Exception:
              Type = null
  
      ModelAndView:
         View name = null
              View = null
             Model = null
  
          FlashMap:
  
  MockHttpServletResponse:
            Status = 200
     Error message = null
           Headers = {}
      Content type = null
              Body = 
     Forwarded URL = null
    Redirected URL = null
           Cookies = []
  </code></pre>