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.server.port is not defined if port is not explicitly set or if it is set to 8080 #1920

Closed
josephearl opened this issue Jul 10, 2023 · 2 comments
Labels
Milestone

Comments

@josephearl
Copy link

josephearl commented Jul 10, 2023

Describe the bug

In my test I have something like:

@AutoConfigureWireMock
@SpringBootTest(properties = {"some.url=http://localhost:${wiremock.server.port}"})

With this I get an error:

Could not resolve placeholder 'wiremock.server.port' in value "http://localhost:${wiremock.server.port}"

If I explicitly set a port in @AutoConfigureWireMock(port = 8765), even 0 to randomly allocate a port, then it works - except for if I explicitly set it to 8080 (the default), then it no longer works

This used to work with Spring Boot 2.7 / Spring 5

I would expect it to set the property value to 8080 which is the WireMock default

Using version 4.0.3 of spring-cloud-contract-wiremock

@josephearl josephearl changed the title wiremock.server.port is not defined if port is not explicitly set wiremock.server.port is not defined if port is not explicitly set or if it is set to 8080 Jul 10, 2023
@marcingrzejszczak marcingrzejszczak added this to the 3.1.9 milestone Sep 4, 2023
@github-project-automation github-project-automation bot moved this to Done in 2021.0.9 Sep 4, 2023
@github-project-automation github-project-automation bot moved this to Done in 2022.0.x Sep 4, 2023
@mohamed-asfour
Copy link

Hello,
it seems that this fix lead to undesired behaviour by defaulting the server port always to 8080 after setting it once to a random port.
This block replaces the wiremock.server.port property even if it has been already set
else { Map<String, Object> source = getWireMockSource(environment); source.put("wiremock.server.port", 8080); if (log.isDebugEnabled()) { log.debug("Registered WireMock server port property to the default <8080> value"); } }
could you please be kind and have a look on this issue?

Thanks in Advance

@marcingrzejszczak
Copy link
Contributor

Argh sorry. Can you open a new issue please? I guess as a workaround you should go with the dynamic approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Status: Done
Development

No branches or pull requests

4 participants