spring-cloud-stream
spring-cloud-stream copied to clipboard
OutputDestination should have a method that clears all messages of a binding
Version:
Spring boot: 2.2.5
Spring cloud stream: 3.0.4.BUILD-SNAPSHOT
Description
Given that the recommended way of implementing tests for spring cloud stream involves using the new test jar binder, using InputDestination and OutputDestination, a few auxiliary methods that were present on MessageCollector could be added to the new classes.
Right now, if writing multiple integration tests that send messages to a given binding, if you want to ensure that the messages are cleared before or after test execution, you would have to execute multiple OutputDestination.receive(..) calls, like this:
@After
public void after() {
outputDestination.receive(10, binding);
outputDestination.receive(10, binding);
outputDestination.receive(10, binding);
outputDestination.receive(10, binding);
outputDestination.receive(10, binding);
}
While using the legacy implementation with MessageCollector, you simply had to this:
@After
public void after() {
collector.forChannel(channel).clear();
}