diff --git a/tests/spring-cloud-contract-stub-runner-moco/src/test/groovy/org/springframework/cloud/contract/stubrunner/provider/moco/MocoHttpServerStub.groovy b/tests/spring-cloud-contract-stub-runner-moco/src/test/groovy/org/springframework/cloud/contract/stubrunner/provider/moco/MocoHttpServerStub.groovy index b1070d184e..7b9ccdf492 100644 --- a/tests/spring-cloud-contract-stub-runner-moco/src/test/groovy/org/springframework/cloud/contract/stubrunner/provider/moco/MocoHttpServerStub.groovy +++ b/tests/spring-cloud-contract-stub-runner-moco/src/test/groovy/org/springframework/cloud/contract/stubrunner/provider/moco/MocoHttpServerStub.groovy @@ -18,9 +18,12 @@ package org.springframework.cloud.contract.stubrunner.provider.moco import com.github.dreamhead.moco.bootstrap.arg.HttpArgs import com.github.dreamhead.moco.runner.JsonRunner +import com.github.dreamhead.moco.runner.RunnerSetting +import groovy.util.logging.Slf4j import org.springframework.cloud.contract.stubrunner.HttpServerStub import org.springframework.util.SocketUtils +@Slf4j class MocoHttpServerStub implements HttpServerStub { private boolean started @@ -62,8 +65,16 @@ class MocoHttpServerStub implements HttpServerStub { @Override HttpServerStub registerMappings(Collection stubFiles) { - List streams = stubFiles.collect { it.newInputStream() } - this.runner = JsonRunner.newJsonRunnerWithStreams(streams, + List settings = stubFiles.findAll { it.name.endsWith("json") } + .collect { + try { + return RunnerSetting.aRunnerSetting().withStream(it.newInputStream()).build() + } catch (Exception e) { + log.warn("Exception occurred while trying to parse file [{}]", it.name, e) + return null + } + }.findAll { it } + this.runner = JsonRunner.newJsonRunnerWithSetting(settings, HttpArgs.httpArgs().withPort(this.port).build()) this.runner.run() this.started = true