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

Eric Deandrea

12/05/2023, 7:38 PM
Hello! I’ve started integrating wiremock-grpc. Question - does it support adding delays to mock responses? I can’t seem to find that anywhere in the API…
o

Oleg Nenashev

12/06/2023, 9:48 AM
@Tom ^
t

Tom

12/06/2023, 10:09 AM
Yes, but at the moment you need to use the core WireMock DSL. We haven't added delays to the extension DSL yet.
e

Eric Deandrea

12/06/2023, 3:20 PM
Would that look something like this?
Copy code
this.wireMock.register(
      <http://WireMock.post|WireMock.post>(grpcUrlPath(LocationsGrpc.SERVICE_NAME, "GetRandomLocation"))
        .willReturn(
          message(DEFAULT_GRPC_LOCATION).build()
            .withFixedDelay(3_000)
        )
    );
if so, it doesn’t seem to work. It doesn’t respect the delay (it does serve the response immediately)
t

Tom

12/06/2023, 8:49 PM
Yes, apologies - the gRPC extension has the effect of skipping the delay code so it needs to be factored out into a library class in WireMock core, then used in the extension.
👍 1
3 Views