3

I am trying to write some integrations tests, and I want to introduce a timeout exception in one case. So, my question is, how can I introduce a delay in the mockMvc.perfrom method?

I found this example but it's not suitable to MockMvc.

Any hint? Thanks in advance.

MockMvc mockMvc;

...

@Test
public void timeoutExpirationRequest_shouldReturn500AndFailureBody() throws Exception {

    mockMvc.perform(
            get("/dcsk/9999")
                .accept(parseMediaType("application/json;charset=UTF-8"))
                .header("*****", "*****")
            )
            .andExpect(status().isInternalServerError())
            .andExpect(content().contentType(APPLICATION_JSON_UTF8))
            .andExpect(jsonPath("$", not(empty())))
            .andExpect(content().json(load("/expected_result/timeout_expiration.json")));
}
pik4
  • 1,283
  • 3
  • 21
  • 56

0 Answers0