RabbitMQ-Mock

Mock for RabbitMQ Java amqp-client

License

License

GroupId

GroupId

com.github.fridujo
ArtifactId

ArtifactId

rabbitmq-mock
Last Version

Last Version

1.1.1
Release Date

Release Date

Type

Type

jar
Description

Description

RabbitMQ-Mock
Mock for RabbitMQ Java amqp-client
Project URL

Project URL

https://github.com/fridujo/rabbitmq-mock
Source Code Management

Source Code Management

https://github.com/fridujo/rabbitmq-mock.git

Download rabbitmq-mock

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.fridujo/rabbitmq-mock/ -->
<dependency>
    <groupId>com.github.fridujo</groupId>
    <artifactId>rabbitmq-mock</artifactId>
    <version>1.1.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.fridujo/rabbitmq-mock/
implementation 'com.github.fridujo:rabbitmq-mock:1.1.1'
// https://jarcasting.com/artifacts/com.github.fridujo/rabbitmq-mock/
implementation ("com.github.fridujo:rabbitmq-mock:1.1.1")
'com.github.fridujo:rabbitmq-mock:jar:1.1.1'
<dependency org="com.github.fridujo" name="rabbitmq-mock" rev="1.1.1">
  <artifact name="rabbitmq-mock" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.fridujo', module='rabbitmq-mock', version='1.1.1')
)
libraryDependencies += "com.github.fridujo" % "rabbitmq-mock" % "1.1.1"
[com.github.fridujo/rabbitmq-mock "1.1.1"]

Dependencies

provided (1)

Group / Artifact Type Version
com.rabbitmq : amqp-client jar 5.7.3

test (6)

Group / Artifact Type Version
org.assertj : assertj-core jar 3.16.1
org.mockito : mockito-core jar 3.4.4
io.micrometer : micrometer-core jar 1.5.2
org.springframework.amqp : spring-rabbit jar 2.2.8.RELEASE
ch.qos.logback : logback-classic jar 1.2.3
org.junit.jupiter : junit-jupiter jar 5.6.2

Project Modules

There are no modules declared in this project.

RabbitMQ-mock

Codacy Badge Build Status Coverage Status Maven Central JitPack License FOSSA Status

Mock for RabbitMQ Java amqp-client.

Compatible with versions 4.0.0 to 5.9.0 of com.rabbitmq:amqp-client

Compatible with versions 3.6.3 to 4.0.0 with the com.github.fridujo.rabbitmq.mock.compatibility package.

Motivation

This project aims to emulate RabbitMQ behavior for test purposes, through:

Example Use

Replace the use of com.rabbitmq.client.ConnectionFactory by MockConnectionFactory

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

With Spring

Change underlying RabbitMQ ConnectionFactory by MockConnectionFactory

@Configuration
@Import(AppConfiguration.class)
class TestConfiguration {
    @Bean
    ConnectionFactory connectionFactory() {
        return new CachingConnectionFactory(new MockConnectionFactory());
    }
}

More details in integration-test

Contribute

Any contribution is greatly appreciated. Please check out the guide for more details.

Open in Gitpod

Getting Started

Maven

Add the following dependency to your pom.xml

<dependency>
    <groupId>com.github.fridujo</groupId>
    <artifactId>rabbitmq-mock</artifactId>
    <version>1.1.1</version>
    <scope>test</scope>
</dependency>

Gradle

Add the following dependency to your build.gradle

repositories {
	mavenCentral()
}

// ...

dependencies {
	// ...
	testCompile('com.github.fridujo:rabbitmq-mock:1.1.1')
	// ...
}

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) 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

FOSSA Status

com.github.fridujo

Fridujo

It's Esperanto for freezer

Versions

Version
1.1.1
1.1.0
1.0.14
1.0.13
1.0.12
1.0.11
1.0.10
1.0.9
1.0.8
1.0.7
1.0.6
1.0.5
1.0.4
1.0.3
1.0.2
1.0.1
1.0.0