An open API service indexing awesome lists of open source software.

https://github.com/t1/quarkus-wiremock-demo

Demonstrates how to use the Quarkus WireMock Extension
https://github.com/t1/quarkus-wiremock-demo

Last synced: about 2 months ago
JSON representation

Demonstrates how to use the Quarkus WireMock Extension

Awesome Lists containing this project

README

          

= Quarkus WireMock Extension Demo

Demonstrates how to use the https://docs.quarkiverse.io/quarkus-wiremock/dev/index.html[Quarkus WireMock Extension]... with a little helper for the mocking.

The two interesting classes are:

- https://github.com/t1/quarkus-wiremock-demo/blob/trunk/src/test/java/com/github/t1/WireMocker.java[`WireMocker`] - allows to do the stubbing a litte bit like Mockito with JAX-RS API interfaces.
Reduce boilerplate code for the mocking.
- https://github.com/t1/quarkus-wiremock-demo/blob/trunk/src/test/java/com/github/t1/NameServiceStandardMappings.java[`NameServiceStandardMappings`] - a WireMock extension that adds default stubs.

The latter would be very useful when running Quarkus in dev mode, but this doesn't work:
the extension is not loaded for the dev mode if the `META-INF/services/...Extension` file is in `src/test/resources`... OTOH we don't want to put it in `src/main/resources` because it's only for dev-testing.
Actually, Quarkus starts a _second_ `WireMock` dev-service when running the tests in dev mode.

The only solution I found, is to put mappings files in `src/test/resources/mappings/*.json`.

== Running

To see it all in action, simply run:

[source,shell]
----
mvn quarkus:dev
----

Then type `o` to see the test output, and `r` to run the tests.