Merge branch '2.2.x'
This commit is contained in:
2
pom.xml
2
pom.xml
@@ -54,7 +54,7 @@
|
||||
<gmavenplus-plugin.version>1.6.3</gmavenplus-plugin.version>
|
||||
|
||||
<!-- We need to have compatibility with Gradle -->
|
||||
<groovy.version>2.5.8</groovy.version>
|
||||
<groovy.version>2.5.9</groovy.version>
|
||||
<!-- We need to have compatibility with Boot -->
|
||||
<maven.version>3.5.4</maven.version>
|
||||
<!-- Resolver has to be aligned with Maven (e.g resolver 1.4 and Maven 3.6 or resolver 1.3 and Maven 3.5) -->
|
||||
|
||||
@@ -63,33 +63,37 @@ public class SpringCloudLoadBalancerAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
@Primary
|
||||
LoadBalancerClientFactory stubRunnerLoadBalancerClientFactory(
|
||||
StubFinder stubFinder, StubMapperProperties stubMapperProperties) {
|
||||
LoadBalancerClientFactory stubRunnerLoadBalancerClientFactory(StubFinder stubFinder,
|
||||
StubMapperProperties stubMapperProperties) {
|
||||
return new StubRunnerLoadBalancerClientFactory(stubFinder, stubMapperProperties);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class StubRunnerLoadBalancerClientFactory extends LoadBalancerClientFactory implements Closeable {
|
||||
class StubRunnerLoadBalancerClientFactory extends LoadBalancerClientFactory
|
||||
implements Closeable {
|
||||
|
||||
private final StubFinder stubFinder;
|
||||
|
||||
private final StubMapperProperties stubMapperProperties;
|
||||
|
||||
public StubRunnerLoadBalancerClientFactory(StubFinder stubFinder, StubMapperProperties stubMapperProperties) {
|
||||
StubRunnerLoadBalancerClientFactory(StubFinder stubFinder,
|
||||
StubMapperProperties stubMapperProperties) {
|
||||
this.stubFinder = stubFinder;
|
||||
this.stubMapperProperties = stubMapperProperties;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReactiveLoadBalancer<ServiceInstance> getInstance(String serviceId) {
|
||||
return request -> Mono.just(new DefaultResponse(new StubbedServiceInstance(stubFinder, stubMapperProperties, serviceId)));
|
||||
return request -> Mono.just(new DefaultResponse(
|
||||
new StubbedServiceInstance(stubFinder, stubMapperProperties, serviceId)));
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
StubbedServiceInstance.CACHE.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class StubbedServiceInstance implements ServiceInstance {
|
||||
@@ -115,9 +119,10 @@ class StubbedServiceInstance implements ServiceInstance {
|
||||
return entry;
|
||||
}
|
||||
RunningStubs runningStubs = this.stubFinder.findAllRunningStubs();
|
||||
String mappedServiceName = StringUtils
|
||||
.hasText(this.stubMapperProperties.fromServiceIdToIvyNotation(this.serviceId))
|
||||
? this.stubMapperProperties.fromServiceIdToIvyNotation(this.serviceId)
|
||||
String mappedServiceName = StringUtils.hasText(
|
||||
this.stubMapperProperties.fromServiceIdToIvyNotation(this.serviceId))
|
||||
? this.stubMapperProperties.fromServiceIdToIvyNotation(
|
||||
this.serviceId)
|
||||
: this.serviceId;
|
||||
entry = runningStubs.getEntry(mappedServiceName);
|
||||
CACHE.put(this.serviceId, entry);
|
||||
|
||||
@@ -35,7 +35,6 @@ import org.springframework.context.annotation.Configuration
|
||||
import org.springframework.test.context.ActiveProfiles
|
||||
import org.springframework.test.context.ContextConfiguration
|
||||
import org.springframework.web.client.RestTemplate
|
||||
|
||||
/**
|
||||
* @author Marcin Grzejszczak
|
||||
*/
|
||||
|
||||
@@ -9,3 +9,4 @@ spring.cloud:
|
||||
discovery.enabled: false
|
||||
service-registry.enabled: false
|
||||
eureka.client.enabled: false
|
||||
ribbon.eureka.enabled: false
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
|
||||
@@ -1,100 +1,100 @@
|
||||
@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
|
||||
@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
|
||||
|
||||
@@ -24,6 +24,7 @@ import groovy.transform.CompileStatic
|
||||
|
||||
import org.springframework.cloud.contract.spec.internal.CanBeDynamic
|
||||
import org.springframework.cloud.contract.spec.internal.DslProperty
|
||||
import org.springframework.cloud.contract.spec.internal.FromFileProperty
|
||||
import org.springframework.cloud.contract.spec.internal.RegexProperty
|
||||
|
||||
import static ContentUtils.extractValue
|
||||
@@ -89,6 +90,9 @@ class BodyExtractor {
|
||||
else if (bodyValue instanceof DslProperty) {
|
||||
return extractClientValueFromBody(bodyValue.clientValue)
|
||||
}
|
||||
else if (bodyValue instanceof FromFileProperty && bodyValue.isString()) {
|
||||
return MapConverter.transformValues(bodyValue.asString(), Closure.IDENTITY)
|
||||
}
|
||||
else {
|
||||
return MapConverter.transformValues(bodyValue, {
|
||||
Object prop = it instanceof DslProperty ? it.clientValue : it
|
||||
|
||||
@@ -65,6 +65,9 @@ class StreamOutputDestinationMessageReceiver
|
||||
private int indexOfDestination(StreamFunctionProperties streamFunctionProperties,
|
||||
String destination) {
|
||||
String[] split = streamFunctionProperties.getDefinition().split(";");
|
||||
if (split.length == 1) {
|
||||
return 0;
|
||||
}
|
||||
int indexOfDestination = Arrays.stream(split).map(String::toLowerCase)
|
||||
.collect(Collectors.toList()).indexOf(destination.toLowerCase());
|
||||
if (indexOfDestination == -1) {
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
package org.springframework.cloud.contract.verifier.util
|
||||
|
||||
import org.springframework.cloud.contract.spec.internal.FromFileProperty
|
||||
import spock.lang.Specification
|
||||
|
||||
/**
|
||||
* @author Adam Białas
|
||||
*/
|
||||
class BodyExtractorSpec extends Specification {
|
||||
|
||||
def "should extract body from json file"() {
|
||||
given:
|
||||
def uri = BodyExtractorSpec.getResource("/classpath/response.json").toURI()
|
||||
def jsonFromFile = new FromFileProperty(new File(uri), String.class)
|
||||
expect:
|
||||
["status" : "RESPONSE"] == BodyExtractor.extractClientValueFromBody(jsonFromFile)
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user