Upgraded Rest Assured to 4.0.0; fixes gh-1122

This commit is contained in:
Marcin Grzejszczak
2019-07-02 14:50:20 +02:00
parent 59d3f0d075
commit b48dd4905f
10 changed files with 136 additions and 21 deletions

View File

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

View File

@@ -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='"-Xmx64m"'
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"

View File

@@ -1,3 +1,19 @@
@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
@@ -14,7 +30,7 @@ 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"
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

View File

@@ -24,6 +24,7 @@
<spring-cloud-contract.version>2.2.0.BUILD-SNAPSHOT</spring-cloud-contract.version>
<spring-cloud-release.version>Hoxton.BUILD-SNAPSHOT
</spring-cloud-release.version>
<rest-assured.version>3.2.0</rest-assured.version>
</properties>
<dependencies>
@@ -42,6 +43,46 @@
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-mock-mvc</artifactId>
<version>${rest-assured.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-web</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-webmvc</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-test</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>spring-web-test-client</artifactId>
<version>${rest-assured.version}</version>
<exclusions>
<exclusion>
<artifactId>spring-context</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
<exclusion>
<artifactId>spring-webflux</artifactId>
<groupId>org.springframework</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
</dependency>
<!-- tag::verifier_test_dependencies[] -->
<dependency>
<groupId>org.springframework.cloud</groupId>

View File

@@ -17,7 +17,7 @@
<properties>
<wiremock.version>2.23.2</wiremock.version>
<jsonassert.version>0.4.13</jsonassert.version>
<rest-assured.version>3.2.0</rest-assured.version>
<rest-assured.version>4.0.0</rest-assured.version>
<maven.version>3.3.9</maven.version>
</properties>
<dependencyManagement>
@@ -135,6 +135,26 @@
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<version>${rest-assured.version}</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy-xml</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>json-path</artifactId>
<version>${rest-assured.version}</version>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>xml-path</artifactId>
<version>${rest-assured.version}</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>

View File

@@ -21,7 +21,6 @@ import java.nio.charset.Charset
import groovy.transform.CompileStatic
import groovy.transform.EqualsAndHashCode
import groovy.transform.ToString
/**
* Represents a property that will become a File content
*
@@ -51,7 +50,9 @@ class FromFileProperty implements Serializable {
}
boolean isByte() {
return this.type == byte[]
// need to take class from a Groovy file, otherwise
// boolean#getAt(List) static compilation issue is thrown
return this.type == GroovyClass.BYTE_CLASS
}
String asString() {

View File

@@ -0,0 +1,27 @@
/*
* 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.spec.internal;
final class GroovyClass {
private GroovyClass() {
throw new IllegalStateException("Can't instantiate a utility class");
}
public static Class<byte[]> BYTE_CLASS = byte[].class;
}

View File

@@ -30,12 +30,6 @@ import com.jayway.jsonpath.JsonPath
import com.toomuchcoding.jsonassert.JsonAssertion
import groovy.transform.CompileStatic
import groovy.util.logging.Commons
import io.restassured.RestAssured
import io.restassured.module.mockmvc.RestAssuredMockMvc
import io.restassured.module.webtestclient.RestAssuredWebTestClient
import io.restassured.module.webtestclient.response.WebTestClientResponse
import io.restassured.module.webtestclient.specification.WebTestClientRequestSpecification
import io.restassured.response.ResponseOptions
import org.codehaus.groovy.control.CompilerConfiguration
import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer
import org.codehaus.groovy.control.customizers.ImportCustomizer
@@ -63,7 +57,7 @@ class SyntaxChecker {
private static final String[] DEFAULT_IMPORTS = [
Contract.name,
ResponseOptions.name,
"io.restassured.response.ResponseOptions",
'io.restassured.module.mockmvc.specification.*',
'io.restassured.module.mockmvc.*',
Test.name,
@@ -76,8 +70,8 @@ class SyntaxChecker {
ContractVerifierMessaging.name,
WebTarget.name,
Response.name,
WebTestClientRequestSpecification.name,
WebTestClientResponse.name,
"io.restassured.module.webtestclient.specification.WebTestClientRequestSpecification",
"io.restassured.module.webtestclient.response.WebTestClientResponse",
DocumentBuilder.name,
DocumentBuilderFactory.name,
Document.name,
@@ -90,9 +84,9 @@ class SyntaxChecker {
}.join("\n")
private static final String STATIC_IMPORTS = [
"${RestAssuredMockMvc.name}.given",
"${RestAssuredMockMvc.name}.when",
"${RestAssured.name}.*",
"io.restassured.module.mockmvc.RestAssuredMockMvc.given",
"io.restassured.module.mockmvc.RestAssuredMockMvc.when",
"io.restassured.RestAssured.*",
"${Entity.name}.*",
"${ContractVerifierUtil.name}.*",
"${ContractVerifierMessagingUtil.name}.headers",
@@ -101,7 +95,7 @@ class SyntaxChecker {
].collect { "import static ${it};" }.join("\n")
private static final String WEB_TEST_CLIENT_STATIC_IMPORTS = [
"${RestAssuredWebTestClient.name}.*",
"io.restassured.module.webtestclient.RestAssuredWebTestClient.*",
"${Entity.name}.*",
"${ContractVerifierUtil.name}.*",
"${ContractVerifierMessagingUtil.name}.headers",

View File

@@ -57,14 +57,14 @@ public class WiremockServerRestAssuredApplicationTests {
@Test
public void contextLoads() throws Exception {
given().port(this.port).when().get("/resource").then().assertThat()
.statusCode(is(200)).content(equalTo("Hello World"));
.statusCode(is(200)).body(equalTo("Hello World"));
}
@Test
public void statusIsMaintained() throws Exception {
given(this.documentationSpec.port(this.port)).filter(document("status")).when()
.get("/status").then().assertThat().statusCode(is(202))
.content(equalTo("Hello World"));
.body(equalTo("Hello World"));
}
@Configuration