}
else {
Assume.assumeTrue(brokerOffline.get(port));
}
CachingConnectionFactory connectionFactory = new CachingConnectionFactory();
connectionFactory.setHost("localhost");
try {
connectionFactory.setPort(port);
if (StringUtils.hasText(hostName)) {
connectionFactory.setHost(hostName);
}
RabbitAdmin admin = new RabbitAdmin(connectionFactory);
for (Queue queue : queues) {
String queueName = queue.getName();
if (purge) {
logger.debug("Deleting queue: " + queueName);
// Delete completely - gets rid of consumers and bindings as well
admin.deleteQueue(queueName);
}
if (isDefaultQueue(queueName)) {
// Just for test probe.
admin.deleteQueue(queueName);
}
else {
admin.declareQueue(queue);
}
}
brokerOffline.put(port, false);
if (!assumeOnline) {
Assume.assumeTrue(brokerOffline.get(port));
}
}
catch (Exception e) {
logger.warn("Not executing tests because basic connectivity test failed", e);
brokerOnline.put(port, false);
if (assumeOnline) {
Assume.assumeNoException(e);
}
}
finally {
connectionFactory.destroy();
}
return super.apply(base, description);
}