Always Remove Test Exchanges in ERIT
- in case of dross left behind by a failed test run
This commit is contained in:
@@ -442,6 +442,33 @@ public final class BrokerRunningSupport {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove exchanges from the broker.
|
||||
* @param exchanges the exchanges.
|
||||
* @since 2.3
|
||||
*/
|
||||
public void removeExchanges(String... exchanges) {
|
||||
LOGGER.debug("deleting test exchanges: " + Arrays.toString(exchanges));
|
||||
Connection connection = null; // NOSONAR (closeResources())
|
||||
Channel channel = null;
|
||||
|
||||
try {
|
||||
connection = getConnection(getConnectionFactory());
|
||||
connection.setId(generateId() + ".exchangeDelete");
|
||||
channel = connection.createChannel();
|
||||
|
||||
for (String exchange : exchanges) {
|
||||
channel.exchangeDelete(exchange);
|
||||
}
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOGGER.warn("Failed to delete exchanges", e);
|
||||
}
|
||||
finally {
|
||||
closeResources(connection, channel);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete and re-declare all the configured queues. Can be used between tests when
|
||||
* a test might leave stale data and multiple tests use the same queue.
|
||||
|
||||
@@ -225,6 +225,19 @@ public class EnableRabbitIntegrationTests {
|
||||
public static void setUp() {
|
||||
System.setProperty(RabbitListenerAnnotationBeanPostProcessor.RABBIT_EMPTY_STRING_ARGUMENTS_PROPERTY,
|
||||
"test-empty");
|
||||
RabbitAvailableCondition.getBrokerRunning().removeExchanges("auto.exch.tx",
|
||||
"auto.exch",
|
||||
"auto.exch.fanout",
|
||||
"auto.exch",
|
||||
"auto.exch",
|
||||
"auto.start",
|
||||
"auto.headers",
|
||||
"auto.headers",
|
||||
"auto.internal",
|
||||
"multi.exch",
|
||||
"multi.json.exch",
|
||||
"multi.exch.tx",
|
||||
"test.metaFanout");
|
||||
}
|
||||
|
||||
@AfterAll
|
||||
|
||||
Reference in New Issue
Block a user