diff --git a/spring-cloud-contract-stub-runner/README.adoc b/spring-cloud-contract-stub-runner/README.adoc index d77e8d8a0d..af2200f4a0 100644 --- a/spring-cloud-contract-stub-runner/README.adoc +++ b/spring-cloud-contract-stub-runner/README.adoc @@ -398,7 +398,7 @@ Value of the annotation can be the `groupid.artifactid` or just the `artifactid` ---- @StubRunnerPort("foo") int fooPort; -@StubRunnerPort("com.example.bar") +@StubRunnerPort("com.example:bar") int barPort; ---- diff --git a/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerPortBeanPostProcessor.java b/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerPortBeanPostProcessor.java index 6e2a6dc798..54fb9a1e2e 100644 --- a/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerPortBeanPostProcessor.java +++ b/spring-cloud-contract-stub-runner/src/main/java/org/springframework/cloud/contract/stubrunner/spring/StubRunnerPortBeanPostProcessor.java @@ -53,7 +53,7 @@ class StubRunnerPortFieldCallback implements ReflectionUtils.FieldCallback { ReflectionUtils.makeAccessible(field); String stub = field.getDeclaredAnnotation(StubRunnerPort.class).value(); Integer port = this.environment.getProperty( - StubRunnerConfiguration.STUBRUNNER_PREFIX + "." + stub + ".port", Integer.class); + StubRunnerConfiguration.STUBRUNNER_PREFIX + "." + stub.replace(":", ".") + ".port", Integer.class); if (port != null) { field.set(this.bean, port); } diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy index 438b854de6..30a48e4f2d 100644 --- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy +++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/spring/StubRunnerConfigurationSpec.groovy @@ -51,7 +51,7 @@ class StubRunnerConfigurationSpec extends Specification { @Autowired StubFinder stubFinder @Autowired Environment environment @StubRunnerPort("fraudDetectionServer") int fraudDetectionServerPort - @StubRunnerPort("org.springframework.cloud.contract.verifier.stubs.fraudDetectionServer") int fraudDetectionServerPortWithGroupId + @StubRunnerPort("org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer") int fraudDetectionServerPortWithGroupId @Value('${foo}') Integer foo @BeforeClass @@ -96,6 +96,9 @@ class StubRunnerConfigurationSpec extends Specification { and: environment.getProperty("stubrunner.runningstubs.fraudDetectionServer.port") != null stubFinder.findAllRunningStubs().getPort("fraudDetectionServer") == (environment.getProperty("stubrunner.runningstubs.fraudDetectionServer.port") as Integer) + and: + environment.getProperty("stubrunner.runningstubs.fraudDetectionServer.port") != null + stubFinder.findAllRunningStubs().getPort("fraudDetectionServer") == (environment.getProperty("stubrunner.runningstubs.org.springframework.cloud.contract.verifier.stubs.fraudDetectionServer.port") as Integer) } def 'should be able to interpolate a running stub in the passed test property'() {