title: MockMVC perform post test to async service
body: <p>I need to test a controller which calls an asynchronous service. </p>
  
  <p><strong>CONTROLLER CODE</strong></p>
  
  <pre><code>@RequestMapping(value = "/path", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_VALUE)
  @ResponseBody
  public ResponseEntity&lt;Result&gt; massiveImport(HttpServletRequest request) {
      try {
          service.asyncMethod(request);
      } catch (Exception e) {
          e.printStackTrace();
          return new ResponseEntity&lt;&gt;(new Result(e.getMessage()), HttpStatus.BAD_REQUEST);
      }
  
      return new ResponseEntity&lt;&gt;(new Result(saveContact.toString()), HttpStatus.OK);
  }
  </code></pre>
  
  <p><strong>SERVICE CODE</strong></p>
  
  <pre><code>@Async
  public Future&lt;Integer&gt; asyncMethod(HttpServletRequest request) throws IllegalFieldValueException, Exception {
      ...
      return new AsyncResult&lt;&gt;(value);
  }
  </code></pre>
  
  <p><strong>TEST CODE</strong></p>
  
  <pre><code>MvcResult result = getMvc().perform(MockMvcRequestBuilders.fileUpload("/path/")
                             .header("X-Auth-Token", accessToken)
                             .accept(MediaType.APPLICATION_JSON))
                             .andDo(print())
                             .andReturn();
  </code></pre>
  
  <p>Test is ok. But I would wait, before closing the test, to complete async service. </p>
  
  <p>Is there any way to do this?</p>