Merge branch '1.0.x'

This commit is contained in:
Marcin Grzejszczak
2017-04-26 15:00:02 +02:00
2 changed files with 17 additions and 1 deletions

View File

@@ -239,7 +239,7 @@ class StubRunnerExecutor implements StubFinder {
final List<File> mappings = repository.getStubs();
final Collection<Contract> contracts = repository.contracts;
Integer port = stubRunnerOptions.port(stubConfiguration);
if (!contracts.isEmpty() && !hasRequest(contracts)) {
if (!hasRequest(contracts) && mappings.isEmpty()) {
if (log.isDebugEnabled()) {
log.debug("There are no HTTP related contracts. Won't start any servers");
}
@@ -261,6 +261,9 @@ class StubRunnerExecutor implements StubFinder {
}
private boolean hasRequest(Collection<Contract> contracts) {
if (contracts.isEmpty()) {
return false;
}
for (Contract contract : contracts) {
if (contract.getRequest() != null) {
return true;

View File

@@ -131,6 +131,19 @@ class StubRunnerExecutorSpec extends Specification {
executor.shutdown()
}
def 'should not start http server if no contracts or mappings are found'() {
given:
def stubConf = new StubConfiguration('asd', 'asd', 'asd', '')
StubRunnerExecutor executor = new StubRunnerExecutor(portScanner)
when:
RunningStubs stubs = executor.runStubs(stubRunnerOptions,
new StubRepository(new File('src/test/resources/emptyrepo')), stubConf)
then:
stubs.getPort('asd') == -1
cleanup:
executor.shutdown()
}
Map<StubConfiguration, Integer> stubIdsWithPortsFromString(String stubIdsToPortMapping) {
return stubIdsToPortMapping.split(',').collectEntries { String entry ->
return StubsParser.fromStringWithPort(entry)