Sync docs from master to gh-pages

This commit is contained in:
buildmaster
2017-05-30 13:52:26 +00:00
parent d5cd9248ac
commit f65e6fc579

View File

@@ -9003,9 +9003,12 @@ You wrote a proper stub generator and your stubs got placed in a JAR file.</p>
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
@@ -9047,8 +9050,16 @@ class MocoHttpServerStub implements HttpServerStub {
@Override
HttpServerStub registerMappings(Collection&lt;File&gt; stubFiles) {
List&lt;InputStream&gt; streams = stubFiles.collect { it.newInputStream() }
this.runner = JsonRunner.newJsonRunnerWithStreams(streams,
List&lt;RunnerSetting&gt; 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