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

fix: @PactBroker not reading Spring properties with JUnit 5 #1023 #1051

Merged
merged 1 commit into from
Mar 21, 2020
Merged

fix: @PactBroker not reading Spring properties with JUnit 5 #1023 #1051

merged 1 commit into from
Mar 21, 2020

Conversation

arhohuttunen
Copy link
Contributor

Fixes an issue in PactVerificationInvocationContextProvider.resolvePactSources() where calling PactBrokerLoader.description() ignores the value resolver that is being set after the call.

The method calling order breaks the PactVerificationSpringProvider that is trying to override the getValueResolver() method to be able to load broker properties from a Spring Boot application.yml file.

@arhohuttunen
Copy link
Contributor Author

I was also thinking about some kind of test for it, but could not easily figure out a clean way to do it.

What do you think about adding spring-boot-starter-test and spring-boot-starter-web as test dependencies into the pact-jvm-provider-junit5-spring module?

Then you could have a kind of an integration test with this kind of approach:

src/test/resources/application.yml:

pactbroker:
  host: localhost
  port: ${local.server.port}

PactVerificationSpringProviderTest.kt:

@ExtendWith(SpringExtension::class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@Provider("Animal Profile Service")
@PactBroker
@IgnoreNoPactsToVerify
internal class PactVerificationSpringProviderTest {
    @TestTemplate
    @ExtendWith(PactVerificationSpringProvider::class)
    fun pactVerificationTestTemplate(context: PactVerificationContext?) {
        context?.verifyInteraction()
    }
}

@uglyog uglyog merged commit 049ac1f into pact-foundation:master Mar 21, 2020
@uglyog
Copy link
Member

uglyog commented Mar 21, 2020

Thanks for the PR!

You're test method is clever, and I can confirm that it works. I have added those changes to the module.

@arhohuttunen arhohuttunen deleted the fix-1023 branch March 21, 2020 05:03
@uglyog
Copy link
Member

uglyog commented Mar 22, 2020

4.0.8 released with this change

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

Successfully merging this pull request may close these issues.

2 participants