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:
committed by
GitHub
parent
928b32ecce
commit
0058b987ae
@@ -115,6 +115,11 @@ class ContractVerifierExtension {
|
||||
*/
|
||||
File generatedTestSourcesDir
|
||||
|
||||
/**
|
||||
* Test resource directory where tests generated from Groovy DSL should be referenced
|
||||
*/
|
||||
File generatedTestResourcesDir
|
||||
|
||||
/**
|
||||
* Dir where the generated stubs from Groovy DSL should be placed.
|
||||
* You can then mention them in your packaging task to create jar with stubs
|
||||
|
||||
@@ -26,6 +26,7 @@ class ExtensionToProperties {
|
||||
staticImports: extension.getStaticImports(),
|
||||
contractsDslDir: extension.getContractsDslDir(),
|
||||
generatedTestSourcesDir: extension.getGeneratedTestSourcesDir(),
|
||||
generatedTestResourcesDir: extension.getGeneratedTestResourcesDir(),
|
||||
stubsOutputDir: extension.getStubsOutputDir(),
|
||||
stubsSuffix: extension.getStubsSuffix(),
|
||||
assertJsonSize: extension.getAssertJsonSize(),
|
||||
|
||||
@@ -20,11 +20,13 @@ import org.gradle.api.GradleException
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.internal.ConventionTask
|
||||
import org.gradle.api.tasks.TaskAction
|
||||
|
||||
import org.springframework.cloud.contract.spec.ContractVerifierException
|
||||
import org.springframework.cloud.contract.verifier.TestGenerator
|
||||
import org.springframework.cloud.contract.verifier.config.ContractVerifierConfigProperties
|
||||
|
||||
import static org.springframework.cloud.contract.verifier.plugin.SpringCloudContractVerifierGradlePlugin.COPY_CONTRACTS_TASK_NAME
|
||||
|
||||
/**
|
||||
* Task used to generate server side tests
|
||||
*
|
||||
@@ -54,8 +56,14 @@ class GenerateServerTestsTask extends ConventionTask {
|
||||
project.logger.info("Included contracts are [${props.includedContracts}]")
|
||||
|
||||
project.sourceSets.test.groovy {
|
||||
project.logger.info("Registering ${getConfigProperties().generatedTestSourcesDir} as test source directory")
|
||||
srcDir getConfigProperties().generatedTestSourcesDir
|
||||
project.logger.
|
||||
info("Registering ${getConfigProperties().generatedTestSourcesDir} as test source directory")
|
||||
srcDir getConfigProperties().getGeneratedTestSourcesDir()
|
||||
}
|
||||
project.sourceSets.test.resources {
|
||||
project.logger.
|
||||
info("Registering ${getConfigProperties().generatedTestResourcesDir} as test resource directory")
|
||||
srcDir getConfigProperties().getGeneratedTestResourcesDir()
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
@@ -69,13 +69,14 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
addIdeaTestSources(project, extension)
|
||||
}
|
||||
|
||||
private addIdeaTestSources(Project project, extension) {
|
||||
private addIdeaTestSources(Project project, ContractVerifierExtension extension) {
|
||||
def hasIdea = new File(project.rootDir, ".idea").exists()
|
||||
if (hasIdea) {
|
||||
project.apply(plugin: 'idea')
|
||||
project.idea {
|
||||
module {
|
||||
testSourceDirs += extension.generatedTestSourcesDir
|
||||
testSourceDirs += extension.generatedTestResourcesDir
|
||||
testSourceDirs += extension.contractsDslDir
|
||||
}
|
||||
}
|
||||
@@ -86,6 +87,8 @@ class SpringCloudContractVerifierGradlePlugin implements Plugin<Project> {
|
||||
extension.with {
|
||||
generatedTestSourcesDir = generatedTestSourcesDir ?: project.file("${project.buildDir}/generated-test-sources/contracts")
|
||||
generatedTestSourcesDir.mkdirs()
|
||||
generatedTestResourcesDir = generatedTestResourcesDir ?: project.file("${project.buildDir}/generated-test-resources/contracts")
|
||||
generatedTestResourcesDir.mkdirs()
|
||||
contractsDslDir = contractsDslDir ?: defaultContractsDir() //TODO: Use sourceset
|
||||
contractsDslDir.mkdirs()
|
||||
stubsOutputDir = stubsOutputDir ?: project.file("${project.buildDir}/stubs/")
|
||||
|
||||
Reference in New Issue
Block a user