public final class BrokerRunning
extends org.junit.rules.TestWatcher
A rule that prevents integration tests from failing if the Rabbit broker application is not running or not accessible. If the Rabbit broker is not running in the background all the tests here will simply be skipped because of a violated assumption (showing as successful). Usage:
@Rule
public static BrokerRunning brokerIsRunning = BrokerRunning.isRunning();
@Test
public void testSendAndReceive() throws Exception {
// ... test using RabbitTemplate etc.
}
The rule can be declared as static so that it only has to check once for all tests in the enclosing test case, but there isn't a lot of overhead in making it non-static.
Assume,
AssumptionViolatedException| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
BROKER_REQUIRED |
| Modifier and Type | Method and Description |
|---|---|
org.junit.runners.model.Statement |
apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description) |
void |
deleteExchanges(java.lang.String... exchanges) |
void |
deleteQueues(java.lang.String... queues) |
java.lang.String |
generateId() |
com.rabbitmq.client.ConnectionFactory |
getConnectionFactory() |
static BrokerRunning |
isBrokerAndManagementRunning() |
static BrokerRunning |
isNotRunning() |
static BrokerRunning |
isRunning() |
static BrokerRunning |
isRunningWithEmptyQueues(java.lang.String... names)
Ensure the broker is running and has an empty queue with the specified name in the default exchange.
|
void |
removeTestQueues(java.lang.String... additionalQueues) |
void |
setHostName(java.lang.String hostName) |
void |
setPort(int port) |
public static final java.lang.String BROKER_REQUIRED
public static BrokerRunning isRunningWithEmptyQueues(java.lang.String... names)
names - the queues to declare for the test.public static BrokerRunning isRunning()
public static BrokerRunning isNotRunning()
public static BrokerRunning isBrokerAndManagementRunning()
public void setPort(int port)
port - the port to setpublic void setHostName(java.lang.String hostName)
hostName - the hostName to setpublic org.junit.runners.model.Statement apply(org.junit.runners.model.Statement base,
org.junit.runner.Description description)
apply in interface org.junit.rules.TestRuleapply in class org.junit.rules.TestWatcherpublic java.lang.String generateId()
public void removeTestQueues(java.lang.String... additionalQueues)
public void deleteQueues(java.lang.String... queues)
public void deleteExchanges(java.lang.String... exchanges)
public com.rabbitmq.client.ConnectionFactory getConnectionFactory()