I\'m implementing long polling as per the Spring blog from some time ago.
Here my converted method with same response signature as before, but instead of responding
In my case, after going through spring source code and setting the timeout (10000 millisecond) and getting async result solved it for me, as;
mvcResult.getRequest().getAsyncContext().setTimeout(10000);
mvcResult.getAsyncResult();
My whole test code was;
MvcResult mvcResult = this.mockMvc.perform(
post("")
.contentType(MediaType.APPLICATION_JSON)
.content())
***.andExpect(request().asyncStarted())***
.andReturn();
***mvcResult.getRequest().getAsyncContext().setTimeout(10000);***
***mvcResult.getAsyncResult();***
this.mockMvc
.perform(asyncDispatch(mvcResult))
.andDo(print())
.andExpect(status().isOk());
Hope it helps..