<dependency>
<groupId>io.specto</groupId>
<artifactId>hoverfly-java</artifactId>
<version>0.14.0</version>
<scope>test</scope>
</dependency>
Project Name | Stars | Downloads | Repos Using This | Packages Using This | Most Recent Commit | Total Releases | Latest Release | Open Issues | License | Language |
---|---|---|---|---|---|---|---|---|---|---|
Stretch | 1,837 | 5 | 11 | 6 months ago | 17 | July 04, 2019 | 45 | mit | Rust | |
High performance flexbox implementation written in rust | ||||||||||
Nut.js | 1,553 | 5 | a month ago | 181 | June 01, 2022 | 27 | apache-2.0 | TypeScript | ||
Native UI testing / controlling with node | ||||||||||
Airplay | 1,062 | 26 | 3 | 7 months ago | 25 | August 04, 2015 | 28 | mit | Ruby | |
Airplay bindings to Ruby | ||||||||||
Metascala | 1,030 | 6 years ago | Scala | |||||||
A JVM written in Scala | ||||||||||
Deepstream_python_apps | 975 | 4 months ago | other | Jupyter Notebook | ||||||
DeepStream SDK Python bindings and sample applications | ||||||||||
Awesome Selenium | 828 | 9 months ago | cc0-1.0 | |||||||
A curated list of delightful Selenium resources. | ||||||||||
Jest | 682 | 4 | a month ago | 25 | May 08, 2022 | 24 | mit | TypeScript | ||
Super-fast alternative for babel-jest or ts-jest without type checking. Please use main repository for issues | ||||||||||
Mmtk Core | 261 | 1 | 17 hours ago | 2 | June 27, 2022 | 202 | other | Rust | ||
Memory Management ToolKit | ||||||||||
Modern Wasm Starter | 197 | 8 months ago | 26 | October 12, 2022 | 1 | unlicense | TypeScript | |||
🛸 Run C++ code on web and create blazingly fast websites! A starter template to easily create WebAssembly packages using type-safe C++ bindings with automatic TypeScript declarations. | ||||||||||
Webdriver Php | 185 | 7 years ago | 25 | PHP | ||||||
PHP bindings for WebDriver (Selenium 2 API). |
A Java native language binding for Hoverfly, a Go proxy which allows you to simulate http services in your unit tests. Another term for this is Service Virtualisation.
Simulation of http/https services
Strict or loose http request matching based on URL, method, body and header combinations
Fluent and expressive DSL for easy generation of simulated services
Automatic marshalling of objects into JSON during request / response body generation
Create simulations by capturing live traffic
Hoverfly is a proxy, so you don’t need to alter the host that you make requests to
Multiple hosts / services per single instance of Hoverfly
Https automatically supported, no extra configuration required
Supports Mutual TLS authentication capture
Interoperable with standard Hoverfly JSON, making it easy to re-use data between Java and other native language bindings.
Use externally managed Hoverfly cluster for API simulations
Request verification
Response templating
Stateful capture / simulation
Full documentation is available here
<dependency>
<groupId>io.specto</groupId>
<artifactId>hoverfly-java</artifactId>
<version>0.14.0</version>
<scope>test</scope>
</dependency>
// Capture and output HTTP traffic to json file
@ClassRule
public static HoverflyRule hoverflyRule = HoverflyRule.inCaptureMode("simulation.json");
// After the capturing, switch to inSimulationMode to spin up a stub server
@ClassRule
public static HoverflyRule hoverflyRule = HoverflyRule.inSimulationMode(defaultPath("simulation.json"));
// Or you can use both approaches at once. If json file not present in capture mode, if present in simulation mode
@ClassRule
public static HoverflyRule hoverflyRule = HoverflyRule.inCaptureOrSimulationMode("simulation.json");
@ClassRule
public static HoverflyRule hoverflyRule = HoverflyRule.inSimulationMode(dsl(
service("www.my-test.com")
.get("/api/bookings/1")
.willReturn(created("http://localhost/api/bookings/1"))
));
@Test
public void shouldBeAbleToGetABookingUsingHoverfly() {
// When
final ResponseEntity<String> getBookingResponse = restTemplate.getForEntity("http://www.my-test.com/api/bookings/1", String.class);
// Then
assertEquals(bookFlightResponse.getStatusCode(), CREATED);
assertEquals(bookFlightResponse.getHeaders().getLocation(), "http://localhost/api/bookings/1");
}
Some code examples for the DSL are available here.
More code examples for the DSL using request matchers can be found here.
// Verify that at least one request to a specific endpoint with any query params
hoverflyRule.verify(service(matches("*.flight.*")).get("/api/bookings").anyQueryParams(), atLeastOnce());
// Verify that an external service/dependency was not called
hoverflyRule.verifyZeroRequestTo(service(matches("*.flight.*")));
// Verify all the stubbed requests were made at least once
hoverflyRule.verifyAll();
Contributions are welcome!
To submit a pull request you should fork the Hoverfly-Java repository, and make your change on a feature branch of your fork.
As 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.
If you have forked this project prior to v0.10.2
, please re-fork to get a slimmer version of the repository.
Feel free to raise an issues on Github.
Apache License version 2.0.
(c) SpectoLabs 2020.