-
Notifications
You must be signed in to change notification settings - Fork 38.6k
Closed
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement
Milestone
Description
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);
}
}
narenchoudhary
Metadata
Metadata
Assignees
Labels
in: testIssues in the test moduleIssues in the test modulein: webIssues in web modules (web, webmvc, webflux, websocket)Issues in web modules (web, webmvc, webflux, websocket)type: enhancementA general enhancementA general enhancement