Merge pull request #1657 from spring-cloud/jdk16_boot_2_5

Works with JDK16
This commit is contained in:
Spencer Gibb
2021-07-09 15:33:33 -04:00
committed by GitHub
37 changed files with 201 additions and 356 deletions

View File

@@ -2,7 +2,7 @@
set -e
WRAPPER_VERSION="6.4"
WRAPPER_VERSION="7.0"
GRADLE_BIN_DIR="gradle-${WRAPPER_VERSION}-bin"
GRADLE_WRAPPER_DIR="${HOME}/.gradle/wrapper/dists/${GRADLE_BIN_DIR}"
CURRENT_DIR="$( pwd )"

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -130,7 +130,7 @@ fi
if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath

View File

@@ -40,7 +40,7 @@ if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
@@ -54,7 +54,7 @@ goto fail
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
@@ -64,21 +64,6 @@ 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
@@ -86,7 +71,7 @@ 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%
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell

11
pom.xml
View File

@@ -37,8 +37,7 @@
<spring-cloud-functiondonotreplace.version>3.0.6.RELEASE</spring-cloud-functiondonotreplace.version>
<jopt-simple.version>5.0.4</jopt-simple.version>
<cglib.version>3.2.11</cglib.version>
<spock-spring.version>1.3-groovy-2.5</spock-spring.version>
<spock-global-unroll.version>0.5.1</spock-global-unroll.version>
<spock-spring.version>2.0-M5-groovy-3.0</spock-spring.version> <!-- @releaser:version-check-off -->
<hoverfly-junit.version>0.2.2</hoverfly-junit.version>
<commons-text.version>1.9</commons-text.version>
<handlebars.version>4.2.0</handlebars.version>
@@ -53,7 +52,7 @@
<gmavenplus-plugin.version>1.12.1</gmavenplus-plugin.version>
<!-- We need to have compatibility with Gradle -->
<groovy.version>2.5.14</groovy.version>
<groovy.version>3.0.8</groovy.version>
<!-- We need to have compatibility with Boot -->
<maven.version>3.6.3</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) -->
@@ -196,9 +195,9 @@
</exclusions>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<version>${spock-global-unroll.version}</version>
<groupId>org.spockframework</groupId>
<artifactId>spock-junit4</artifactId>
<version>${spock-spring.version}</version>
</dependency>
<dependency>
<groupId>io.specto</groupId>

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -3,7 +3,6 @@ plugins {
id "org.springframework.boot"
id "io.spring.dependency-management"
id "maven-publish"
id "maven"
/**
* While the SCC Gradle plugin is not strictly necessary for this project.
* It is included to ensure that if the contractDslDir does not exist, then

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -66,11 +66,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -32,11 +32,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -175,11 +175,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-zookeeper-discovery</artifactId>
@@ -215,6 +210,11 @@
<artifactId>spring-boot-starter-webflux</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-junit4</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -61,11 +61,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>
@@ -81,6 +76,11 @@
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-junit4</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -2,19 +2,11 @@ buildscript {
repositories {
mavenCentral()
mavenLocal()
if (project.hasProperty('fatJar')) {
jcenter()
}
//For plugin-publish-plugin. Could be limited only to that dependency with Gradle 5.1+ - https://docs.gradle.org/5.1.1/release-notes.html#repository-to-dependency-matching
gradlePluginPortal()
}
dependencies {
classpath "com.bmuschko:gradle-nexus-plugin:2.3"
classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3"
classpath 'com.gradle.publish:plugin-publish-plugin:0.11.0'
if (project.hasProperty('fatJar')) {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3'
}
classpath 'com.gradle.publish:plugin-publish-plugin:0.14.0'
}
}
@@ -47,8 +39,7 @@ repositories {
jcenter()
maven { url "https://repo.spring.io/snapshot" }
maven { url "https://repo.spring.io/milestone" }
maven { url "https://repo.spring.io/libs-release-local" }
maven { url "https://repo.spring.io/libs-staging-local/" }
maven { url "https://repo.spring.io/release" }
}
//Dependencies in all subprojects - https://solidsoft.wordpress.com/2014/11/13/gradle-tricks-display-dependencies-for-all-subprojects-in-multi-project-build/
@@ -70,9 +61,9 @@ dependencies {
implementation "org.apache.maven.resolver:maven-resolver-api:1.4.1"
implementation "org.eclipse.jgit:org.eclipse.jgit:5.5.1.201910021850-r"
implementation "com.jcraft:jsch.agentproxy.jsch:0.0.9"
implementation "com.fasterxml.jackson.core:jackson-databind:2.11.3"
implementation "com.fasterxml.jackson.core:jackson-databind:2.11.4"
implementation "org.springframework:spring-core:5.3.2"
implementation "org.springframework:spring-core:5.3.6"
implementation("org.springframework.cloud:spring-cloud-contract-shade:${project.version}")
api("org.springframework.cloud:spring-cloud-contract-stub-runner:${project.version}") {
exclude(group: '*')
@@ -81,10 +72,9 @@ dependencies {
exclude(group: '*')
}
testImplementation('org.spockframework:spock-core:1.3-groovy-2.5') {
testImplementation('org.spockframework:spock-core:2.0-M5-groovy-3.0') { // @releaser:version-check-off
exclude(group: 'org.codehaus.groovy')
}
testImplementation 'info.solidsoft.spock:spock-global-unroll:0.5.0'
testImplementation localGroovy()
testImplementation gradleTestKit()
}
@@ -112,16 +102,6 @@ dependencies {
jansi 'org.fusesource.jansi:jansi:1.11'
}
/*jacoco {
toolVersion = "0.7.7.201606060606"
}
jacocoTestReport {
reports {
xml.enabled true
}
}*/
jar {
manifest {
attributes 'Implementation-Version': project.version

View File

@@ -1,10 +1,7 @@
// This setup seems to work. Let's not touch it.
apply plugin: 'maven'
apply plugin: 'maven-publish'
//apply plugin: 'signing'
uploadArchives.dependsOn { [check] }
//apply plugin: 'signing'
task sourcesJar(type: Jar) {
classifier 'sources'
@@ -82,63 +79,6 @@ if (isReleaseToCentral) {
}
}
afterEvaluate {
uploadArchives {
repositories {
mavenDeployer {
// POM signature
if (isReleaseVersion && isReleaseToCentral) {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
}
// Target repository
String repoUserName = isReleaseToCentral ? getProp("SONATYPE_USER") : repoUser
String repoPass = isReleaseToCentral ? getProp("SONATYPE_PASSWORD") : repoPass
repository(url: repoUrl) {
authentication(userName: repoUserName, password: repoPass)
}
pom.project {
name "$project.name"
packaging 'jar'
description 'Spring Cloud Contract Gradle Plugin'
url 'https://github.com/spring-cloud/spring-cloud-contract'
inceptionYear '2014'
scm {
connection 'scm:git:git@github.com:spring-cloud/spring-cloud-contract.git'
developerConnection 'scm:git:git@github.com:spring-cloud/spring-cloud-contract.git'
url 'https://github.com/spring-cloud/spring-cloud-contract'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'https://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'jkubrynski'
name 'Jakub Kubrynski'
email 'jk ATT codearte DOTT io'
}
developer {
id 'marcingrzejszczak'
name 'Marcin Grzejszczak'
email 'mgrzejszczak ATT pivotal DOTT io'
}
developer {
id 'dsyer'
name 'Dave Syer'
email 'dsyer ATT pivotal DOTT io'
}
}
}
}
}
}
}
String getProp(String propName) {
return hasProperty(propName) ?
(getProperty(propName) ?: System.properties[propName]) : System.properties[propName] ?:

View File

@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.4-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

View File

@@ -61,11 +61,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-contract-wiremock</artifactId>

View File

@@ -178,11 +178,6 @@
<artifactId>spock-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
@@ -280,8 +275,8 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
<groupId>org.spockframework</groupId>
<artifactId>spock-junit4</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

View File

@@ -51,14 +51,14 @@ class NameProvider {
else if (contractMetadata.getConvertedContract().size() > 1) {
int index = findIndexOf(contractMetadata.getConvertedContract(), stubContent);
String name = camelCasedMethodFromFileName(stubsFile) + "_" + index;
if (log.isDebugEnabled()) {
log.debug("Scenario found. The method name will be [" + name + "]");
if (log.isTraceEnabled()) {
log.trace("Scenario found. The method name will be [" + name + "]");
}
return name;
}
String name = camelCasedMethodFromFileName(stubsFile);
if (StringUtils.hasText(name) && log.isDebugEnabled()) {
log.debug("The method name will be [" + name + "]");
if (StringUtils.hasText(name) && log.isTraceEnabled()) {
log.trace("The method name will be [" + name + "]");
}
return name;
}

View File

@@ -212,17 +212,17 @@ public class SingleContractMetadata {
private String calculateMethodName() {
if (!isEmpty(contract.getName())) {
String name = camelCase(convertIllegalPackageChars(contract.getName()));
log.debug("Overriding the default test name with [{}]", name);
log.trace("Overriding the default test name with [{}]", name);
return name;
}
if (allContracts.size() > 1) {
int index = allContracts.indexOf(getContract());
String name = String.format("%s_%d", camelCasedMethodFromFileName(stubsPath), index);
log.debug("Scenario found. The method name will be [{}]", name);
log.trace("Scenario found. The method name will be [{}]", name);
return name;
}
String name = camelCasedMethodFromFileName(stubsPath);
log.debug("The method name will be [{}]", name);
log.trace("The method name will be [{}]", name);
return name;
}

View File

@@ -484,7 +484,8 @@ class JaxRsClientMethodBuilderSpec extends Specification implements WireMockStub
}
}
def "should generate regex assertions for map objects in response body with #methodBodyName"() {
@Unroll
def "should generate regex assertions for map objects in response body with #methodBuilderName"() {
given:
Contract contractDsl = Contract.make {
request {

View File

@@ -20,6 +20,7 @@ import java.util.function.Function
import groovy.json.JsonSlurper
import spock.lang.Issue
import spock.lang.Shared
import spock.lang.Specification
import org.springframework.cloud.contract.spec.Contract
@@ -95,157 +96,157 @@ class WireMockResponseStubStrategySpec extends Specification {
assert body.get("double") instanceof BigDecimal
}
def "should convert patterns to proper value"() {
given:
def contract = Contract.make {
request {
method(GET())
urlPath(value(regex("/info/[0-9]"))) {
queryParameters {
parameter 'limit': $(consumer(equalTo('20')), producer(equalTo('10')))
parameter 'offset': $(consumer(containing("20")), producer(equalTo('20')))
parameter 'filter': 'email'
parameter 'sort': equalTo("name")
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer('99'))
parameter 'name': $(consumer(matching('John.*')), producer('John.Doe'))
parameter 'email': 'bob@email.com'
parameter 'hello': $(consumer(matching('John.*')), producer(absent()))
parameter 'hello2': absent()
}
}
headers {
contentType(applicationJson())
header([
second: "value", third: $(anyAlphaNumeric())
])
}
body([
foo1 : $(c(regex("[0-9]")), p(1)),
foo2 : $(c(regex("[0-9]"))),
foo3 : $(anyAlphaNumeric()),
foo4 : value(regex(aDouble())),
foo5 : value(anyDouble()),
foo6 : "concrete",
duck : 123,
alpha : 'abc',
number : 123,
aBoolean : true,
date : '2017-01-01',
dateTime : '2017-01-01T01:23:45',
time : '01:02:34',
valueWithoutAMatcher: 'foo',
valueWithTypeMatch : 'string',
key : [
'complex.key': 'foo'
]
])
bodyMatchers {
jsonPath('$.duck', byRegex("[0-9]{3}"))
jsonPath('$.duck', byEquality())
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()))
jsonPath('$.alpha', byEquality())
jsonPath('$.number', byRegex(number()))
jsonPath('$.aBoolean', byRegex(anyBoolean()))
jsonPath('$.date', byDate())
jsonPath('$.dateTime', byTimestamp())
jsonPath('$.time', byTime())
jsonPath("\$.['key'].['complex.key']", byEquality())
}
}
response {
status(OK())
headers {
contentType(applicationJson())
header([
second: "value", third: $(anyAlphaNumeric())
])
}
body([
foo1 : $(p(regex("[0-9]")), c(1)),
foo2 : $(p(regex("[0-9]"))),
foo3 : $(anyAlphaNumeric()),
foo4 : value(regex(aDouble())),
foo5 : value(anyDouble()),
foo6 : "concrete",
duck : 123,
alpha : 'abc',
number : 123,
positiveInteger : 1234567890,
negativeInteger : -1234567890,
positiveDecimalNumber: 123.4567890,
negativeDecimalNumber: -123.4567890,
aBoolean : true,
date : '2017-01-01',
dateTime : '2017-01-01T01:23:45',
time : "01:02:34",
valueWithoutAMatcher : 'foo',
valueWithTypeMatch : 'string',
valueWithMin : [
1, 2, 3
],
valueWithMax : [
1, 2, 3
],
valueWithMinMax : [
1, 2, 3
],
valueWithMinEmpty : [],
valueWithMaxEmpty : [],
key : [
'complex.key': 'foo'
],
nullValue : null
])
bodyMatchers {
// asserts the jsonpath value against manual regex
jsonPath('$.duck', byRegex("[0-9]{3}"))
// asserts the jsonpath value against the provided value
jsonPath('$.duck', byEquality())
// asserts the jsonpath value against some default regex
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()))
jsonPath('$.alpha', byEquality())
jsonPath('$.number', byRegex(number()))
jsonPath('$.positiveInteger', byRegex(anInteger()))
jsonPath('$.negativeInteger', byRegex(anInteger()))
jsonPath('$.positiveDecimalNumber', byRegex(aDouble()))
jsonPath('$.negativeDecimalNumber', byRegex(aDouble()))
jsonPath('$.aBoolean', byRegex(anyBoolean()))
// asserts vs inbuilt time related regex
jsonPath('$.date', byDate())
jsonPath('$.dateTime', byTimestamp())
jsonPath('$.time', byTime())
// asserts that the resulting type is the same as in response body
jsonPath('$.valueWithTypeMatch', byType())
jsonPath('$.valueWithMin', byType {
// results in verification of size of array (min 1)
minOccurrence(1)
})
jsonPath('$.valueWithMax', byType {
// results in verification of size of array (max 3)
maxOccurrence(3)
})
jsonPath('$.valueWithMinMax', byType {
// results in verification of size of array (min 1 & max 3)
minOccurrence(1)
maxOccurrence(3)
})
jsonPath('$.valueWithMinEmpty', byType {
// results in verification of size of array (min 0)
minOccurrence(0)
})
jsonPath('$.valueWithMaxEmpty', byType {
// results in verification of size of array (max 0)
maxOccurrence(0)
})
// will execute a method `assertThatValueIsANumber`
jsonPath('$.duck', byCommand('assertThatValueIsANumber($it)'))
jsonPath("\$.['key'].['complex.key']", byEquality())
jsonPath('$.nullValue', byNull())
}
@Shared def patternsContract = Contract.make {
request {
method(GET())
urlPath(value(regex("/info/[0-9]"))) {
queryParameters {
parameter 'limit': $(consumer(equalTo('20')), producer(equalTo('10')))
parameter 'offset': $(consumer(containing("20")), producer(equalTo('20')))
parameter 'filter': 'email'
parameter 'sort': equalTo("name")
parameter 'age': $(consumer(notMatching("^\\w*\$")), producer('99'))
parameter 'name': $(consumer(matching('John.*')), producer('John.Doe'))
parameter 'email': 'bob@email.com'
parameter 'hello': $(consumer(matching('John.*')), producer(absent()))
parameter 'hello2': absent()
}
}
headers {
contentType(applicationJson())
header([
second: "value", third: $(anyAlphaNumeric())
])
}
body([
foo1 : $(c(regex("[0-9]")), p(1)),
foo2 : $(c(regex("[0-9]"))),
foo3 : $(anyAlphaNumeric()),
foo4 : value(regex(aDouble())),
foo5 : value(anyDouble()),
foo6 : "concrete",
duck : 123,
alpha : 'abc',
number : 123,
aBoolean : true,
date : '2017-01-01',
dateTime : '2017-01-01T01:23:45',
time : '01:02:34',
valueWithoutAMatcher: 'foo',
valueWithTypeMatch : 'string',
key : [
'complex.key': 'foo'
]
])
bodyMatchers {
jsonPath('$.duck', byRegex("[0-9]{3}"))
jsonPath('$.duck', byEquality())
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()))
jsonPath('$.alpha', byEquality())
jsonPath('$.number', byRegex(number()))
jsonPath('$.aBoolean', byRegex(anyBoolean()))
jsonPath('$.date', byDate())
jsonPath('$.dateTime', byTimestamp())
jsonPath('$.time', byTime())
jsonPath("\$.['key'].['complex.key']", byEquality())
}
}
response {
status(OK())
headers {
contentType(applicationJson())
header([
second: "value", third: $(anyAlphaNumeric())
])
}
body([
foo1 : $(p(regex("[0-9]")), c(1)),
foo2 : $(p(regex("[0-9]"))),
foo3 : $(anyAlphaNumeric()),
foo4 : value(regex(aDouble())),
foo5 : value(anyDouble()),
foo6 : "concrete",
duck : 123,
alpha : 'abc',
number : 123,
positiveInteger : 1234567890,
negativeInteger : -1234567890,
positiveDecimalNumber: 123.4567890,
negativeDecimalNumber: -123.4567890,
aBoolean : true,
date : '2017-01-01',
dateTime : '2017-01-01T01:23:45',
time : "01:02:34",
valueWithoutAMatcher : 'foo',
valueWithTypeMatch : 'string',
valueWithMin : [
1, 2, 3
],
valueWithMax : [
1, 2, 3
],
valueWithMinMax : [
1, 2, 3
],
valueWithMinEmpty : [],
valueWithMaxEmpty : [],
key : [
'complex.key': 'foo'
],
nullValue : null
])
bodyMatchers {
// asserts the jsonpath value against manual regex
jsonPath('$.duck', byRegex("[0-9]{3}"))
// asserts the jsonpath value against the provided value
jsonPath('$.duck', byEquality())
// asserts the jsonpath value against some default regex
jsonPath('$.alpha', byRegex(onlyAlphaUnicode()))
jsonPath('$.alpha', byEquality())
jsonPath('$.number', byRegex(number()))
jsonPath('$.positiveInteger', byRegex(anInteger()))
jsonPath('$.negativeInteger', byRegex(anInteger()))
jsonPath('$.positiveDecimalNumber', byRegex(aDouble()))
jsonPath('$.negativeDecimalNumber', byRegex(aDouble()))
jsonPath('$.aBoolean', byRegex(anyBoolean()))
// asserts vs inbuilt time related regex
jsonPath('$.date', byDate())
jsonPath('$.dateTime', byTimestamp())
jsonPath('$.time', byTime())
// asserts that the resulting type is the same as in response body
jsonPath('$.valueWithTypeMatch', byType())
jsonPath('$.valueWithMin', byType {
// results in verification of size of array (min 1)
minOccurrence(1)
})
jsonPath('$.valueWithMax', byType {
// results in verification of size of array (max 3)
maxOccurrence(3)
})
jsonPath('$.valueWithMinMax', byType {
// results in verification of size of array (min 1 & max 3)
minOccurrence(1)
maxOccurrence(3)
})
jsonPath('$.valueWithMinEmpty', byType {
// results in verification of size of array (min 0)
minOccurrence(0)
})
jsonPath('$.valueWithMaxEmpty', byType {
// results in verification of size of array (max 0)
maxOccurrence(0)
})
// will execute a method `assertThatValueIsANumber`
jsonPath('$.duck', byCommand('assertThatValueIsANumber($it)'))
jsonPath("\$.['key'].['complex.key']", byEquality())
jsonPath('$.nullValue', byNull())
}
}
}
def "should convert patterns to proper value"() {
when:
def subject = new WireMockRequestStubStrategy(contract, null) {
def subject = new WireMockRequestStubStrategy(patternsContract, null) {
@Override
protected ContentType contentType(SingleContractMetadata singleContractMetadata) {
return ContentType.JSON
@@ -255,7 +256,7 @@ class WireMockResponseStubStrategySpec extends Specification {
then:
noExceptionThrown()
when:
def response = new WireMockResponseStubStrategy(contract, null) {
def response = new WireMockResponseStubStrategy(patternsContract, null) {
@Override
protected ContentType contentType(SingleContractMetadata singleContractMetadata) {
return ContentType.JSON

View File

@@ -75,7 +75,7 @@ class XmlToXPathsConverterSpec extends Specification {
}
@Unroll
def "should remove elements to [#expectedValue] for xPath [#value]"() {
def "should remove elements to [#result] for xPath [#xpath]"() {
given:
BodyMatchers m = new BodyMatchers()
m.xPath(xpath, m.byEquality())

View File

@@ -49,6 +49,11 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.spockframework</groupId>
<artifactId>spock-junit4</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -58,11 +58,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -71,11 +71,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-webflux</artifactId>

View File

@@ -57,11 +57,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-test</artifactId>

View File

@@ -70,11 +70,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -59,11 +59,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -56,11 +56,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -61,11 +61,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -62,11 +62,6 @@
<artifactId>spring-boot-starter-web</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>

View File

@@ -59,11 +59,6 @@
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>info.solidsoft.spock</groupId>
<artifactId>spock-global-unroll</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>