@ContextConfiguration(classes = Config, loader = SpringBootContextLoader)
-@SpringBootTest(properties = [" stubrunner.cloud.enabled=false", "stubrunner.camel.enabled=false"])
+@SpringBootTest(properties = [" stubrunner.cloud.enabled=false",
+ "stubrunner.camel.enabled=false",
+ 'foo=${stubrunner.runningstubs.fraudDetectionServer.port}'])
@AutoConfigureStubRunner
@DirtiesContext
@ActiveProfiles("test")
@@ -4608,12 +4610,13 @@ class StubRunnerConfigurationSpec extends Specification {
@Autowired StubFinder stubFinder
@Autowired Environment environment
+ @Value('${foo}') Integer foo
@BeforeClass
@AfterClass
void setupProps() {
- System.clearProperty("stubrunner.repository.root");
- System.clearProperty("stubrunner.classifier");
+ System.clearProperty("stubrunner.repository.root")
+ System.clearProperty("stubrunner.classifier")
}
def 'should start WireMock servers'() {
@@ -4653,6 +4656,15 @@ class StubRunnerConfigurationSpec extends Specification {
stubFinder.findAllRunningStubs().getPort("fraudDetectionServer") == (environment.getProperty("stubrunner.runningstubs.fraudDetectionServer.port") as Integer)
}
+ def 'should be able to interpolate a running stub in the passed test property'() {
+ given:
+ int fraudPort = stubFinder.findAllRunningStubs().getPort("fraudDetectionServer")
+ expect:
+ fraudPort > 0
+ environment.getProperty("foo", Integer) == fraudPort
+ foo == fraudPort
+ }
+
@Configuration
@EnableAutoConfiguration
static class Config {}