Merge branch '1.0.x'
This commit is contained in:
@@ -49,10 +49,10 @@ include::{samples_url}/producer_with_restdocs/src/assembly/stub.xml[indent=0]
|
||||
include::{plugins_path}/spring-cloud-contract-gradle-plugin/src/test/resources/functionalTest/scenarioProject/build.gradle[tags=jar_setup,indent=0]
|
||||
----
|
||||
|
||||
==== Modules
|
||||
|
||||
include::{stubrunner_core_path}/README.adoc[]
|
||||
|
||||
=== Common
|
||||
|
||||
==== Common properties for JUnit and Spring
|
||||
|
||||
Some of the properties that are repetitive can be set using system properties or configuration properties (for Spring). Here are their names with their default values:
|
||||
@@ -68,6 +68,8 @@ Some of the properties that are repetitive can be set using system properties or
|
||||
|stubrunner.ids|| Array of Ivy notation stubs to download
|
||||
|stubrunner.username|| Optional username to access the tool that stores the JARs with stubs
|
||||
|stubrunner.password|| Optional password to access the tool that stores the JARs with stubs
|
||||
|stubrunner.stubsPerConsumer|false| Set to `true` if you want to use different stubs per each consumer instead of registering all stubs for every consumer
|
||||
|stubrunner.consumerName|| If you want to use stubs per consumer and want to override the consumer name just change this value
|
||||
|======================
|
||||
|
||||
===== Stub runner stubs ids
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<description>Spring Cloud Contract Dependencies</description>
|
||||
<properties>
|
||||
<wiremock.version>2.5.1</wiremock.version>
|
||||
<jsonassert.version>0.4.8</jsonassert.version>
|
||||
<jsonassert.version>0.4.9</jsonassert.version>
|
||||
<aether.version>1.0.2.v20150114</aether.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
|
||||
@@ -63,7 +63,7 @@
|
||||
<dependency>
|
||||
<groupId>com.toomuchcoding.jsonassert</groupId>
|
||||
<artifactId>jsonassert</artifactId>
|
||||
<version>0.4.8</version>
|
||||
<version>0.4.9</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
|
||||
@@ -26,6 +26,8 @@ import spock.lang.Issue
|
||||
import spock.lang.Shared
|
||||
import spock.lang.Specification
|
||||
|
||||
import java.lang.reflect.InvocationTargetException
|
||||
|
||||
class MethodBodyBuilderSpec extends Specification implements WireMockStubVerifier {
|
||||
|
||||
@Rule OutputCapture capture = new OutputCapture()
|
||||
@@ -153,4 +155,56 @@ DocumentContext parsedJson = JsonPath.parse(json);
|
||||
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
|
||||
}
|
||||
|
||||
@Issue('#289')
|
||||
def "should fail on nonexistent field [#methodBuilderName]"() {
|
||||
given:
|
||||
Contract contractDsl = Contract.make {
|
||||
request {
|
||||
method 'GET'
|
||||
url '/something'
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
}
|
||||
}
|
||||
response {
|
||||
status 200
|
||||
headers {
|
||||
contentType(applicationJson())
|
||||
}
|
||||
body([
|
||||
doesNotExist: $(p(anyAlphaUnicode()), c("123"))
|
||||
])
|
||||
}
|
||||
}
|
||||
MethodBodyBuilder builder = methodBuilder(contractDsl)
|
||||
BlockBuilder blockBuilder = new BlockBuilder(" ")
|
||||
when:
|
||||
builder.appendTo(blockBuilder)
|
||||
def test = blockBuilder.toString()
|
||||
then:
|
||||
SyntaxChecker.tryToCompile(methodBuilderName, blockBuilder.toString())
|
||||
and:
|
||||
String jsonSample = '''\
|
||||
String json = "{}";
|
||||
DocumentContext parsedJson = JsonPath.parse(json);
|
||||
'''
|
||||
and:
|
||||
LinkedList<String> lines = [] as LinkedList<String>
|
||||
test.eachLine { if (it.contains('assertThatJson')) lines << it else it }
|
||||
lines.addFirst(jsonSample)
|
||||
try {
|
||||
SyntaxChecker.tryToRun(methodBuilderName, lines.join("\n"))
|
||||
} catch (IllegalStateException e) {
|
||||
assert e.message.contains("Parsed JSON [{}] doesn't match the JSON path")
|
||||
} catch (InvocationTargetException e1) {
|
||||
assert e1.cause.message.contains("Parsed JSON [{}] doesn't match the JSON path")
|
||||
}
|
||||
where:
|
||||
methodBuilderName | methodBuilder
|
||||
"MockMvcSpockMethodBuilder" | { Contract dsl -> new MockMvcSpockMethodRequestProcessingBodyBuilder(dsl, properties) }
|
||||
"MockMvcJUnitMethodBuilder" | { Contract dsl -> new MockMvcJUnitMethodBodyBuilder(dsl, properties) }
|
||||
"JaxRsClientSpockMethodRequestProcessingBodyBuilder" | { Contract dsl -> new JaxRsClientSpockMethodRequestProcessingBodyBuilder(dsl, properties) }
|
||||
"JaxRsClientJUnitMethodBodyBuilder" | { Contract dsl -> new JaxRsClientJUnitMethodBodyBuilder(dsl, properties) }
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user