Merge branch 'master' into 2.0.x
This commit is contained in:
@@ -41,10 +41,10 @@ dependencies {
|
||||
}
|
||||
----
|
||||
|
||||
====== Gradle and Rest Assured 3.0
|
||||
====== Gradle and Rest Assured 2.0
|
||||
|
||||
By default Rest Assured 2.x is added to the classpath. However in order to give the users the
|
||||
opportunity to use Rest Assured 3.x it's enough to add it to the plugins classpath.
|
||||
By default Rest Assured 3.x is added to the classpath. However in order to give the users the
|
||||
opportunity to use Rest Assured 2.x it's enough to add it to the plugins classpath.
|
||||
|
||||
[source,groovy,indent=0]
|
||||
----
|
||||
@@ -55,20 +55,20 @@ buildscript {
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:${springboot_version}"
|
||||
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${verifier_version}"
|
||||
classpath "io.rest-assured:rest-assured:3.0.2"
|
||||
classpath "io.rest-assured:spring-mock-mvc:3.0.2"
|
||||
classpath "com.jayway.restassured:rest-assured:2.5.0"
|
||||
classpath "com.jayway.restassured:spring-mock-mvc:2.5.0"
|
||||
}
|
||||
}
|
||||
|
||||
depenendencies {
|
||||
// all dependencies
|
||||
// you can exclude rest-assured from spring-cloud-contract-verifier
|
||||
testCompile "io.rest-assured:rest-assured:3.0.2"
|
||||
testCompile "io.rest-assured:spring-mock-mvc:3.0.2"
|
||||
testCompile "com.jayway.restassured:rest-assured:2.5.0"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:2.5.0"
|
||||
}
|
||||
----
|
||||
|
||||
That way the plugin will automatically see that Rest Assured 3.x is present on the classpath
|
||||
That way the plugin will automatically see that Rest Assured 2.x is present on the classpath
|
||||
and will modify the imports accordingly.
|
||||
|
||||
====== Snapshot versions for Gradle
|
||||
@@ -307,10 +307,10 @@ include::{standalone_samples_path}/http-server/pom.xml[tags=contract_maven_plugi
|
||||
|
||||
You can read more in the https://cloud.spring.io/spring-cloud-contract/spring-cloud-contract-maven-plugin/[Spring Cloud Contract Maven Plugin Docs]
|
||||
|
||||
====== Maven and Rest Assured 3.0
|
||||
====== Maven and Rest Assured 2.0
|
||||
|
||||
By default Rest Assured 2.x is added to the classpath. However in order to give the users the
|
||||
opportunity to use Rest Assured 3.x it's enough to add it to the plugins classpath.
|
||||
By default Rest Assured 3.x is added to the classpath. However in order to give the users the
|
||||
opportunity to use Rest Assured 2.x it's enough to add it to the plugins classpath.
|
||||
|
||||
[source,groovy,indent=0]
|
||||
----
|
||||
@@ -329,15 +329,15 @@ opportunity to use Rest Assured 3.x it's enough to add it to the plugins classpa
|
||||
<version>${spring-cloud-contract.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.5.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.5.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -347,15 +347,15 @@ opportunity to use Rest Assured 3.x it's enough to add it to the plugins classpa
|
||||
<!-- all dependencies -->
|
||||
<!-- you can exclude rest-assured from spring-cloud-contract-verifier -->
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.5.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.example.fraud;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
|
||||
public class FraudBase {
|
||||
@Before
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.example.fraud;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
|
||||
public class FraudnameBase {
|
||||
|
||||
|
||||
@@ -9,8 +9,8 @@ buildscript {
|
||||
dependencies {
|
||||
classpath "org.springframework.boot:spring-boot-gradle-plugin:2.0.0.BUILD-SNAPSHOT"
|
||||
classpath "org.springframework.cloud:spring-cloud-contract-gradle-plugin:${findProperty('verifierVersion') ?: verifierVersion}"
|
||||
classpath "io.rest-assured:rest-assured:3.0.2"
|
||||
classpath "io.rest-assured:spring-mock-mvc:3.0.2"
|
||||
classpath "com.jayway.restassured:rest-assured:2.9.0"
|
||||
classpath "com.jayway.restassured:spring-mock-mvc:2.9.0"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,8 +55,8 @@ dependencies {
|
||||
|
||||
testCompile 'org.springframework.cloud:spring-cloud-starter-contract-verifier'
|
||||
testCompile "org.springframework.cloud:spring-cloud-stream-test-support"
|
||||
testCompile "io.rest-assured:rest-assured:3.0.2"
|
||||
testCompile "io.rest-assured:spring-mock-mvc:3.0.2"
|
||||
testCompile "com.jayway.restassured:rest-assured:2.9.0"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:2.9.0"
|
||||
}
|
||||
|
||||
task stubsJar(type: Jar, dependsOn: "generateWireMockClientStubs") {
|
||||
|
||||
@@ -46,11 +46,11 @@
|
||||
<scope>test</scope>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
@@ -58,15 +58,15 @@
|
||||
|
||||
<!-- Example of overriding Rest Assured version -->
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.9.0</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
@@ -106,15 +106,15 @@
|
||||
<!-- Example of using Rest Assured 3.x. If you don't add this section Rest Assured 2.9.0 will be used -->
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.9.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>3.0.2</version>
|
||||
<version>2.9.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package com.example.source;
|
||||
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import org.junit.Before;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.example.fraud;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
|
||||
public class FraudBase {
|
||||
|
||||
|
||||
@@ -124,11 +124,10 @@
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>${jsonassert.version}</version>
|
||||
</dependency>
|
||||
<!-- TODO: In 1.2.x make 3.0.0 default -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<version>3.0.2</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<artifactId>spring-web</artifactId>
|
||||
@@ -144,6 +143,11 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>3.0.2</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.aether</groupId>
|
||||
<artifactId>aether-api</artifactId>
|
||||
|
||||
@@ -18,7 +18,11 @@
|
||||
<artifactId>spring-cloud-contract-verifier</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -91,7 +91,7 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.contract.stubrunner.server
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import groovy.json.JsonSlurper
|
||||
import org.springframework.beans.factory.annotation.Autowired
|
||||
import org.springframework.boot.test.context.SpringBootContextLoader
|
||||
|
||||
@@ -14,6 +14,8 @@ apply plugin: 'maven-publish'
|
||||
group = 'org.springframework.cloud.testprojects'
|
||||
|
||||
ext {
|
||||
restAssuredVersion = '3.0.2'
|
||||
|
||||
contractsDir = file("repository/mappings")
|
||||
stubsOutputDirRoot = file("${project.buildDir}/production/${project.name}-stubs/repository/")
|
||||
}
|
||||
@@ -35,8 +37,8 @@ dependencies {
|
||||
testCompile "com.github.tomakehurst:wiremock:${wiremockVersion}"
|
||||
testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}"
|
||||
testCompile "org.spockframework:spock-spring:1.0-groovy-2.4"
|
||||
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
testCompile "io.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "io.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
testCompile "ch.qos.logback:logback-classic:1.1.2"
|
||||
testCompile "org.springframework.cloud:spring-cloud-contract-verifier:${verifierVersion}"
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
package org.springframework.cloud.contract.verifier.twitter.places
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import org.springframework.cloud.contract.verifier.twitter.place.PairIdController
|
||||
import spock.lang.Specification
|
||||
|
||||
|
||||
@@ -34,7 +34,6 @@ allprojects {
|
||||
}
|
||||
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
spockVersion = '1.0-groovy-2.4'
|
||||
|
||||
contractVerifierStubsBaseDirectory = 'src/test/resources/stubs'
|
||||
|
||||
@@ -28,7 +28,7 @@ buildscript {
|
||||
}
|
||||
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
restAssuredVersion = '3.0.2'
|
||||
spockVersion = '1.0-groovy-2.4'
|
||||
|
||||
contractVerifierStubsBaseDirectory = 'src/test/resources/stubs'
|
||||
@@ -92,8 +92,8 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
|
||||
testCompile "org.mockito:mockito-core"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.springframework.boot:spring-boot-test"
|
||||
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
testCompile "io.rest-assured:rest-assured:$restAssuredVersion"
|
||||
testCompile "io.rest-assured:spring-mock-mvc:$restAssuredVersion"
|
||||
}
|
||||
|
||||
task cleanup(type: Delete) {
|
||||
@@ -115,7 +115,7 @@ configure(project(':fraudDetectionService')) {
|
||||
|
||||
configure(project(':loanApplicationService')) {
|
||||
|
||||
task copyCollaboratorStubs(type: Copy) {
|
||||
task copyCollaboratorStubs(type: com.sun.org.apache.xalan.internal.xsltc.compiler.Copy) {
|
||||
File fraudBuildDir = project(':fraudDetectionService').buildDir
|
||||
from(new File(fraudBuildDir, "/production/${project(':fraudDetectionService').name}-stubs/"))
|
||||
into "src/test/resources/"
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.cloud
|
||||
|
||||
import org.springframework.cloud.frauddetection.FraudDetectionController
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import spock.lang.Specification
|
||||
|
||||
class MvcSpec extends Specification {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.cloud;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import org.junit.Before;
|
||||
|
||||
public class MvcTest {
|
||||
|
||||
@@ -28,7 +28,7 @@ buildscript {
|
||||
}
|
||||
|
||||
ext {
|
||||
restAssuredVersion = '2.5.0'
|
||||
restAssuredVersion = '3.0.2'
|
||||
spockVersion = '1.0-groovy-2.4'
|
||||
|
||||
contractVerifierStubsBaseDirectory = 'src/test/resources/stubs'
|
||||
@@ -51,7 +51,7 @@ subprojects {
|
||||
dependencies {
|
||||
testCompile "org.codehaus.groovy:groovy-all:2.5.0-beta-1"
|
||||
testCompile "org.spockframework:spock-core:$spockVersion"
|
||||
testCompile("junit:junit:4.12")
|
||||
testCompile "junit:junit:4.12"
|
||||
testCompile "com.github.tomakehurst:wiremock:${wiremockVersion}"
|
||||
testCompile "com.toomuchcoding.jsonassert:jsonassert:${jsonAssertVersion}"
|
||||
testCompile "org.assertj:assertj-core:2.4.1"
|
||||
@@ -116,8 +116,8 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService')
|
||||
testCompile "org.mockito:mockito-core"
|
||||
testCompile "org.springframework:spring-test"
|
||||
testCompile "org.springframework.boot:spring-boot-test"
|
||||
testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion"
|
||||
testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion"
|
||||
testCompile "io.rest-assured:rest-assured:$restAssuredVersion"
|
||||
testCompile "io.rest-assured:spring-mock-mvc:$restAssuredVersion"
|
||||
}
|
||||
|
||||
task cleanup(type: Delete) {
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
package org.springframework.cloud
|
||||
|
||||
import org.springframework.cloud.frauddetection.FraudDetectionController
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import spock.lang.Specification
|
||||
|
||||
class MvcSpec extends Specification {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.springframework.cloud;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import org.junit.Before;
|
||||
|
||||
public class MvcTest {
|
||||
|
||||
@@ -49,15 +49,15 @@
|
||||
<!-- verifier test dependencies-->
|
||||
<!-- tag::dependencies[] -->
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<version>3.0.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<version>2.9.0</version>
|
||||
<version>3.0.2</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package com.blogspot.toomuchcoding.frauddetection;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package hello;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package hello
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc
|
||||
import spock.lang.Specification
|
||||
|
||||
public class BaseAccurest extends Specification {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*/
|
||||
package hello;
|
||||
|
||||
import com.jayway.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
import io.restassured.module.mockmvc.RestAssuredMockMvc;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
|
||||
@@ -111,7 +111,12 @@
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.jayway.restassured</groupId>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>rest-assured</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.rest-assured</groupId>
|
||||
<artifactId>spring-mock-mvc</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
@@ -41,7 +41,7 @@ class JavaTestGenerator implements SingleTestGenerator {
|
||||
|
||||
private static final String JSON_ASSERT_STATIC_IMPORT = 'com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson'
|
||||
private static final String JSON_ASSERT_CLASS = 'com.toomuchcoding.jsonassert.JsonAssertion'
|
||||
private static final String REST_ASSURED_3_0_CLASS = 'io.restassured.RestAssured'
|
||||
private static final String REST_ASSURED_2_0_CLASS = 'com.jayway.restassured.RestAssured'
|
||||
|
||||
@PackageScope ClassPresenceChecker checker = new ClassPresenceChecker()
|
||||
|
||||
@@ -69,9 +69,9 @@ class JavaTestGenerator implements SingleTestGenerator {
|
||||
addJsonPathRelatedImports(clazz)
|
||||
|
||||
Map<ParsedDsl, TestType> contracts = mapContractsToTheirTestTypes(listOfFiles)
|
||||
boolean restAssured3Present = this.checker.isClassPresent(REST_ASSURED_3_0_CLASS)
|
||||
String restAssuredPackage = restAssured3Present ? 'io.restassured' : 'com.jayway.restassured'
|
||||
log.info("Rest Assured version 3.0 found [${restAssured3Present}]")
|
||||
boolean restAssured2Present = this.checker.isClassPresent(REST_ASSURED_2_0_CLASS)
|
||||
String restAssuredPackage = restAssured2Present ? 'com.jayway.restassured' : 'io.restassured'
|
||||
log.info("Rest Assured version 2.x found [${restAssured2Present}]")
|
||||
boolean conditionalImportsAdded = false
|
||||
boolean toIgnore = listOfFiles.ignored.find { it }
|
||||
contracts.each { ParsedDsl key, TestType value ->
|
||||
|
||||
@@ -22,7 +22,6 @@ import org.springframework.cloud.contract.verifier.TestGenerator
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
import org.springframework.cloud.contract.verifier.config.TestMode
|
||||
import org.springframework.cloud.contract.verifier.file.ContractMetadata
|
||||
import org.springframework.cloud.contract.verifier.util.ContractVerifierDslConverter
|
||||
import org.springframework.cloud.contract.verifier.util.SyntaxChecker
|
||||
import org.springframework.util.StringUtils
|
||||
import spock.lang.Issue
|
||||
@@ -38,11 +37,11 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
TemporaryFolder tmpFolder = new TemporaryFolder()
|
||||
File file
|
||||
|
||||
private static final List<String> mockMvcJUnitClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
|
||||
'import org.junit.FixMethodOrder;', 'import org.junit.Ignore;', 'import org.junit.Test;', 'import org.junit.runners.MethodSorters;',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*;',
|
||||
'@FixMethodOrder(MethodSorters.NAME_ASCENDING)', '@Test', '@Ignore', 'import com.jayway.restassured.module.mockmvc.specification.MockMvcRequestSpecification;',
|
||||
'import com.jayway.restassured.response.ResponseOptions;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
|
||||
private static final List<String> mockMvcJUnitRestAssured2ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
|
||||
'import org.junit.FixMethodOrder;', 'import org.junit.Ignore;', 'import org.junit.Test;', 'import org.junit.runners.MethodSorters;',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*;',
|
||||
'@FixMethodOrder(MethodSorters.NAME_ASCENDING)', '@Test', '@Ignore', 'import com.jayway.restassured.module.mockmvc.specification.MockMvcRequestSpecification;',
|
||||
'import com.jayway.restassured.response.ResponseOptions;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
|
||||
|
||||
private static final List<String> mockMvcJUnitRestAssured3ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
|
||||
'import org.junit.FixMethodOrder;', 'import org.junit.Ignore;', 'import org.junit.Test;', 'import org.junit.runners.MethodSorters;',
|
||||
@@ -51,37 +50,37 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
'import io.restassured.response.ResponseOptions;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
|
||||
|
||||
|
||||
private static final List<String> explicitJUnitClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
|
||||
'import org.junit.FixMethodOrder;', 'import org.junit.Ignore;', 'import org.junit.Test;', 'import org.junit.runners.MethodSorters;',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static com.jayway.restassured.RestAssured.*;',
|
||||
'@FixMethodOrder(MethodSorters.NAME_ASCENDING)', '@Test', '@Ignore', 'import com.jayway.restassured.specification.RequestSpecification;',
|
||||
'import com.jayway.restassured.response.Response;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
|
||||
private static final List<String> explicitJUnitRestAssured2ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
|
||||
'import org.junit.FixMethodOrder;', 'import org.junit.Ignore;', 'import org.junit.Test;', 'import org.junit.runners.MethodSorters;',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static com.jayway.restassured.RestAssured.*;',
|
||||
'@FixMethodOrder(MethodSorters.NAME_ASCENDING)', '@Test', '@Ignore', 'import com.jayway.restassured.specification.RequestSpecification;',
|
||||
'import com.jayway.restassured.response.Response;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
|
||||
|
||||
private static final List<String> explicitJUnitRestAssured3ClassStrings = ['import com.jayway.jsonpath.DocumentContext;', 'import com.jayway.jsonpath.JsonPath;',
|
||||
'import org.junit.FixMethodOrder;', 'import org.junit.Ignore;', 'import org.junit.Test;', 'import org.junit.runners.MethodSorters;',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static io.restassured.RestAssured.*;',
|
||||
'@FixMethodOrder(MethodSorters.NAME_ASCENDING)', '@Test', '@Ignore', 'import io.restassured.specification.RequestSpecification;',
|
||||
'import io.restassured.response.Response;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
|
||||
'import org.junit.FixMethodOrder;', 'import org.junit.Ignore;', 'import org.junit.Test;', 'import org.junit.runners.MethodSorters;',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson;', 'import static io.restassured.RestAssured.*;',
|
||||
'@FixMethodOrder(MethodSorters.NAME_ASCENDING)', '@Test', '@Ignore', 'import io.restassured.specification.RequestSpecification;',
|
||||
'import io.restassured.response.Response;', 'import static org.springframework.cloud.contract.verifier.assertion.SpringCloudContractAssertions.assertThat']
|
||||
|
||||
private static final List<String> spockClassStrings = ['import com.jayway.jsonpath.DocumentContext', 'import com.jayway.jsonpath.JsonPath',
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
private static final List<String> spockClassRestAssured2Strings = ['import com.jayway.jsonpath.DocumentContext', 'import com.jayway.jsonpath.JsonPath',
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
|
||||
private static final List<String> spockClassRestAssured3Strings = ['import com.jayway.jsonpath.DocumentContext', 'import com.jayway.jsonpath.JsonPath',
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static io.restassured.module.mockmvc.RestAssuredMockMvc.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static io.restassured.module.mockmvc.RestAssuredMockMvc.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
|
||||
private static final List<String> explicitSpockClassStrings = ['import com.jayway.jsonpath.DocumentContext', 'import com.jayway.jsonpath.JsonPath',
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static com.jayway.restassured.RestAssured.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
private static final List<String> explicitSpockRestAssured2ClassStrings = ['import com.jayway.jsonpath.DocumentContext', 'import com.jayway.jsonpath.JsonPath',
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static com.jayway.restassured.RestAssured.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
|
||||
private static final List<String> explicitSpockRestAssured3ClassStrings = ['import com.jayway.jsonpath.DocumentContext', 'import com.jayway.jsonpath.JsonPath',
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static io.restassured.RestAssured.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
'import spock.lang.Ignore', 'import spock.lang.Specification', 'import spock.lang.Stepwise',
|
||||
'import static com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson', 'import static io.restassured.RestAssured.*',
|
||||
'@Stepwise', '@Ignore']
|
||||
|
||||
public static final Closure JAVA_ASSERTER = { String classToTest ->
|
||||
String name = Math.abs(new Random().nextInt())
|
||||
@@ -148,11 +147,11 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
and:
|
||||
asserter(clazz)
|
||||
where:
|
||||
testFramework | mode | classStrings | asserter
|
||||
JUNIT | TestMode.MOCKMVC | mockMvcJUnitClassStrings | JAVA_ASSERTER
|
||||
JUNIT | TestMode.EXPLICIT | explicitJUnitClassStrings | JAVA_ASSERTER
|
||||
SPOCK | TestMode.MOCKMVC | spockClassStrings | GROOVY_ASSERTER
|
||||
SPOCK | TestMode.EXPLICIT | explicitSpockClassStrings | GROOVY_ASSERTER
|
||||
testFramework | mode | classStrings | asserter
|
||||
JUNIT | TestMode.MOCKMVC | mockMvcJUnitRestAssured3ClassStrings | JAVA_ASSERTER
|
||||
JUNIT | TestMode.EXPLICIT | explicitJUnitRestAssured3ClassStrings | JAVA_ASSERTER
|
||||
SPOCK | TestMode.MOCKMVC | spockClassRestAssured3Strings | GROOVY_ASSERTER
|
||||
SPOCK | TestMode.EXPLICIT | explicitSpockRestAssured3ClassStrings | GROOVY_ASSERTER
|
||||
}
|
||||
|
||||
def "should build test class for #testFramework when the path contains bizarre signs"() {
|
||||
@@ -182,13 +181,13 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
SPOCK | TestMode.EXPLICIT | GROOVY_ASSERTER | "ContractsSpec.groovy"
|
||||
}
|
||||
|
||||
def "should build test class for #testFramework with Rest Assured 3.0"() {
|
||||
def "should build test class for #testFramework with Rest Assured 2.x"() {
|
||||
given:
|
||||
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties()
|
||||
properties.targetFramework = testFramework
|
||||
properties.testMode = mode
|
||||
ContractMetadata contract = new ContractMetadata(file.toPath(), true, 1, 2,
|
||||
ContractVerifierDslConverter.convertAsCollection(file) )
|
||||
convertAsCollection(file) )
|
||||
contract.ignored >> true
|
||||
contract.order >> 2
|
||||
JavaTestGenerator testGenerator = new JavaTestGenerator(checker: new ClassPresenceChecker() {
|
||||
@@ -203,14 +202,15 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
|
||||
then:
|
||||
classStrings.each { assert clazz.contains(it) }
|
||||
!clazz.contains("com.jayway.restassured")
|
||||
clazz.contains("com.jayway.restassured")
|
||||
!clazz.contains("io.restassured")
|
||||
|
||||
where:
|
||||
testFramework | mode | classStrings
|
||||
JUNIT | TestMode.MOCKMVC | mockMvcJUnitRestAssured3ClassStrings
|
||||
JUNIT | TestMode.EXPLICIT | explicitJUnitRestAssured3ClassStrings
|
||||
SPOCK | TestMode.MOCKMVC | spockClassRestAssured3Strings
|
||||
SPOCK | TestMode.EXPLICIT | explicitSpockRestAssured3ClassStrings
|
||||
JUNIT | TestMode.MOCKMVC | mockMvcJUnitRestAssured2ClassStrings
|
||||
JUNIT | TestMode.EXPLICIT | explicitJUnitRestAssured2ClassStrings
|
||||
SPOCK | TestMode.MOCKMVC | spockClassRestAssured2Strings
|
||||
SPOCK | TestMode.EXPLICIT | explicitSpockRestAssured2ClassStrings
|
||||
}
|
||||
|
||||
def "should build test class for #testFramework and mode #mode with two files"() {
|
||||
@@ -258,11 +258,11 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
ContractVerifierConfigProperties properties = new ContractVerifierConfigProperties()
|
||||
properties.targetFramework = testFramework
|
||||
ContractMetadata contract = new ContractMetadata(file.toPath(), false, 1, null,
|
||||
ContractVerifierDslConverter.convertAsCollection(file) )
|
||||
convertAsCollection(file) )
|
||||
contract.ignored >> false
|
||||
and:
|
||||
ContractMetadata contract2 = new ContractMetadata(file2.toPath(), false, 1, null,
|
||||
ContractVerifierDslConverter.convertAsCollection(file2) )
|
||||
convertAsCollection(file2) )
|
||||
contract2.ignored >> false
|
||||
and:
|
||||
JavaTestGenerator testGenerator = new JavaTestGenerator()
|
||||
@@ -277,11 +277,11 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
and:
|
||||
textAssertion(clazz)
|
||||
where:
|
||||
testFramework | mode | classStrings | asserter | textAssertion
|
||||
JUNIT | TestMode.MOCKMVC | mockMvcJUnitClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tMockMvcRequestSpecification") == 2 }
|
||||
JUNIT | TestMode.EXPLICIT | explicitJUnitClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tMockMvcRequestSpecification") == 2 }
|
||||
SPOCK | TestMode.MOCKMVC | spockClassStrings | GROOVY_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tdef request") == 2 }
|
||||
SPOCK | TestMode.EXPLICIT | explicitSpockClassStrings | GROOVY_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tdef request") == 2 }
|
||||
testFramework | mode | classStrings | asserter | textAssertion
|
||||
JUNIT | TestMode.MOCKMVC | mockMvcJUnitRestAssured3ClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tMockMvcRequestSpecification") == 2 }
|
||||
JUNIT | TestMode.EXPLICIT | explicitJUnitRestAssured3ClassStrings | JAVA_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tMockMvcRequestSpecification") == 2 }
|
||||
SPOCK | TestMode.MOCKMVC | spockClassRestAssured3Strings | GROOVY_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tdef request") == 2 }
|
||||
SPOCK | TestMode.EXPLICIT | explicitSpockRestAssured2ClassStrings | GROOVY_ASSERTER | { String test -> StringUtils.countOccurrencesOf(test, "\t\t\tdef request") == 2 }
|
||||
}
|
||||
|
||||
def "should build JaxRs test class for #testFramework"() {
|
||||
@@ -352,9 +352,9 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
asserter(clazz)
|
||||
|
||||
where:
|
||||
testFramework | classStrings | asserter
|
||||
JUNIT | mockMvcJUnitClassStrings | JAVA_ASSERTER
|
||||
SPOCK | spockClassStrings | GROOVY_ASSERTER
|
||||
testFramework | classStrings | asserter
|
||||
JUNIT | mockMvcJUnitRestAssured3ClassStrings | JAVA_ASSERTER
|
||||
SPOCK | spockClassRestAssured3Strings | GROOVY_ASSERTER
|
||||
}
|
||||
|
||||
@Issue('#30')
|
||||
@@ -394,9 +394,9 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
asserter(clazz)
|
||||
|
||||
where:
|
||||
testFramework | classStrings | asserter
|
||||
JUNIT | mockMvcJUnitClassStrings | JAVA_ASSERTER
|
||||
SPOCK | spockClassStrings | GROOVY_ASSERTER
|
||||
testFramework | classStrings | asserter
|
||||
JUNIT | mockMvcJUnitRestAssured3ClassStrings | JAVA_ASSERTER
|
||||
SPOCK | spockClassRestAssured3Strings | GROOVY_ASSERTER
|
||||
}
|
||||
|
||||
@Issue('#117')
|
||||
@@ -404,7 +404,7 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
given:
|
||||
String baseClass = """
|
||||
// tag::context_path_baseclass[]
|
||||
import com.jayway.restassured.RestAssured;
|
||||
import io.restassured.RestAssured;
|
||||
import org.junit.Before;
|
||||
import org.springframework.boot.web.server.LocalServerPort;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
@@ -445,7 +445,7 @@ class SingleTestGeneratorSpec extends Specification {
|
||||
properties.baseClassForTests = "test.ContextPathTestingBaseClass"
|
||||
and:
|
||||
ContractMetadata contract = new ContractMetadata(file.toPath(), false, 1,
|
||||
null, ContractVerifierDslConverter.convertAsCollection(file))
|
||||
null, convertAsCollection(file))
|
||||
and:
|
||||
SingleTestGenerator testGenerator = new JavaTestGenerator()
|
||||
when:
|
||||
|
||||
@@ -17,9 +17,9 @@ class SyntaxChecker {
|
||||
|
||||
private static final String[] DEFAULT_IMPORTS = [
|
||||
"org.springframework.cloud.contract.spec.Contract",
|
||||
"com.jayway.restassured.response.ResponseOptions",
|
||||
"com.jayway.restassured.module.mockmvc.specification.*",
|
||||
"com.jayway.restassured.module.mockmvc.*",
|
||||
"io.restassured.response.ResponseOptions",
|
||||
"io.restassured.module.mockmvc.specification.*",
|
||||
"io.restassured.module.mockmvc.*",
|
||||
"org.junit.Test",
|
||||
"org.junit.Rule",
|
||||
"com.jayway.jsonpath.DocumentContext",
|
||||
@@ -37,9 +37,9 @@ class SyntaxChecker {
|
||||
}.join("\n")
|
||||
|
||||
private static final String STATIC_IMPORTS = [
|
||||
"com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.given",
|
||||
"com.jayway.restassured.module.mockmvc.RestAssuredMockMvc.when",
|
||||
"com.jayway.restassured.RestAssured.*",
|
||||
"io.restassured.module.mockmvc.RestAssuredMockMvc.given",
|
||||
"io.restassured.module.mockmvc.RestAssuredMockMvc.when",
|
||||
"io.restassured.RestAssured.*",
|
||||
"javax.ws.rs.client.Entity.*",
|
||||
"org.springframework.cloud.contract.verifier.messaging.util.ContractVerifierMessagingUtil.headers",
|
||||
"com.toomuchcoding.jsonassert.JsonAssertion.assertThatJson",
|
||||
|
||||
Reference in New Issue
Block a user