{"id":19940747,"url":"https://github.com/spectolabs/hoverfly-java","last_synced_at":"2025-04-08T08:14:26.147Z","repository":{"id":5363120,"uuid":"52800193","full_name":"SpectoLabs/hoverfly-java","owner":"SpectoLabs","description":"Java binding for Hoverfly","archived":false,"fork":false,"pushed_at":"2025-03-06T04:55:43.000Z","size":1685,"stargazers_count":169,"open_issues_count":17,"forks_count":59,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-01T05:34:31.423Z","etag":null,"topics":["api-simulation","hoverfly","http","https","java","mocking","proxy","service-virtualization","stubbing","testing","testing-tools"],"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/SpectoLabs.png","metadata":{"files":{"readme":"README.adoc","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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,"publiccode":null,"codemeta":null}},"created_at":"2016-02-29T15:07:12.000Z","updated_at":"2025-02-11T11:25:56.000Z","dependencies_parsed_at":"2023-12-19T01:29:48.051Z","dependency_job_id":"452088b1-f21a-4119-be29-13ca6c06d136","html_url":"https://github.com/SpectoLabs/hoverfly-java","commit_stats":{"total_commits":724,"total_committers":40,"mean_commits":18.1,"dds":0.5662983425414365,"last_synced_commit":"dd92035caa8902d3d1a990d69ef0e3897ca177cb"},"previous_names":[],"tags_count":70,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectoLabs%2Fhoverfly-java","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectoLabs%2Fhoverfly-java/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectoLabs%2Fhoverfly-java/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SpectoLabs%2Fhoverfly-java/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SpectoLabs","download_url":"https://codeload.github.com/SpectoLabs/hoverfly-java/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247801169,"owners_count":20998339,"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":["api-simulation","hoverfly","http","https","java","mocking","proxy","service-virtualization","stubbing","testing","testing-tools"],"created_at":"2024-11-13T00:06:45.354Z","updated_at":"2025-04-08T08:14:26.057Z","avatar_url":"https://github.com/SpectoLabs.png","language":"Java","readme":"== Hoverfly Java - Easy Creation of Stub Http Servers for Testing\n\nimage:https://circleci.com/gh/SpectoLabs/hoverfly-java.svg?style=shield[\"CircleCI\", link=\"https://circleci.com/gh/SpectoLabs/hoverfly-java\"]\nimage:https://readthedocs.org/projects/hoverfly-java/badge/?version=latest[\"Read the Docs\", link=\"https://hoverfly-java.readthedocs.io/en/latest/\"]\nimage:https://codecov.io/gh/spectolabs/hoverfly-java/branch/master/graph/badge.svg[\"Codecov\", link=\"https://codecov.io/gh/spectolabs/hoverfly-java\"]\nimage:https://snyk.io/test/github/SpectoLabs/hoverfly-java/badge.svg?targetFile=build.gradle[\"Known Vulnerabilities\", link=\"https://snyk.io/test/github/SpectoLabs/hoverfly-java?targetFile=build.gradle\"]\nimage:https://img.shields.io/maven-central/v/io.specto/hoverfly-java.svg[\"Maven Central\", link=\"https://mvnrepository.com/artifact/io.specto/hoverfly-java\"]\n\nA Java native language binding for http://hoverfly.io/[Hoverfly^], a Go proxy which allows you to simulate http services in your unit tests. Another term\nfor this is https://en.wikipedia.org/wiki/Service_virtualization[Service Virtualisation^].\n\n== Features\n\n- Simulation of http/https services\n- Strict or loose http request matching based on URL, method, body and header combinations\n- Fluent and expressive DSL for easy generation of simulated services\n- Automatic marshalling of objects into JSON during request / response body generation\n- Create simulations by capturing live traffic\n- Hoverfly is a proxy, so you don't need to alter the host that you make requests to\n- Multiple hosts / services per single instance of Hoverfly\n- Https automatically supported, no extra configuration required\n- Supports Mutual TLS authentication capture\n- Interoperable with standard Hoverfly JSON, making it easy to re-use data between Java and other native language bindings.\n- Use externally managed Hoverfly cluster for API simulations\n- Request verification\n- Response templating\n- Stateful capture / simulation\n- http://hoverfly-java.readthedocs.io/en/latest/pages/junit5/junit5.html[JUnit 5 extension^]\n\n== Documentation\n\nFull documentation is available http://hoverfly-java.readthedocs.io/[here^]\n\n== Maven Dependency\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003eio.specto\u003c/groupId\u003e\n    \u003cartifactId\u003ehoverfly-java\u003c/artifactId\u003e\n    \u003cversion\u003e0.19.0\u003c/version\u003e\n    \u003cscope\u003etest\u003c/scope\u003e\n\u003c/dependency\u003e\n```\n\n== Example\n=== Create API simulation using capture mode\n``` java\n// Capture and output HTTP traffic to json file\n@ClassRule\npublic static HoverflyRule hoverflyRule = HoverflyRule.inCaptureMode(\"simulation.json\");\n\n\n// After the capturing, switch to inSimulationMode to spin up a stub server\n@ClassRule\npublic static HoverflyRule hoverflyRule = HoverflyRule.inSimulationMode(defaultPath(\"simulation.json\"));\n\n// Or you can use both approaches at once. If json file not present in capture mode, if present in simulation mode\n@ClassRule\npublic static HoverflyRule hoverflyRule = HoverflyRule.inCaptureOrSimulationMode(\"simulation.json\");\n```\n=== Create API simulation using DSL\n```java\n\n@ClassRule\npublic static HoverflyRule hoverflyRule = HoverflyRule.inSimulationMode(dsl(\n    service(\"www.my-test.com\")\n        .get(\"/api/bookings/1\")\n        .willReturn(created(\"http://localhost/api/bookings/1\"))\n));\n\n@Test\npublic void shouldBeAbleToGetABookingUsingHoverfly() {\n    // When\n    final ResponseEntity\u003cString\u003e getBookingResponse = restTemplate.getForEntity(\"http://www.my-test.com/api/bookings/1\", String.class);\n\n    // Then\n    assertEquals(bookFlightResponse.getStatusCode(), CREATED);\n    assertEquals(bookFlightResponse.getHeaders().getLocation(), \"http://localhost/api/bookings/1\");\n}\n```\n\nSome code examples for the DSL are available https://github.com/SpectoLabs/hoverfly-java/blob/master/src/test/java/io/specto/hoverfly/ruletest/HoverflyDslTest.java[here^].\n\nMore code examples for the DSL using request matchers can be found https://github.com/SpectoLabs/hoverfly-java/blob/master/src/test/java/io/specto/hoverfly/ruletest/HoverflyDslMatcherTest.java[here^].\n\n\n=== Verify requests\n```java\n\n// Verify that at least one request to a specific endpoint with any query params\nhoverflyRule.verify(service(matches(\"*.flight.*\")).get(\"/api/bookings\").anyQueryParams(), atLeastOnce());\n\n// Verify that an external service/dependency was not called\nhoverflyRule.verifyZeroRequestTo(service(matches(\"*.flight.*\")));\n\n// Verify all the stubbed requests were made at least once\nhoverflyRule.verifyAll();\n\n```\n== Contributions\n\nContributions are welcome!\n\nTo submit a pull request you should fork the Hoverfly-Java repository, and make your change on a feature branch of your fork.\n\nAs of `v0.10.2`, hoverfly binaries are no longer stored in the repository. You should run `./gradlew clean test` once to cache the binaries for development with your IDE.\n\nIf you have forked this project prior to `v0.10.2`, please re-fork to get a slimmer version of the repository.\n\n== Issues\n\nFeel free to raise an issues on Github.\n\n== License\n\nApache License version 2.0.\n\n(c) https://ioco.uk/[iOCO^] 2024.\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectolabs%2Fhoverfly-java","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspectolabs%2Fhoverfly-java","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspectolabs%2Fhoverfly-java/lists"}