https://linen.dev logo
#wiremock-java
Title
# wiremock-java
o

Oleg Nenashev

11/23/2023, 8:39 PM
FYI @Eric Deandrea, WDYT about a WireMock Dev Service? https://github.com/quarkiverse/quarkus-wiremock/issues/58
I mean, technically it is a Dev Service, but not a containerized one
e

Eric Deandrea

11/27/2023, 1:00 PM
Sorry for the delay in getting back to you. I was out on Thanksgiving Holiday. As for a Wiremock dev service I definitely see value in it. I see 2 real uses cases: 1. Running during dev mode. This would be pretty “static”, meaning providing a consistent API for other downstream services the application may talk to. Microcks (https://github.com/microcks/microcks-quarkus) is doing something similar to this. You point it at the other service’s OpenAPI documents (or other artifacts for other types of services) and it will automatically proxy those services. We’re using this today in the Quarkus sample application (https://github.com/quarkusio/quarkus-super-heroes/tree/main/rest-fights#integration-with-microcks) 2. Running when running tests. This could be “static”, like dev mode, but could also be more dynamic. This is where the application would set different responses for different test scenarios within unit/integration tests. We’re doing this today in the Quarkus sample application.
To be honest I didn’t realize there was a quarkus wiremock extension. Looking at the documentation (https://wiremock.org/docs/solutions/quarkus/) I don’t really see a solution for my #2 use case above.
o

Oleg Nenashev

11/27/2023, 1:02 PM
Actually it supports Integration tests
I was doing the presentation on the integration on friday, and here is my demo: https://github.com/wiremock/wiremock-quarkus-devservice-demo It works pretty well with @QuarkusTest
e

Eric Deandrea

11/27/2023, 1:07 PM
I see
@ConnectWireMock
in your test, but in the source code for the extension I don’t see that annotation?
oh wait nevermind I found it
its in a separate artifact
o

Oleg Nenashev

11/27/2023, 1:09 PM
Yep. Comes from the test jar. It is documented but not 100% trivial. Once we have an official REST API client distribution, it will be easier
e

Eric Deandrea

11/27/2023, 1:10 PM
how would the dev service work if i needed to reconfigure other properties based on the Wiremock url/port? For example, I may need to configure a rest client property, something I would generally do inside a
QuarkusTestResourceLifecycleManager
Does the wiremock extension expose properties that I could read?
o

Oleg Nenashev

11/27/2023, 1:12 PM
Right now it is not supported, I submitted a GitHub issue last week. Right now you have to fix the port, because there is no real-time propagation, and it's not something sustainable
e

Eric Deandrea

11/27/2023, 1:12 PM
gotcha
for example, the microcks extension exposes some properties that can be used in the app configuration. Kinda like this: https://github.com/quarkusio/quarkus-super-heroes/blob/main/rest-fights/src/main/resources/application.properties#L41
(something I contributed to that extension 🙂 )
o

Oleg Nenashev

11/27/2023, 1:13 PM
Yep. This is what one needs to do with WireMock too
e

Eric Deandrea

11/27/2023, 1:14 PM
but this is definitely a good start
o

Oleg Nenashev

11/27/2023, 1:15 PM
So yeah, I might just copy-paste the implementation 🙂 https://github.com/quarkiverse/quarkus-wiremock/issues/68 Actually there is a PR from maintainer now: https://github.com/quarkiverse/quarkus-wiremock/pull/74
🎉 1
Once its a little more stable i can certainly pull this into the sample application
🙌 1
i’d love to get the grpc extension in there too. Right now I’m using something else because verification wasn’t yet there in the wiremock extension
o

Oleg Nenashev

11/27/2023, 1:19 PM
Verification means contract testing for the spec, right?
o

Oleg Nenashev

11/27/2023, 1:20 PM
Once its a little more stable i can certainly pull this into the sample application
Great! I will keep evolving my example too, because I have a few Quarkus talks submitted
e

Eric Deandrea

11/27/2023, 1:20 PM
although I’m not sure if that PR has made it into a release yet, because I don’t see any updated docs around it on https://wiremock.org/docs/grpc/
i actually did my own PR for that functionality not realizing that Tom had done it too! https://github.com/wiremock/wiremock-grpc-extension/pull/11
2 Views