Spring boot and @PactBroker is not working as expected with system properties
See original GitHub issueIn Spring Boot you can provide an application.properties/application.yml file that contains system properties and environment properties.
I use some of the system variables in my test
PactVerificationTest.java
@RunWith(SpringRestPactRunner.class)
@Provider("someprovider")
@IgnoreNoPactsToVerify
@PactBroker(
protocol = "https",
host = "${pactbroker.host}", port = "${pactbroker.port}",
authentication = @PactBrokerAuth(username = "${pactbroker.auth.username}", password = "${pactbroker.auth.password}")
)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.DEFINED_PORT)
public class PactVerificationTest {
@TestTarget
public final Target target = new HttpTarget(50519);
@MockBean
private EmailController emailController;
@Before
public void beforeTests() {
doNothing().when(emailController).sendEmail(any(Email.class));
}
@State({"default", "extra"})
public void toDefaultState() {
System.out.println("Now service in default state");
}
}
And then I name these variables in the configuration file
application.yml
pactbroker:
host: "my.host.name.org"
port: "443"
auth:
username: "myusername"
password: "mypassword"
Unfortunately this does not work and I get a RuntimeError
java.lang.RuntimeException: Could not resolve property "pactbroker.host" in the system properties or environment variables and no default value is supplied
So it seems as it wont read the variables.
Versions: Spring Boot 2.0.0.M7 au.com.dius:pact-jvm-provider-spring_2.12 3.5.11
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (4 by maintainers)
Top Results From Across the Web
Spring boot and @PactBroker is not working as expected with ...
In Spring Boot you can provide an application.properties/application.yml file that contains system properties and environment properties.
Read more >Having trouble in verifying the PACT from provider side using ...
Consumer side is working fine. It has generated pact and published too on pact broker URL. Yes it is expecting a status code...
Read more >Pact junit runner | Pact Docs
The pact broker loader was updated to allow system properties to be used for the hostname, port or protocol. The port was changed...
Read more >Spring Cloud Contract Reference Documentation
We talk about Provider Contracts when it is the producer of the API that defines the contracts and publishes it for all its...
Read more >Writing Contract Tests with Pact in Spring Boot
The unit test will do two things: It verifies that our code can handle the expected provider responses and - as a nice...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This has now been implemented. I have a test project https://github.com/uglyog/pact-springboot-test with this working nicely.
3.5.14 has now been released