The goal is to verify that the expected interactions occur up to the given timeout.
This is useful for testing asynchronous flows in event-driven services, similar to the testing support in Spring Amqp.
Sample code:
@SpringBootApplication
public class MyApplication {
@Autowired
private RestTemplate template;
@RabbitListener()
public void callService(String payload) {
template.put("http://example.com/hello", payload);
}
}
@SpringBootTest
@RunWith(SpringRunner.class)
public class ApplicationTest {
@Autowired
private MockRestServiceServer mockServer;
@Autowired
private AmqpTemplate template;
@Test
public void callsService() {
mockServer.expect(method(PUT))
.andExpect(requestTo("/hello"))
.andRespond(withNoContent());
template.convertAndSend("HelloWorld");
mockServer.verify(5, TimeUnit.SECONDS);
}
}
The goal is to verify that the expected interactions occur up to the given timeout.
This is useful for testing asynchronous flows in event-driven services, similar to the testing support in Spring Amqp.
Sample code: