{"id":18340949,"url":"https://github.com/fridujo/spring-automocker","last_synced_at":"2025-07-01T02:37:17.566Z","repository":{"id":32060172,"uuid":"129699491","full_name":"fridujo/spring-automocker","owner":"fridujo","description":"Automatic IO mocking tool for Spring's JavaConfig","archived":false,"fork":false,"pushed_at":"2022-12-10T05:33:52.000Z","size":194,"stargazers_count":11,"open_issues_count":84,"forks_count":6,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-06T06:34:35.522Z","etag":null,"topics":["graphite","jdbc","jms","micrometer","mock","rabbitmq","spring"],"latest_commit_sha":null,"homepage":null,"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":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-04-16T07:03:32.000Z","updated_at":"2025-01-15T14:46:39.000Z","dependencies_parsed_at":"2023-01-14T20:25:30.970Z","dependency_job_id":null,"html_url":"https://github.com/fridujo/spring-automocker","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Fspring-automocker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Fspring-automocker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Fspring-automocker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Fspring-automocker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fridujo","download_url":"https://codeload.github.com/fridujo/spring-automocker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fridujo%2Fspring-automocker/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":258435310,"owners_count":22700453,"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":["graphite","jdbc","jms","micrometer","mock","rabbitmq","spring"],"created_at":"2024-11-05T20:24:45.018Z","updated_at":"2025-07-01T02:37:17.516Z","avatar_url":"https://github.com/fridujo.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spring-Automocker\n[![Build Status](https://travis-ci.org/fridujo/spring-automocker.svg?branch=master)](https://travis-ci.org/fridujo/spring-automocker)\n[![codecov](https://codecov.io/gh/fridujo/spring-automocker/branch/master/graph/badge.svg)](https://codecov.io/gh/fridujo/spring-automocker)\n[![Maven Central](https://img.shields.io/maven-central/v/com.github.fridujo/spring-automocker.svg)](https://search.maven.org/#search|ga|1|a:\"spring-automocker\")\n[![License](https://img.shields.io/github/license/fridujo/spring-automocker.svg)](https://opensource.org/licenses/Apache-2.0)\n\nAutomatic detection and mocking of Spring IO components.\n\n### Motivation\n\nWriting integration tests for Spring application is often writing the same glue code over and over again.\nSpring-Automocker was created to avoid re-writing the same boilerplate code and focus on test added value.\n\n### Mocking strategies\n\n##### Property sources\nThe extension [`@MockPropertySources`](spring-automocker/src/main/java/com/github/fridujo/automocker/base/MockPropertySources.java) adds a `ProtocolResolver` to Spring context resolving *properties file* as empty ones.\n\n##### MVC controllers\nThe extension [`@MockWebMvc`](spring-automocker/src/main/java/com/github/fridujo/automocker/base/MockWebMvc.java) sets up a `MockMvc`.\nThis `MockMvc` instance is either wired on :\n* the `org.springframework.web.context.WebApplicationContext` if the current context is of such type\n* the `@Controller` annotated beans otherwise\n\n##### JDBC Data Sources\nThe extension [`@MockJdbc`](spring-automocker/src/main/java/com/github/fridujo/automocker/base/MockJdbc.java)\n* modifies `javax.sql.DataSource` beans by making them point to a dedicated H2 in-memory database.\n* adds a [`DataSourceResetter`](spring-automocker/src/main/java/com/github/fridujo/automocker/api/jdbc/DataSourceResetter.java) to truncate all tables after each test\n\n##### JMS Connection Factories\nThe extension [`@MockJms`](spring-automocker/src/main/java/com/github/fridujo/automocker/base/MockJms.java)\n* replace all `javax.jms.ConnectionFactory` beans by **mockrunner-jms** `MockConnectionFactory` ones\n* for each `javax.jms.ConnectionFactory` beans adds a [`JmsMock`](spring-automocker/src/main/java/com/github/fridujo/automocker/api/jms/JmsMock.java) with the same qualifiers for simplified JMS operations usage\n* adds a [`DestinationManagerResetter`](spring-automocker/src/main/java/com/github/fridujo/automocker/api/jms/DestinationManagerResetter.java) to remove messages from all queues after each test\n* if available, wraps the `ErrorHandler` of `JmsListenerContainerFactory` to access errors from matching [`JmsMock`](spring-automocker/src/main/java/com/github/fridujo/automocker/api/jms/JmsMock.java)\n\n##### Micrometer Graphite Meter Registry\nThe extension [`@MockMicrometerGraphite`](spring-automocker/src/main/java/com/github/fridujo/automocker/base/MockMicrometerGraphite.java) replaces the default `GraphiteReporter` by one baked by [`GraphiteMock`](spring-automocker/src/main/java/com/github/fridujo/automocker/api/metrics/GraphiteMock.java) which can be injected like any other bean.\n\n##### RabbitMQ Connection Factories\nThe extension [`@MockAmqp`](spring-automocker/src/main/java/com/github/fridujo/automocker/base/MockAmqp.java) replaces all `org.springframework.amqp.rabbit.connection.ConnectionFactory` beans by **rabbitmq-mock** ones.\n\n### Utilities\nThe extension [`@RegisterTools`](spring-automocker/src/main/java/com/github/fridujo/automocker/base/RegisterTools.java) registers a [`BeanLocator`](spring-automocker/src/main/java/com/github/fridujo/automocker/api/tools/BeanLocator.java) to easily access beans by partial name.\n\n## Example Use\n\nAs Spring-Automocker uses **spring-test** `org.springframework.test.context.ContextCustomizerFactory` extension mechanism, it is compatible with Spring \u003e= 4.3 (so spring-boot \u003e= 1.4).\n\n### Using JUnit 4\n\nUse `SpringJUnit4ClassRunner` in conjuction with `@Automocker`\n\n```java\n@Automocker\n@RunWith(SpringJUnit4ClassRunner.class)\n@ContextConfiguration(classes = MyApplication.class)\npublic class MyApplicationTest {\n\n    @Autowired\n    private MyService service;\n\n\t@Test\n\tpublic void my_test() {\n\t\t// test injected service\n\t}\n}\n```\n\n### Using JUnit 5\n\nUse `@ExtendWith(SpringExtension.class)` in conjuction with `@Automocker`\n\n```java\n@Automocker\n@ExtendWith(SpringExtension.class)\n@ContextConfiguration(classes = MyApplication.class)\npublic class MyApplicationTest {\n\n    @Autowired\n    private MyService service;\n\n\t@Test\n\tpublic void my_test() {\n\t\t// test injected service\n\t}\n}\n```\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\u003espring-automocker\u003c/artifactId\u003e\n    \u003cversion\u003e1.1.0\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:spring-automocker:1.1.0')\n\t// ...\n}\n```\n\n### Building from Source\n\nYou need [JDK-8](http://jdk.java.net/8/) to build Spring-Automocker. Core and samples can be built with Maven using the following command.\n```\nmvn clean package\n```\n\nAll features can be tested through samples with Maven using the following command.\n```\nmvn clean test\n```\n\nSince Maven has incremental build support, you can usually omit executing the clean goal.\n\n### Installing in the Local Maven Repository\n\nCore and samples can be installed in a local Maven Repository for usage in other projects via the following command.\n```\nmvn clean install\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridujo%2Fspring-automocker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffridujo%2Fspring-automocker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffridujo%2Fspring-automocker/lists"}