From 766f90363bb2e0b088cbd84fdc4707f141adbc0c Mon Sep 17 00:00:00 2001 From: Marcin Grzejszczak Date: Tue, 30 May 2017 15:36:29 +0200 Subject: [PATCH] Trying to fix the build --- .../provider/moco/MocoHttpServerStub.groovy | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) 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