From ab5d47e7a61010f56ffde6ab4e8ab35bb6b0e3e2 Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Wed, 8 Feb 2017 17:41:26 +0100 Subject: [PATCH] Changed the taken port fixes #221 --- .../contract/stubrunner/StubRunnerExecutorSpec.groovy | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy index 58efa72fb8..75b97eea90 100644 --- a/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy +++ b/spring-cloud-contract-stub-runner/src/test/groovy/org/springframework/cloud/contract/stubrunner/StubRunnerExecutorSpec.groovy @@ -17,6 +17,7 @@ package org.springframework.cloud.contract.stubrunner import groovy.json.JsonOutput +import org.springframework.util.SocketUtils import java.util.concurrent.TimeUnit @@ -72,13 +73,15 @@ class StubRunnerExecutorSpec extends Specification { def 'should start a stub on a given port'() { given: + int port = SocketUtils.findAvailableTcpPort() StubRunnerExecutor executor = new StubRunnerExecutor(portScanner) - stubRunnerOptions = new StubRunnerOptionsBuilder(stubIdsToPortMapping: stubIdsWithPortsFromString('group:artifact:12345,someotherartifact:123')) + stubRunnerOptions = new StubRunnerOptionsBuilder(stubIdsToPortMapping: + stubIdsWithPortsFromString("group:artifact:${port},someotherartifact:${SocketUtils.findAvailableTcpPort()}")) .build() when: executor.runStubs(stubRunnerOptions, repository, stub) then: - executor.findStubUrl("group", "artifact") == 'http://localhost:12345'.toURL() + executor.findStubUrl("group", "artifact") == "http://localhost:${port}".toURL() cleanup: executor.shutdown() }