Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wiremock request matching for urlPathPattern is not working with MockRestServiceServer #740

Closed
javaw0rkspace opened this issue Sep 22, 2018 · 0 comments

Comments

@javaw0rkspace
Copy link

I am testing Spring boot REST API using Junit4 and Wiremock. Both JSON and Java mapping is working perfectly with the following code

My Test class

@Rule
  public WireMockRule wireMockRule = new WireMockRule(wireMockConfig().port(8080).httpsPort(443));
stubFor(get(urlMatching("/validation/session/([a-zA-Z0-9/-]*)"))
          .willReturn(aResponse().withStatus(HttpStatus.OK.value()).withHeader("Content-Type", "application/json")
              .withBody("{\"isIpBlocked\": \"Y\"}")));

Stub mapping

{
	"request": {
		"method": "GET",
		"urlPathPattern": "/validation/session/([a-zA-Z0-9/-]*)"
	},
	"response": {
		"status": 200,
		"jsonBody": {
			"isIpBlocked": "Y",
			"serviceMessage": {
				"type": "OK",
				"code": "200",
				"description": "IP validated successfully. No result found"
			}
		},
		"headers": {
			"Content-Type": "application/json"
		}
	}
}

Match the URL
https://mywebsite/validation/session/687d69ae-42a8-4584-a395-8e0c876bacae

But the same is not working if I use

  MockRestServiceServer server = WireMockRestServiceServer.with(this.restTemplate)
      .stubs("classpath:/stubs/**/validate-ip-success-mock-response.json").build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants