java
Testing async controllers using MockMvc
I have a controller that returns a DeferredResult, it is a POST. Controller: #RequestMapping(value = "/{customerId}/cards", method = RequestMethod.POST) #ResponseBody public DeferredResult<CardSummaryQuery> createCard( #PathVariable String customerId, #RequestBody CustomerDto payload) { DeferredResult<CardSummaryQuery> deferred = new DeferredResult<>(); Observable<CardSummaryQuery> observable = cardService.registerCardObservable(customerId, payload); observable.subscribe(deferred::setResult, deferred::setErrorResult); return deferred; } I am trying to test it but receiving the following error: "java.lang.AssertionError: Content type not set" MvcResult result = mockMvc .perform(post("/customers/55e5d-4df4r-v4fgt/cards").content(payload) .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()).andExpect(request().asyncStarted()) .andExpect(request().asyncResult("Deferred result")).andReturn(); mockMvc.perform(asyncDispatch(result)).andExpect(jsonPath("$.success").value(true)); What can I do to solve?
Related Links
Heapsort StackOverflow error
Spring Android not working with Gradle
Arabic value does not work in jsp servlet
JPA Sequence Generator causing ORA-01438: value larger than specified precision allowed for this column for Id column
What does Mockito.anyLong() do?
displaying the output from a serial port in JTextField
String pattern matching with regular expression in java [duplicate]
Android : GPS tracking system for find each other in a close area
is it necessary to return a different object from the getter method than the object passed by Hibernate to the setter?
Convert 2D binary matrix to black/white image in java
Unable to check for valid Login from SQLite
Android AlaramManager of android not triggering at defined time
Updating a BeanTableModel with new Data - Java
Upload to Artifactory using Java client
Preventing repetitive items from being printed [duplicate]
How to dermine if a value of type int is a match in an array?