Description
This project aims to emulate RabbitMQ behavior for test purposes.
RabbitMQ-mock alternatives and similar libraries
Based on the "Testing" category.
Alternatively, view RabbitMQ-mock alternatives based on common mentions on social networks and blogs.
-
Apache JMeter
Apache JMeter open-source load testing tool for analyzing and measuring the performance of a variety of services -
TestContainers
Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container. -
MockServer
MockServer enables easy mocking of any system you integrate with via HTTP or HTTPS with clients written in Java, JavaScript and Ruby. MockServer also includes a proxy that introspects all proxied traffic including encrypted SSL traffic and supports Port Forwarding, Web Proxying (i.e. HTTP proxy), HTTPS Tunneling Proxying (using HTTP CONNECT) and SOCKS Proxying (i.e. dynamic port forwarding). -
PowerMock
PowerMock is a Java framework that allows you to unit test code normally regarded as untestable. -
Pact JVM
JVM version of Pact. Enables consumer driven contract testing, providing a mock service and DSL for the consumer project, and interaction playback and verification for the service provider project. -
Scott Test Reporter
Never debug a test again: Detailed failure reports and hassle free assertions for Java tests - Power Asserts for Java -
pojo-tester
Java testing framework for testing pojo methods. It tests equals, hashCode, toString, getters, setters, constructors and whatever you report in issues ;)
CodeRabbit: AI Code Reviews for Developers

* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of RabbitMQ-mock or a related project?
README
RabbitMQ-mock
Mock for RabbitMQ Java amqp-client.
Compatible with versions 4.0.0 to 5+ of com.rabbitmq:amqp-client
Compatible with versions 3.6.3 to 4.0.0 with the [
com.github.fridujo.rabbitmq.mock.compatibility
package](src/main/java/com/github/fridujo/rabbitmq/mock/compatibility/MockConnectionFactoryFactory.java).
Motivation
This project aims to emulate RabbitMQ behavior for test purposes, through:
com.rabbitmq.client.ConnectionFactory
with [MockConnectionFactory
](src/main/java/com/github/fridujo/rabbitmq/mock/MockConnectionFactory.java)
Example Use
Replace the use of com.rabbitmq.client.ConnectionFactory
by [MockConnectionFactory
](src/main/java/com/github/fridujo/rabbitmq/mock/MockConnectionFactory.java)
ConnectionFactory factory = new MockConnectionFactory();
try (Connection conn = factory.newConnection()) {
try (Channel channel = conn.createChannel()) {
GetResponse response = channel.basicGet(queueName, autoAck);
byte[] body = response.getBody();
long deliveryTag = response.getEnvelope().getDeliveryTag();
// Do what you need with the body
channel.basicAck(deliveryTag, false);
}
}
More details in [integration-test](src/test/java/com/github/fridujo/rabbitmq/mock/IntegrationTest.java)
With Spring
Change underlying RabbitMQ ConnectionFactory by [MockConnectionFactory
](src/main/java/com/github/fridujo/rabbitmq/mock/MockConnectionFactory.java)
@Configuration
@Import(AppConfiguration.class)
class TestConfiguration {
@Bean
ConnectionFactory connectionFactory() {
return new CachingConnectionFactory(new MockConnectionFactory());
}
}
More details in [integration-test](src/test/java/com/github/fridujo/rabbitmq/mock/spring/SpringIntegrationTest.java)
Contribute
Any contribution is greatly appreciated. Please check out the [guide](CONTRIBUTING.md) for more details.
Getting Started
Maven
Add the following dependency to your pom.xml
<dependency>
<groupId>com.github.fridujo</groupId>
<artifactId>rabbitmq-mock</artifactId>
<version>${rabbitmq-mock.version}</version>
<scope>test</scope>
</dependency>
Gradle
Add the following dependency to your build.gradle
repositories {
mavenCentral()
}
// ...
dependencies {
// ...
testCompile('com.github.fridujo:rabbitmq-mock:$rabbitmqMockVersion')
// ...
}
Building from Source
You need JDK-8 to build RabbitMQ-Mock. The project can be built with Maven using the following command.
mvn clean package
Tests are split in:
- unit tests covering features and borderline cases:
mvn test
- integration tests, seatbelts for integration with Spring and Spring-Boot. These tests use the maven-invoker-plugin to launch the same project (in [src/it/spring_boot](src/it/spring_boot)) with different versions of the dependencies:
mvn integration-test
- mutation tests, to help understand what is missing in test assertions:
mvn org.pitest:pitest-maven:mutationCoverage
Installing in the Local Maven Repository
The project can be installed in a local Maven Repository for usage in other projects via the following command.
mvn clean install
Using the latest SNAPSHOT
The master of the project pushes SNAPSHOTs in Sonatype's repo.
To use the latest master build add Sonatype OSS snapshot repository, for Maven:
<repositories>
...
<repository>
<id>sonatype-oss-spanshots</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</repository>
</repositories>
For Gradle:
repositories {
// ...
maven {
url "https://oss.sonatype.org/content/repositories/snapshots"
}
}
License
*Note that all licence references and agreements mentioned in the RabbitMQ-mock README section above
are relevant to that project's source code only.