Questions tagged [wiremock]

Library used for stubbing and mocking web services.

Wiremock is a library written in Java by Tom Akehurst. It is used for stubbing and mocking web services. It supports HTTP response stubbing, request verification, proxy/intercept, record/playback of stubs and fault injection, and can be used from within a unit test or deployed into a test environment.

For more information see http://wiremock.org

894 questions
15
votes
4 answers

java.lang.IllegalStateException: No Server ALPNProcessors - WireMock

I am trying to run unit tests (that use Wiremock) on my maven project and the following error is observed. java.lang.IllegalStateException: No Server ALPNProcessors I tried adding the alpn-boot-8.1.12.v20180117.jar to the Xbootclasspath as…
JavaTechnical
  • 8,846
  • 8
  • 61
  • 97
15
votes
3 answers

Using WireMock with SOAP Web Services in Java

I am totally new to WireMock. Until now, I have been using mock responses using SOAPUI. My use case is simple: Just firing SOAP XML requests to different endpoints (http://localhost:9001/endpoint1) and getting canned XML response back. But MockWrire…
Anurag
  • 723
  • 3
  • 13
  • 31
15
votes
4 answers

Wiremock returning 404 for a stubbed url

I have defined wireMock server as follows:- private WireMockServer wireMockServer; @Before public void preSetup() throws Exception { wireMockServer = new WireMockServer(56789); wireMockServer.start(); …
tuk
  • 5,941
  • 14
  • 79
  • 162
14
votes
2 answers

Difference between WireMockServer vs MockServerClient

I am trying to understand what is the difference between two frameworks which are MockServerClient( or org.mockserver.integration.ClientAndServer) and WireMockServer?Can they be exchanged? I read the docs. but could not figure out what is the…
James
  • 441
  • 2
  • 6
  • 9
14
votes
1 answer

WireMock in Junit in Jenkins - BindException: Address already in use

I have some Junit test in which I use WireMock. Locally the tests pass, but on Jenkins I get an error of java.lang.RuntimeException: java.net.BindException: Address already in use In the WireMock configuration I set dynamicHttpsPort() (which…
yishaiz
  • 2,433
  • 4
  • 28
  • 49
13
votes
4 answers

How to fix "NoHttpResponseException" when running Wiremock on jenkins?

I start a wiremock server in a integration test. The IT pass in my local BUT some case failed in jenkins server, the error is localhost:8089 failed to respond; nested exception is org.apache.http.NoHttpResponseException: localhost:8089 failed to…
Alvin
  • 133
  • 1
  • 1
  • 7
13
votes
1 answer

Why we should use wiremock instead of Mockito

I am having Restclient class which makes a rest call to URL whenever GET method is called on the Restclient object. I have a proper logic working behind. Now Consider a case instead of using wiremock I used Mockito to mock the method GET on the…
am10
  • 449
  • 1
  • 6
  • 17
13
votes
4 answers

Matching data in JsonPath with wiremock

I'm trying to create mocks for my login procedure. I use POST method with a couple of fields and login object (with login, password, etc.) For that I'm using JsonPath. Code below: { "request": { "method": "POST", "url": "/login", …
a_dzik
  • 927
  • 2
  • 11
  • 24
12
votes
5 answers

How to get wiremock running before the spring boot application status up?

I have an integration test for a spring boot micro-service. The problem is that the service calls an external service (via REST) on startup. I’m using WireMock to mock the call. Spring makes the application start before WireMock is started. Because…
Yacine Ait Yaiz
  • 133
  • 1
  • 1
  • 6
11
votes
4 answers

How to use WireMock's response template in JUnit 5 Tests

I'm trying to use the Response Templating feature of WireMock, but it does not seem to work with the sample piece of code provided in the docs. This is a sample piece of code: import static…
Kenpachi
  • 651
  • 1
  • 10
  • 21
11
votes
3 answers

How to make Spring Cloud Contract reset WireMock before or after each test

We are writing a Spring Boot application and use the Cloud Contract WireMock support to stub a backing service. Our test class is annotated like so: @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment =…
arcimboldo
  • 121
  • 1
  • 1
  • 5
11
votes
2 answers

Wiremock bodyFileName templating

I'm using Wiremock to stub out some API calls made by mobile clients. Struggling to get templated filename from request. Can anyone confirm if this should even work with Wiremock standalone pls? "response": { "status": 200, "bodyFileName":…
iFrame
  • 111
  • 1
  • 5
11
votes
2 answers

Wiremock : how to upload file to folder __files with API

the documentation of wiremock says that we can mock a a request that retrieve a file thanks to this code : { "request": { "method": "GET", "url": "/body-file" }, "response": { "status": 200, …
kenji_getpowered
  • 338
  • 2
  • 10
10
votes
3 answers

Wiremock query parameter JSON stub file

I'm trying to mock query parameter using a wiremock JSON stub file. It works when I do it this way : { "request": { "method": "GET", "url": "/posts?id=1", }, //... } However when I change my query parameter to use the dedicated field…
Robert jardonneau
  • 434
  • 2
  • 4
  • 14
10
votes
2 answers

Wiremock Stand alone - How to manipulate response with request data

I was trying to implement mocking of POST REST call using Wiremock Standalone server. I am faced with a challenge like this, suppose the post body contains an "name" field and its value, the same value should be returned in the response of that POST…
Sam
  • 181
  • 2
  • 3
  • 13
1
2
3
59 60