JUnit Tests for RabbitMQ

I wouldn't try to mock the RabbitMQ server itself; instead, mock your publication methods, channel factories, and so on in order to emulate error conditions (and the happy path, of course). What happens when your FoozleEvent.publish method throws an IOError, for example?


We use mocking extensively for tests in the framework itself; explore the tests for ideas. It's not too bad on the RabbitTemplate side, but mocking for the listener container is more involved.

In some case, though, a real integration test is needed and in that case we use a JUnit @Rule to ignore the tests if there's not a local rabbitmq broker.