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
7
votes
1 answer

Wiremock error: Request was not matched as there were no stubs registered

@ClassRule public static WireMockRule wireMockRule = new WireMockRule(9898); @Test public void createXmlFile() { stubFor(get(urlPathEqualTo("/data/racing/")) .willReturn(aResponse() …
krmanish007
  • 6,749
  • 16
  • 58
  • 100
7
votes
2 answers

Wiremock Capture path param and return in the response body

I am trying to create dynamic mocks using WireMock. I have a situation where if I specify URL like : http://localhost:8089/api/account/abc@abc.com then I should receive response like: { "account" : "abc@abc.com" } In brief, the path param is…
JavaMan
  • 465
  • 1
  • 6
  • 21
7
votes
1 answer

Get "Failed to load class org.slf4j.impl.StaticLoggerBinder" error when I run wiremock.jar on MAC

How about the case of running WireMock in the terminal with java -jar wiremock-standalone.jar? Shouldn't console logging be enabled? Steps: I downloaded the jar from:…
yoyoalphax
  • 71
  • 1
  • 3
7
votes
1 answer

How can I specify optional Query Parameters

I defined query parameter in my contract. I need this parameter to be optional: method 'GET' url($(regex(urlRegex))) { queryParameters { parameter 'fitler': $(stub(regex(filterRegex))) } } I want this contract to be…
yaroslavTir
  • 711
  • 2
  • 10
  • 22
7
votes
3 answers

ClassNotFoundException with Wiremock 2.5.1 and Spring Boot 1.5.1

I'm having problems when trying to configure a test infrastructure in Spring Boot 1.5.1.RELEASE and Wiremock 2.5.1. It's throwing: java.lang.NoClassDefFoundError: org/apache/http/client/HttpClient at…
Pimenta
  • 113
  • 1
  • 1
  • 7
7
votes
2 answers

How to enable HTTPS for standalone Wiremock

Overview: I used wiremock standalone 2.1.11 and did the following to enable HTTPS URL for my request but to no avail: Studying the doc http://wiremock.org/docs/running-standalone/ Adding --https-port but nothing happened Adding keystore but…
saeedj
  • 2,179
  • 9
  • 25
  • 38
7
votes
1 answer

How to use WireMock on a Feign client in a Spring Boot application?

I have a class that makes use of a Feign client. Previously I used Mockito and gave a stored response for each of the method calls in the Feign client. Now I want to use WireMock, so that I can see that my code handles different kinds of response…
L42
  • 3,052
  • 4
  • 28
  • 49
7
votes
1 answer

HttpHostConnectException when initializing WireMock HTTP server

I'm trying to test my code that has an underlying GET call to an HTTP server. I am trying to use WireMock, and base on the "Getting Started" I have the following code: @Rule public WireMockRule wireMockRule = new…
summerbulb
  • 5,709
  • 8
  • 37
  • 83
6
votes
3 answers

Is there a way to get list of loaded properties file in SpringBoot application?

I'm facing an issue on only one platform when I'm trying to execute mvn clean install. As part of the build we compile multiple component and last we execute functional testing using wiremock. It is supposed to pick specific configuration from…
6
votes
2 answers

Multiple Application Contexts in Spring JUnit test with WireMock

I have the following scenario: @Transactional @SpringBootTest @ActiveProfiles("test") @AutoConfigureMockMvc @AutoConfigureWireMock(port = 0) public abstract class IntegrationTest { } public class Test1 extends IntegrationTest { // Tests that use…
Jordan Silva
  • 833
  • 8
  • 18
6
votes
1 answer

WireMock unable to set log4j level to INFO instead of DEBUG

I'm running JUnit testcases with WireMock. Embedded Jetty Server is configured as follows. @Before public void setup() { final ResponseTemplateTransformer theTemplateTransformer = new ResponseTemplateTransformer(false); …
user10417331
6
votes
1 answer

Special characters in @QueryParam name in Spring feign client

One of our external API uses query param names with special characters (don't ask me why, I don't know). My feign client's method for this API is declared like this: @GetMapping("/v1/user/{userId}/orders") List getOrders( …
zolv
  • 1,720
  • 2
  • 19
  • 36
6
votes
2 answers

Mocking libraries with server sent events (SSE) support

I am considering usage of "WireMock" utility in order to create simple simulators of HTTP based APIs for my automatic tests. My problem is that some of the tests require server sent events (SSE), which is (as far as I read in their github comments)…
pinpinokio
  • 505
  • 5
  • 19
6
votes
1 answer

WireMock uses wrong __files directory for multi-directory mappings configuration

I'm using Spring Boot with spring-cloud-contract-wiremock and com.github.tomakehurst.wiremock dependencies. My wiremock definitions are stored in json files. Like that: directoryA/mappings/detail-mapping-123.json: { "request" : { "urlPath" :…
Krzysiek
  • 615
  • 8
  • 19
6
votes
0 answers

Wiremock recording not saving request headers

I am trying to use Wiremocks record and playback feature to record a number of requests. The service I am calling returns different values depending on the headers that are sent in the request so I need the recording to capture the headers. I am…
user889829
  • 388
  • 2
  • 7
  • 20