Adds support for binary payloads (#818)

with this change we're adding support for binary payloads both for HTTP and messaging.

fixes #664
This commit is contained in:
Marcin Grzejszczak
2018-12-15 14:06:17 +01:00
committed by GitHub
parent 928b32ecce
commit 0058b987ae
102 changed files with 3282 additions and 1550 deletions

View File

@@ -168,6 +168,23 @@ When test or stub generation takes place, the contents of the file is passed to
of a request or a response. The name of the file needs to be a file with location
relative to the folder in which the contract lays.
If you need to pass the contents of a file in a binary form
it's enough for you to use the `fileAsBytes` method in Groovy DSL or `bodyFromFileAsBytes` field in YAML.
.Groovy DSL
[source,groovy,indent=0]
----
include::{verifier_core_path}/src/test/resources/body_builder/worksWithPdf.groovy[indent=0]
----
.YAML
[source,yml,indent=0]
----
include::{verifier_core_path}/src/test/resources/yml/contract_pdf.yml[indent=0]
----
IMPORTANT: You should use this approach whenever you want to work with binary payloads both for HTTP and messaging.
[[contract-dsl-http-top-level-elements]]
==== HTTP Top-Level Elements
@@ -1645,7 +1662,7 @@ following code listing shows the `SingleTestGenerator` interface:
[source,groovy]
----
include::{verifier_core_path}/src/main/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGenerator.groovy[indent=0,lines=17..-1]
include::{verifier_core_path}/src/main/groovy/org/springframework/cloud/contract/verifier/builder/SingleTestGenerator.java[indent=0,lines=17..-1]
----
Again, you must provide a `spring.factories` file, such as the one shown in the following

View File

@@ -156,6 +156,7 @@ contracts {
testFramework ='JUNIT'
testMode = 'MockMvc'
generatedTestSourcesDir = project.file("${project.buildDir}/generated-test-sources/contracts")
generatedTestResourcesDir = project.file("${project.buildDir}/generated-test-resources/contracts")
contractsDslDir = "${project.rootDir}/src/test/resources/contracts"
basePackageForTests = 'org.springframework.cloud.verifier.tests'
stubsOutputDir = project.file("${project.buildDir}/stubs")
@@ -242,7 +243,10 @@ should be skipped. By default, it is an empty array.
GroovyDSL. By default, its value is `$rootDir/src/test/resources/contracts`.
* *generatedTestSourcesDir*: Specifies the test source directory where tests generated
from the Groovy DSL should be placed. By default its value is
`$buildDir/generated-test-sources/contractVerifier`.
`$buildDir/generated-test-sources/contracts`.
* *generatedTestResourcesDir*: Specifies the test resource directory where resources used by the tests generated
from the Groovy DSL should be placed. By default its value is
`$buildDir/generated-test-resources/contracts`.
* *stubsOutputDir*: Specifies the directory where the generated WireMock stubs from
the Groovy DSL should be placed.
* *testFramework*: Specifies the target test framework to be used. Currently, Spock, JUnit 4 (`TestFramework.JUNIT`) and
@@ -581,6 +585,10 @@ classes.
use Spock classes, the class is `spock.lang.Specification`.
* *contractsDirectory*: Specifies a directory containing contracts written with the
GroovyDSL. The default directory is `/src/test/resources/contracts`.
* *generatedTestSourcesDir*: Specifies the test source directory where tests generated
from the Groovy DSL should be placed. By default its value is
`$buildDir/generated-test-sources/contracts`.
* *generatedTestResourcesDir*: Specifies the test resource directory where resources used by the tests generated
* *testFramework*: Specifies the target test framework to be used. Currently, Spock, JUnit 4 (`TestFramework.JUNIT`) and
JUnit 5 are supported with JUnit 4 being the default framework.
* *packageWithBaseClasses*: Defines a package where all the base classes reside. This