Merge remote-tracking branch 'origin/2.1.x' into 2.1.x
This commit is contained in:
@@ -2193,6 +2193,7 @@ $ touch .springformat
|
||||
==== Intellij IDEA
|
||||
|
||||
In order to setup Intellij you should import our coding conventions, inspection profiles and set up the checkstyle plugin.
|
||||
The following files can be found in the https://github.com/spring-cloud/spring-cloud-build/tree/master/spring-cloud-build-tools[Spring Cloud Build] project.
|
||||
|
||||
.spring-cloud-build-tools/
|
||||
----
|
||||
@@ -2233,7 +2234,7 @@ image::https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/{spring
|
||||
|
||||
Go to `File` -> `Settings` -> `Other settings` -> `Checkstyle`. There click on the `+` icon in the `Configuration file` section. There, you'll have to define where the checkstyle rules should be picked from. In the image above, we've picked the rules from the cloned Spring Cloud Build repository. However, you can point to the Spring Cloud Build's GitHub repository (e.g. for the `checkstyle.xml` : `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle.xml`). We need to provide the following variables:
|
||||
|
||||
- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL.
|
||||
- `checkstyle.header.file` - please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/main/resources/checkstyle-header.txt` URL.
|
||||
- `checkstyle.suppressions.file` - default suppressions. Please point it to the Spring Cloud Build's, `spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` file either in your cloned repo or via the `https://raw.githubusercontent.com/spring-cloud/spring-cloud-build/master/spring-cloud-build-tools/src/checkstyle/checkstyle-suppressions.xml` URL.
|
||||
- `checkstyle.additional.suppressions.file` - this variable corresponds to suppressions in your local project. E.g. you're working on `spring-cloud-contract`. Then point to the `project-root/src/checkstyle/checkstyle-suppressions.xml` folder. Example for `spring-cloud-contract` would be: `/home/username/spring-cloud-contract/src/checkstyle/checkstyle-suppressions.xml`.
|
||||
|
||||
|
||||
@@ -37,19 +37,90 @@ WARNING: If you want to use Spock in your projects, you must add separately the
|
||||
docs for more information]
|
||||
|
||||
[[gradle-add-gradle-plugin]]
|
||||
==== Add Gradle Plugin with Dependencies
|
||||
== Add Gradle Plugin with Dependencies
|
||||
|
||||
To add a Gradle plugin with dependencies, use code similar to this:
|
||||
To add a Gradle plugin with dependencies, you can use code similar to the following:
|
||||
|
||||
[source,groovy,indent=0]
|
||||
====
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="primary"]
|
||||
.Plugin DSL GA versions
|
||||
----
|
||||
// build.gradle
|
||||
plugins {
|
||||
id "groovy"
|
||||
// this will work only for GA versions of Spring Cloud Contract
|
||||
id "org.springframework.cloud.contract" version "${GAVerifierVersion}"
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${GAVerifierVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile "org.codehaus.groovy:groovy-all:${groovyVersion}"
|
||||
// example with adding Spock core and Spock Spring
|
||||
testCompile "org.spockframework:spock-core:${spockVersion}"
|
||||
testCompile "org.spockframework:spock-spring:${spockVersion}"
|
||||
testCompile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
|
||||
}
|
||||
----
|
||||
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
|
||||
.Plugin DSL non GA versions
|
||||
----
|
||||
// settings.gradle
|
||||
pluginManagement {
|
||||
plugins {
|
||||
id "org.springframework.cloud.contract" version "${verifierVersion}"
|
||||
}
|
||||
repositories {
|
||||
// to pick from local .m2
|
||||
mavenLocal()
|
||||
// for snapshots
|
||||
maven { url "https://repo.spring.io/snapshot" }
|
||||
// for milestones
|
||||
maven { url "https://repo.spring.io/milestone" }
|
||||
// for GA versions
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
// build.gradle
|
||||
plugins {
|
||||
id "groovy"
|
||||
id "org.springframework.cloud.contract"
|
||||
}
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-contract-dependencies:${verifierVersion}"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile "org.codehaus.groovy:groovy-all:${groovyVersion}"
|
||||
// example with adding Spock core and Spock Spring
|
||||
testCompile "org.spockframework:spock-core:${spockVersion}"
|
||||
testCompile "org.spockframework:spock-spring:${spockVersion}"
|
||||
testCompile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
|
||||
}
|
||||
----
|
||||
|
||||
[source,groovy,indent=0,subs="verbatim,attributes",role="secondary"]
|
||||
.Legacy Plugin Application
|
||||
----
|
||||
// build.gradle
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springboot_version}"
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springboot_version}"
|
||||
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${verifier_version}"
|
||||
// here you can also pass additional dependencies such as Pact or Kotlin spec e.g.:
|
||||
// classpath "org.springframework.cloud:spring-cloud-contract-spec-kotlin:${verifier_version}"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,13 +134,14 @@ dependencyManagement {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testCompile 'org.codehaus.groovy:groovy-all:2.4.6'
|
||||
testCompile "org.codehaus.groovy:groovy-all:${groovyVersion}"
|
||||
// example with adding Spock core and Spock Spring
|
||||
testCompile 'org.spockframework:spock-core:1.0-groovy-2.4'
|
||||
testCompile 'org.spockframework:spock-spring:1.0-groovy-2.4'
|
||||
testCompile "org.spockframework:spock-core:${spockVersion}"
|
||||
testCompile "org.spockframework:spock-spring:${spockVersion}"
|
||||
testCompile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
|
||||
}
|
||||
----
|
||||
====
|
||||
|
||||
[[gradle-and-rest-assured]]
|
||||
==== Gradle and Rest Assured 2.0
|
||||
|
||||
@@ -1,4 +1,25 @@
|
||||
// tag::repos[]
|
||||
/*
|
||||
We need to use the [buildscript {}] section when we have to modify
|
||||
the classpath for the plugins. If that's not the case this section
|
||||
can be skipped.
|
||||
|
||||
If you don't need to modify the classpath (e.g. add a Pact dependency),
|
||||
then you can just set the [pluginManagement {}] section in [settings.gradle] file.
|
||||
|
||||
// settings.gradle
|
||||
pluginManagement {
|
||||
repositories {
|
||||
// for snapshots
|
||||
maven {url "https://repo.spring.io/snapshot"}
|
||||
// for milestones
|
||||
maven {url "https://repo.spring.io/milestone"}
|
||||
// for GA versions
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
|
||||
*/
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
|
||||
@@ -1,17 +1,10 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
mavenLocal()
|
||||
maven { url "https://repo.spring.io/snapshot" }
|
||||
maven { url "https://repo.spring.io/milestone" }
|
||||
maven { url "https://repo.spring.io/release" }
|
||||
maven { url 'https://repo.spring.io/plugins-snapshot' }
|
||||
maven { url "https://repo.spring.io/plugins-release-local" }
|
||||
maven { url "https://repo.spring.io/plugins-staging-local/" }
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.1.2.RELEASE"
|
||||
}
|
||||
plugins {
|
||||
id "groovy"
|
||||
id "org.springframework.boot"
|
||||
id "io.spring.dependency-management"
|
||||
id "maven-publish"
|
||||
id "maven"
|
||||
id "org.springframework.cloud.contract"
|
||||
}
|
||||
|
||||
group = 'com.example'
|
||||
@@ -25,12 +18,6 @@ repositories {
|
||||
maven { url "https://repo.spring.io/release" }
|
||||
}
|
||||
|
||||
apply plugin: 'groovy'
|
||||
apply plugin: 'org.springframework.boot'
|
||||
apply plugin: 'io.spring.dependency-management'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'maven'
|
||||
|
||||
dependencyManagement {
|
||||
imports {
|
||||
mavenBom "org.springframework.cloud:spring-cloud-dependencies:$BOM_VERSION"
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
org.gradle.daemon=false
|
||||
verifierVersion=2.1.4.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Greenwich.BUILD-SNAPSHOT
|
||||
BOM_VERSION=Greenwich.BUILD-SNAPSHOT
|
||||
bootVersion=2.1.7.RELEASE
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
22
samples/standalone/webclient/http-server/gradlew
vendored
22
samples/standalone/webclient/http-server/gradlew
vendored
@@ -1,5 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
@@ -109,8 +125,8 @@ if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
184
samples/standalone/webclient/http-server/gradlew.bat
vendored
184
samples/standalone/webclient/http-server/gradlew.bat
vendored
@@ -1,84 +1,100 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
@@ -1 +1,26 @@
|
||||
pluginManagement {
|
||||
plugins {
|
||||
id 'org.springframework.boot'
|
||||
id "org.springframework.cloud.contract" version "${verifierVersion}"
|
||||
id "io.spring.dependency-management" version "1.0.8.RELEASE"
|
||||
}
|
||||
repositories {
|
||||
// to pick from local .m2
|
||||
mavenLocal()
|
||||
// for snapshots
|
||||
maven { url "https://repo.spring.io/libs-snapshot-local" }
|
||||
// for milestones
|
||||
maven { url "https://repo.spring.io/libs-milestone-local" }
|
||||
// for GA versions
|
||||
gradlePluginPortal()
|
||||
}
|
||||
resolutionStrategy {
|
||||
eachPlugin {
|
||||
if (requested.id.id == 'org.springframework.boot') {
|
||||
useModule("org.springframework.boot:spring-boot-gradle-plugin:${bootVersion}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rootProject.name = 'http-server-webclient-gradle'
|
||||
|
||||
|
||||
@@ -46,7 +46,8 @@ public final class StubRunnerWireMockTestExecutionListener
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (WireMockHttpServerStub.SERVERS.values().stream().noneMatch(p -> p.random)) {
|
||||
if (!WireMockHttpServerStub.SERVERS.isEmpty() && WireMockHttpServerStub.SERVERS
|
||||
.values().stream().noneMatch(p -> p.random)) {
|
||||
if (log.isWarnEnabled()) {
|
||||
log.warn("You've used fixed ports for WireMock setup - "
|
||||
+ "will mark context as dirty. Please use random ports, as much "
|
||||
|
||||
@@ -18,8 +18,12 @@ package org.springframework.cloud.contract.stubrunner.spring;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.config.BeanPostProcessor;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.cloud.contract.stubrunner.BatchStubRunner;
|
||||
@@ -54,9 +58,6 @@ public class StubRunnerConfiguration {
|
||||
|
||||
static final String STUBRUNNER_PREFIX = "stubrunner.runningstubs";
|
||||
|
||||
@Autowired(required = false)
|
||||
private MessageVerifier<?> contractVerifierMessaging;
|
||||
|
||||
private StubDownloaderBuilderProvider provider = new StubDownloaderBuilderProvider();
|
||||
|
||||
@Autowired
|
||||
@@ -72,7 +73,7 @@ public class StubRunnerConfiguration {
|
||||
* @return the batch stub runner bean
|
||||
*/
|
||||
@Bean
|
||||
public BatchStubRunner batchStubRunner() {
|
||||
public BatchStubRunner batchStubRunner(BeanFactory beanFactory) {
|
||||
StubRunnerOptionsBuilder builder = builder();
|
||||
if (this.props.getProxyHost() != null) {
|
||||
builder.withProxy(this.props.getProxyHost(), this.props.getProxyPort());
|
||||
@@ -80,14 +81,19 @@ public class StubRunnerConfiguration {
|
||||
StubRunnerOptions stubRunnerOptions = builder.build();
|
||||
BatchStubRunner batchStubRunner = new BatchStubRunnerFactory(stubRunnerOptions,
|
||||
this.provider.get(stubRunnerOptions),
|
||||
this.contractVerifierMessaging != null ? this.contractVerifierMessaging
|
||||
: new NoOpStubMessages()).buildBatchStubRunner();
|
||||
new LazyMessageVerifier(beanFactory)).buildBatchStubRunner();
|
||||
// TODO: Consider running it in a separate thread
|
||||
RunningStubs runningStubs = batchStubRunner.runStubs();
|
||||
registerPort(runningStubs);
|
||||
return batchStubRunner;
|
||||
}
|
||||
|
||||
@Bean
|
||||
public BeanPostProcessor batchStubRunnerBeanPostProcessor(BatchStubRunner runner) {
|
||||
return new BeanPostProcessor() {
|
||||
};
|
||||
}
|
||||
|
||||
private StubRunnerOptionsBuilder builder() {
|
||||
return new StubRunnerOptionsBuilder()
|
||||
.withMinMaxPort(this.props.getMinPort(), this.props.getMaxPort())
|
||||
@@ -131,3 +137,47 @@ public class StubRunnerConfiguration {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class LazyMessageVerifier implements MessageVerifier {
|
||||
|
||||
private MessageVerifier<?> messageVerifier;
|
||||
|
||||
private final BeanFactory beanFactory;
|
||||
|
||||
LazyMessageVerifier(BeanFactory beanFactory) {
|
||||
this.beanFactory = beanFactory;
|
||||
}
|
||||
|
||||
private MessageVerifier messageVerifier() {
|
||||
if (this.messageVerifier == null) {
|
||||
try {
|
||||
this.messageVerifier = this.beanFactory.getBean(MessageVerifier.class);
|
||||
}
|
||||
catch (BeansException ex) {
|
||||
this.messageVerifier = new NoOpStubMessages();
|
||||
}
|
||||
}
|
||||
return this.messageVerifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object message, String destination) {
|
||||
messageVerifier().send(message, destination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object receive(String destination, long timeout, TimeUnit timeUnit) {
|
||||
return messageVerifier().receive(destination, timeout, timeUnit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object receive(String destination) {
|
||||
return messageVerifier().receive(destination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(Object payload, Map headers, String destination) {
|
||||
messageVerifier().send(payload, headers, destination);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner.issue1225;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.boot.SpringBootConfiguration;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.AutoConfigureStubRunner;
|
||||
import org.springframework.cloud.contract.stubrunner.spring.StubRunnerPort;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Tests that stub runner specific auto-configuration can be loaded up in combination with
|
||||
* other slice tests
|
||||
*
|
||||
* @author Biju Kunjummen
|
||||
*/
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(properties = {
|
||||
"ping.url=http://localhost:${stubrunner.runningstubs.loanIssuance.port}" })
|
||||
@AutoConfigureStubRunner(ids = {
|
||||
"org.springframework.cloud.contract.verifier.stubs:loanIssuance:+:stubs",
|
||||
"org.springframework.cloud.contract.verifier.stubs:fraudDetectionServer:+:stubs" })
|
||||
@ActiveProfiles("test")
|
||||
public class Issue1225Tests {
|
||||
|
||||
@StubRunnerPort("loanIssuance")
|
||||
private int stubRunnerLoanIssuancePort;
|
||||
|
||||
@Autowired
|
||||
private PingProxyController pingProxyController;
|
||||
|
||||
@Test
|
||||
public void shouldInjectTheStubPortsAsEarlyAsPossible() {
|
||||
assertThat(this.stubRunnerLoanIssuancePort).isPositive();
|
||||
assertThat(this.pingProxyController.pingUrl)
|
||||
.contains(":" + this.stubRunnerLoanIssuancePort);
|
||||
}
|
||||
|
||||
@ComponentScan
|
||||
@SpringBootConfiguration
|
||||
static class Config {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@RestController
|
||||
class PingProxyController {
|
||||
|
||||
String pingUrl;
|
||||
|
||||
public PingProxyController(@Value("${ping.url}") String pingUrl) {
|
||||
this.pingUrl = pingUrl;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -22,6 +22,7 @@
|
||||
<module>spring-cloud-contract-pact</module>
|
||||
<module>spring-cloud-contract-maven-plugin</module>
|
||||
<module>spring-cloud-contract-gradle-plugin</module>
|
||||
<module>spring-cloud-contract-gradle-portal-plugin</module>
|
||||
</modules>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -158,7 +158,3 @@ task resolveDependencies {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task wrapper(type: Wrapper) {
|
||||
gradleVersion = '4.10.2'
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,5 +1,21 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
#
|
||||
# Copyright 2015 the original author or authors.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# https://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
##############################################################################
|
||||
##
|
||||
## Gradle start up script for UN*X
|
||||
@@ -28,7 +44,7 @@ APP_NAME="Gradle"
|
||||
APP_BASE_NAME=`basename "$0"`
|
||||
|
||||
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
DEFAULT_JVM_OPTS=""
|
||||
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
|
||||
|
||||
# Use the maximum available, or set MAX_FD != -1 to use that value.
|
||||
MAX_FD="maximum"
|
||||
@@ -109,8 +125,8 @@ if $darwin; then
|
||||
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
|
||||
fi
|
||||
|
||||
# For Cygwin, switch paths to Windows format before running java
|
||||
if $cygwin ; then
|
||||
# For Cygwin or MSYS, switch paths to Windows format before running java
|
||||
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
|
||||
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
|
||||
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
|
||||
JAVACMD=`cygpath --unix "$JAVACMD"`
|
||||
|
||||
@@ -1,84 +1,100 @@
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS=
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
@rem
|
||||
@rem Copyright 2015 the original author or authors.
|
||||
@rem
|
||||
@rem Licensed under the Apache License, Version 2.0 (the "License");
|
||||
@rem you may not use this file except in compliance with the License.
|
||||
@rem You may obtain a copy of the License at
|
||||
@rem
|
||||
@rem https://www.apache.org/licenses/LICENSE-2.0
|
||||
@rem
|
||||
@rem Unless required by applicable law or agreed to in writing, software
|
||||
@rem distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@rem See the License for the specific language governing permissions and
|
||||
@rem limitations under the License.
|
||||
@rem
|
||||
|
||||
@if "%DEBUG%" == "" @echo off
|
||||
@rem ##########################################################################
|
||||
@rem
|
||||
@rem Gradle startup script for Windows
|
||||
@rem
|
||||
@rem ##########################################################################
|
||||
|
||||
@rem Set local scope for the variables with windows NT shell
|
||||
if "%OS%"=="Windows_NT" setlocal
|
||||
|
||||
set DIRNAME=%~dp0
|
||||
if "%DIRNAME%" == "" set DIRNAME=.
|
||||
set APP_BASE_NAME=%~n0
|
||||
set APP_HOME=%DIRNAME%
|
||||
|
||||
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
|
||||
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
|
||||
|
||||
@rem Find java.exe
|
||||
if defined JAVA_HOME goto findJavaFromJavaHome
|
||||
|
||||
set JAVA_EXE=java.exe
|
||||
%JAVA_EXE% -version >NUL 2>&1
|
||||
if "%ERRORLEVEL%" == "0" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:findJavaFromJavaHome
|
||||
set JAVA_HOME=%JAVA_HOME:"=%
|
||||
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
|
||||
|
||||
if exist "%JAVA_EXE%" goto init
|
||||
|
||||
echo.
|
||||
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
|
||||
echo.
|
||||
echo Please set the JAVA_HOME variable in your environment to match the
|
||||
echo location of your Java installation.
|
||||
|
||||
goto fail
|
||||
|
||||
:init
|
||||
@rem Get command-line arguments, handling Windows variants
|
||||
|
||||
if not "%OS%" == "Windows_NT" goto win9xME_args
|
||||
|
||||
:win9xME_args
|
||||
@rem Slurp the command line arguments.
|
||||
set CMD_LINE_ARGS=
|
||||
set _SKIP=2
|
||||
|
||||
:win9xME_args_slurp
|
||||
if "x%~1" == "x" goto execute
|
||||
|
||||
set CMD_LINE_ARGS=%*
|
||||
|
||||
:execute
|
||||
@rem Setup the command line
|
||||
|
||||
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
|
||||
|
||||
@rem Execute Gradle
|
||||
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
|
||||
|
||||
:end
|
||||
@rem End local scope for the variables with windows NT shell
|
||||
if "%ERRORLEVEL%"=="0" goto mainEnd
|
||||
|
||||
:fail
|
||||
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
|
||||
rem the _cmd.exe /c_ return code!
|
||||
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
|
||||
exit /b 1
|
||||
|
||||
:mainEnd
|
||||
if "%OS%"=="Windows_NT" endlocal
|
||||
|
||||
:omega
|
||||
|
||||
@@ -1,3 +1,19 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* https://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.cloud.contract.verifier.plugin
|
||||
|
||||
import org.gradle.api.Task
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-contract-tools</artifactId>
|
||||
<version>2.1.4.BUILD-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
<groupId>org.springframework.cloud.contract</groupId>
|
||||
<artifactId>org.springframework.cloud.contract.gradle.plugin</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>Spring Cloud Contract Gradle Portal Plugin</name>
|
||||
<description>Spring Cloud Contract Gradle Portal Plugin</description>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-contract-gradle-plugin</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
@@ -19,6 +19,9 @@ package org.springframework.cloud.contract.wiremock;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
|
||||
import org.springframework.boot.context.event.ApplicationPreparedEvent;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.core.Ordered;
|
||||
@@ -41,6 +44,8 @@ import org.springframework.util.SocketUtils;
|
||||
public class WireMockApplicationListener
|
||||
implements ApplicationListener<ApplicationPreparedEvent> {
|
||||
|
||||
private static final Log log = LogFactory.getLog(WireMockApplicationListener.class);
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ApplicationPreparedEvent event) {
|
||||
registerPort(event.getApplicationContext().getEnvironment());
|
||||
@@ -54,26 +59,22 @@ public class WireMockApplicationListener
|
||||
if (httpPortProperty == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (httpPortProperty.equals(0)) {
|
||||
MutablePropertySources propertySources = environment.getPropertySources();
|
||||
addPropertySource(propertySources);
|
||||
Map<String, Object> source = ((MapPropertySource) propertySources
|
||||
.get("wiremock")).getSource();
|
||||
source.put("wiremock.server.port",
|
||||
SocketUtils.findAvailableTcpPort(10000, 12500));
|
||||
source.put("wiremock.server.port-dynamic", true);
|
||||
if (isHttpDynamic(httpPortProperty)) {
|
||||
registerPropertySourceForDynamicEntries(environment, "wiremock.server.port",
|
||||
10000, 12500, "wiremock.server.port-dynamic");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Registered property source for dynamic http port");
|
||||
}
|
||||
}
|
||||
int httpsPortProperty = environment.getProperty("wiremock.server.https-port",
|
||||
Integer.class, 0);
|
||||
if (httpsPortProperty == 0) {
|
||||
MutablePropertySources propertySources = environment.getPropertySources();
|
||||
addPropertySource(propertySources);
|
||||
Map<String, Object> source = ((MapPropertySource) propertySources
|
||||
.get("wiremock")).getSource();
|
||||
source.put("wiremock.server.https-port",
|
||||
SocketUtils.findAvailableTcpPort(12500, 15000));
|
||||
source.put("wiremock.server.https-port-dynamic", true);
|
||||
if (isHttpsDynamic(httpsPortProperty)) {
|
||||
registerPropertySourceForDynamicEntries(environment,
|
||||
"wiremock.server.https-port", 12500, 15000,
|
||||
"wiremock.server.https-port-dynamic");
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Registered property source for dynamic https port");
|
||||
}
|
||||
}
|
||||
else if (httpsPortProperty == -1) {
|
||||
MutablePropertySources propertySources = environment.getPropertySources();
|
||||
@@ -81,10 +82,33 @@ public class WireMockApplicationListener
|
||||
Map<String, Object> source = ((MapPropertySource) propertySources
|
||||
.get("wiremock")).getSource();
|
||||
source.put("wiremock.server.https-port-dynamic", true);
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"Registered property source for dynamic https with https port property set to -1");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isHttpsDynamic(int httpsPortProperty) {
|
||||
return httpsPortProperty == 0;
|
||||
}
|
||||
|
||||
private boolean isHttpDynamic(Integer httpPortProperty) {
|
||||
return httpPortProperty.equals(0);
|
||||
}
|
||||
|
||||
private void registerPropertySourceForDynamicEntries(
|
||||
ConfigurableEnvironment environment, String portProperty, int minPort,
|
||||
int maxPort, String dynamicPortProperty) {
|
||||
MutablePropertySources propertySources = environment.getPropertySources();
|
||||
addPropertySource(propertySources);
|
||||
Map<String, Object> source = ((MapPropertySource) propertySources.get("wiremock"))
|
||||
.getSource();
|
||||
source.put(portProperty, SocketUtils.findAvailableTcpPort(minPort, maxPort));
|
||||
source.put(dynamicPortProperty, true);
|
||||
}
|
||||
|
||||
private void addPropertySource(MutablePropertySources propertySources) {
|
||||
if (!propertySources.contains("wiremock")) {
|
||||
propertySources.addFirst(
|
||||
|
||||
@@ -109,8 +109,7 @@ public class WireMockConfiguration implements SmartLifecycle {
|
||||
}
|
||||
this.server = new WireMockServer(this.options);
|
||||
}
|
||||
registerStubs();
|
||||
logRegisteredMappings();
|
||||
resetMappings();
|
||||
if (!this.beanFactory.containsBean(WIREMOCK_SERVER_BEAN_NAME)) {
|
||||
this.beanFactory.registerSingleton(WIREMOCK_SERVER_BEAN_NAME, this.server);
|
||||
}
|
||||
@@ -125,10 +124,11 @@ public class WireMockConfiguration implements SmartLifecycle {
|
||||
|
||||
void resetMappings() {
|
||||
this.server.resetAll();
|
||||
registerStubs();
|
||||
logRegisteredMappings();
|
||||
}
|
||||
|
||||
private void registerStubs() throws IOException {
|
||||
private void registerStubs() {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Will register [" + this.wireMock.getServer().getStubs().length
|
||||
+ "] stubs");
|
||||
@@ -144,11 +144,16 @@ public class WireMockConfiguration implements SmartLifecycle {
|
||||
}
|
||||
pattern = pattern + "**/*.json";
|
||||
}
|
||||
for (Resource resource : resolver.getResources(pattern)) {
|
||||
StubMapping stubMapping = WireMockStubMapping
|
||||
.buildFrom(StreamUtils.copyToString(resource.getInputStream(),
|
||||
Charset.forName("UTF-8")));
|
||||
this.server.addStubMapping(stubMapping);
|
||||
try {
|
||||
for (Resource resource : resolver.getResources(pattern)) {
|
||||
StubMapping stubMapping = WireMockStubMapping.buildFrom(
|
||||
StreamUtils.copyToString(resource.getInputStream(),
|
||||
Charset.forName("UTF-8")));
|
||||
this.server.addStubMapping(stubMapping);
|
||||
}
|
||||
}
|
||||
catch (IOException ex) {
|
||||
throw new IllegalStateException(ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
|
||||
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
||||
import org.apache.http.conn.ssl.TrustSelfSignedStrategy;
|
||||
import org.apache.http.ssl.SSLContexts;
|
||||
import org.junit.Assert;
|
||||
|
||||
import org.springframework.util.ClassUtils;
|
||||
|
||||
@@ -58,8 +57,8 @@ public abstract class WireMockSpring {
|
||||
.build().getSocketFactory());
|
||||
}
|
||||
catch (Exception e) {
|
||||
Assert.fail("Cannot install custom socket factory: [" + e.getMessage()
|
||||
+ "]");
|
||||
throw new AssertionError("Cannot install custom socket factory: ["
|
||||
+ e.getMessage() + "]");
|
||||
}
|
||||
}
|
||||
initialized = true;
|
||||
|
||||
@@ -53,7 +53,6 @@ public class AutoConfigureWireMockRandomPortApplicationTests {
|
||||
.withHeader("Content-Type", "text/plain").withBody("Hello World!")));
|
||||
assertThat(this.service.go()).isEqualTo("Hello World!");
|
||||
|
||||
|
||||
wireMockServer.verify(1, RequestPatternBuilder.allRequests());
|
||||
}
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.contract.wiremock;
|
||||
|
||||
public class AutoConfigureWireMockRandomPortInheretedApplicationTests extends AutoConfigureWireMockRandomPortApplicationTests {
|
||||
public class AutoConfigureWireMockRandomPortInheretedApplicationTests
|
||||
extends AutoConfigureWireMockRandomPortApplicationTests {
|
||||
|
||||
}
|
||||
|
||||
@@ -46,9 +46,8 @@ public class FailFastLoanApplicationServiceTests {
|
||||
|
||||
// Then
|
||||
assertThat(throwable).isInstanceOf(BeanCreationException.class);
|
||||
assertThat(throwable.getCause()).isInstanceOf(BeanInstantiationException.class);
|
||||
assertThat(throwable.getCause().getCause())
|
||||
.isInstanceOf(IllegalArgumentException.class).hasMessageContaining(
|
||||
.isInstanceOf(BeanInstantiationException.class).hasMessageContaining(
|
||||
"For groupId [org.springframework.cloud.contract.verifier.stubs] artifactId [should-not-be-found] "
|
||||
+ "and classifier [stubs] the version was not resolved! The following exceptions took place");
|
||||
}
|
||||
@@ -66,9 +65,8 @@ public class FailFastLoanApplicationServiceTests {
|
||||
|
||||
// Then
|
||||
assertThat(throwable).isInstanceOf(BeanCreationException.class);
|
||||
assertThat(throwable.getCause()).isInstanceOf(BeanInstantiationException.class);
|
||||
assertThat(throwable.getCause().getCause())
|
||||
.isInstanceOf(IllegalStateException.class)
|
||||
.isInstanceOf(BeanInstantiationException.class)
|
||||
.hasMessageContaining("No stubs were found on classpath ");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user