Small update on the annotation

This commit is contained in:
Marcin Grzejszczak
2018-03-16 16:14:55 +01:00
parent 32888e3b92
commit c3d7e2721d
3 changed files with 6 additions and 3 deletions

View File

@@ -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;
----

View File

@@ -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);
}

View File

@@ -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'() {