{"id":18340954,"url":"https://github.com/fridujo/rabbitmq-mock","last_synced_at":"2025-04-05T02:10:45.583Z","repository":{"id":32659085,"uuid":"132457216","full_name":"fridujo/rabbitmq-mock","owner":"fridujo","description":"Mock for RabbitMQ Java amqp-client","archived":false,"fork":false,"pushed_at":"2024-04-16T06:17:10.000Z","size":393,"stargazers_count":173,"open_issues_count":21,"forks_count":33,"subscribers_count":9,"default_branch":"master","last_synced_at":"2024-04-16T18:20:47.050Z","etag":null,"topics":["amqp","amqp-client","hacktoberfest","java","mock","rabbitmq","rabbitmq-java","testing"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fridujo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2018-05-07T12:26:15.000Z","updated_at":"2024-04-18T07:36:30.134Z","dependencies_parsed_at":"2024-02-05T07:29:28.064Z","dependency_job_id":"78822e49-0a86-4e15-b3e2-ec2fe9366152","html_url":"https://github.com/fridujo/rabbitmq-mock","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Frabbitmq-mock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Frabbitmq-mock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Frabbitmq-mock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Frabbitmq-mock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fridujo","download_url":"https://codeload.github.com/fridujo/rabbitmq-mock/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247276189,"owners_count":20912288,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["amqp","amqp-client","hacktoberfest","java","mock","rabbitmq","rabbitmq-java","testing"],"created_at":"2024-11-05T20:24:51.008Z","updated_at":"2025-04-05T02:10:45.563Z","avatar_url":"https://github.com/fridujo.png","language":"Java","funding_links":[],"categories":["测试"],"sub_categories":[],"readme":"# RabbitMQ-mock\n\n[![Build Status](https://github.com/fridujo/rabbitmq-mock/actions/workflows/build.yml/badge.svg)](https://github.com/fridujo/rabbitmq-mock/actions)\n[![Coverage Status](https://codecov.io/gh/fridujo/rabbitmq-mock/branch/master/graph/badge.svg)](https://codecov.io/gh/fridujo/rabbitmq-mock/)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.fridujo/rabbitmq-mock.svg)](https://search.maven.org/artifact/com.github.fridujo/rabbitmq-mock)\n[![JitPack](https://jitpack.io/v/fridujo/rabbitmq-mock.svg)](https://jitpack.io/#fridujo/rabbitmq-mock)\n[![License](https://img.shields.io/github/license/fridujo/rabbitmq-mock.svg)](https://opensource.org/licenses/Apache-2.0)\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ffridujo%2Frabbitmq-mock.svg?type=shield)](https://app.fossa.io/projects/git%2Bgithub.com%2Ffridujo%2Frabbitmq-mock?ref=badge_shield)\n\nMock for RabbitMQ Java [amqp-client](https://github.com/rabbitmq/rabbitmq-java-client).\n\n\u003e Compatible with versions **4.0.0** to **5+** of [**com.rabbitmq:amqp-client**](https://github.com/rabbitmq/rabbitmq-java-client)\n\n\u003e 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).\n\n### Motivation\n\nThis 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).\n\nHowever today, you will have more robust results using a real RabbitMQ instance through the use of [Testcontainers](https://java.testcontainers.org/modules/rabbitmq/).\n\nIf Docker is not an acceptable option, you can still rely on **RabbitMQ-mock**.\n\n## Example Use\n\nReplace the use of `com.rabbitmq.client.ConnectionFactory` by [`MockConnectionFactory`](src/main/java/com/github/fridujo/rabbitmq/mock/MockConnectionFactory.java)\n\n```java\nConnectionFactory factory = new MockConnectionFactory();\ntry (Connection conn = factory.newConnection()) {\n    try (Channel channel = conn.createChannel()) {\n        GetResponse response = channel.basicGet(queueName, autoAck);\n        byte[] body = response.getBody();\n        long deliveryTag = response.getEnvelope().getDeliveryTag();\n\n        // Do what you need with the body\n\n        channel.basicAck(deliveryTag, false);\n    }\n}\n```\n\nMore details in [integration-test](src/test/java/com/github/fridujo/rabbitmq/mock/IntegrationTest.java)\n\n### With Spring\nChange underlying RabbitMQ ConnectionFactory by [`MockConnectionFactory`](src/main/java/com/github/fridujo/rabbitmq/mock/MockConnectionFactory.java)\n\n```java\n\n@Configuration\n@Import(AppConfiguration.class)\nclass TestConfiguration {\n    @Bean\n    ConnectionFactory connectionFactory() {\n        return new CachingConnectionFactory(new MockConnectionFactory());\n    }\n}\n```\n\nMore details in [integration-test](src/test/java/com/github/fridujo/rabbitmq/mock/spring/SpringIntegrationTest.java)\n\n## Contribute\nAny contribution is greatly appreciated. Please check out the [guide](CONTRIBUTING.md) for more details.\n\n[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#github.com/fridujo/rabbitmq-mock.git)\n\n## Getting Started\n\n### Maven\nAdd the following dependency to your **pom.xml**\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.github.fridujo\u003c/groupId\u003e\n    \u003cartifactId\u003erabbitmq-mock\u003c/artifactId\u003e\n    \u003cversion\u003e${rabbitmq-mock.version}\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\nAdd the following dependency to your **build.gradle**\n```groovy\nrepositories {\n\tmavenCentral()\n}\n\n// ...\n\ndependencies {\n\t// ...\n\ttestCompile('com.github.fridujo:rabbitmq-mock:$rabbitmqMockVersion')\n\t// ...\n}\n```\n\n### Building from Source\n\nYou need [JDK-17(https://adoptium.net/temurin/releases/?version=17\u0026package=jdk) to build RabbitMQ-Mock. The project can be built with Maven using the following command.\n```\n./mvnw install\n```\n\nTests are split in:\n\n* **unit tests** covering features and borderline cases: `mvn test`\n* **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`\n* **mutation tests**, to help understand what is missing in test assertions: `mvn org.pitest:pitest-maven:mutationCoverage`\n\n### Using the latest SNAPSHOT\n\nThe master of the project pushes SNAPSHOTs in Sonatype's repo.\n\nTo use the latest master build add Sonatype OSS snapshot repository, for Maven:\n```\n\u003crepositories\u003e\n    ...\n    \u003crepository\u003e\n        \u003cid\u003esonatype-oss-spanshots\u003c/id\u003e\n        \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n    \u003c/repository\u003e\n\u003c/repositories\u003e\n```\n\nFor Gradle:\n```groovy\nrepositories {\n    // ...\n    maven {\n        url \"https://oss.sonatype.org/content/repositories/snapshots\"\n    }\n}\n```\n\n## License\n[![FOSSA Status](https://app.fossa.io/api/projects/git%2Bgithub.com%2Ffridujo%2Frabbitmq-mock.svg?type=large)](https://app.fossa.io/projects/git%2Bgithub.com%2Ffridujo%2Frabbitmq-mock?ref=badge_large)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridujo%2Frabbitmq-mock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffridujo%2Frabbitmq-mock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridujo%2Frabbitmq-mock/lists"}