To mock RabbitMQ in the Java world, there is a library that I am building : rabbitmq-mock.
The purpose is exactly the use case you describe. You can simply replace the amqp-client ConnectionFactory
and you will have most of RabbitMQ features out of the box, without using IO (no port binding is needed) and without startup time.
Simply add the dependendy in your pom.xml:
<dependency>
<groupId>com.github.fridujo</groupId>
<artifactId>rabbitmq-mock</artifactId>
<version>1.0.14</version>
<scope>test</scope>
</dependency>
Then you can use it through a replacement of the ConnectionFactory you provided through Spring configuration or that Spring-Boot have provided for you:
@Configuration
@Import(AppConfiguration.class)
class TestConfiguration {
@Bean
ConnectionFactory connectionFactory() {
return new CachingConnectionFactory(new MockConnectionFactory());
}
}
Hope this will help !