From c63dc35e9f2dfc1c356f3144fff9b87f2d6bb974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 6 Jul 2017 12:19:10 +0200 Subject: [PATCH 01/15] Upgradle to Gradle 3.5.1 --- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 ++-- stub-runner/stub-runner/build.gradle | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.gradle b/build.gradle index 53eb33d8..036333de 100644 --- a/build.gradle +++ b/build.gradle @@ -95,7 +95,7 @@ project(':accurest-core') { compile 'org.apache.commons:commons-lang3:3.3' compile "com.github.tomakehurst:wiremock:$wiremockVersion" compile "com.toomuchcoding.jsonassert:jsonassert:$jsonassertVersion" - compile 'org.codehaus.groovy:groovy-all:2.4.4' + compile 'org.codehaus.groovy:groovy-all:2.4.10' testCompile 'cglib:cglib-nodep:2.2' testCompile 'org.objenesis:objenesis:2.1' testCompile project(':accurest-testing-utils') diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 91aa685d..60d2f0cb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Tue Apr 12 23:29:55 EDT 2016 +#Thu Jul 06 12:13:23 CEST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.5.1-bin.zip diff --git a/stub-runner/stub-runner/build.gradle b/stub-runner/stub-runner/build.gradle index c633e222..858e21c1 100644 --- a/stub-runner/stub-runner/build.gradle +++ b/stub-runner/stub-runner/build.gradle @@ -6,7 +6,7 @@ mainClassName = 'io.codearte.accurest.stubrunner.StubRunnerMain' dependencies { compile project(':accurest-core') compile project(':accurest-messaging-root:accurest-messaging-core') - compile 'org.codehaus.groovy:groovy-all:2.4.4' + compile 'org.codehaus.groovy:groovy-all:2.4.10' compile "com.github.tomakehurst:wiremock:$wiremockVersion" compile 'javax.servlet:javax.servlet-api:3.1.0' compile 'args4j:args4j:2.32' From 105416ef48fd2a887b495497da2411be89567ef6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 6 Jul 2017 14:32:25 +0200 Subject: [PATCH 02/15] Make client stubs generation task in Gradle cacheable --- .../plugin/GenerateWireMockClientStubsFromDslTask.groovy | 2 ++ 1 file changed, 2 insertions(+) diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy index 3a7825fb..eec9cb52 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy @@ -4,11 +4,13 @@ import io.codearte.accurest.config.AccurestConfigProperties import io.codearte.accurest.wiremock.DslToWireMockClientConverter import io.codearte.accurest.wiremock.RecursiveFilesConverter import org.gradle.api.internal.ConventionTask +import org.gradle.api.tasks.CacheableTask import org.gradle.api.tasks.InputDirectory import org.gradle.api.tasks.OutputDirectory import org.gradle.api.tasks.TaskAction //TODO: Implement as an incremental task: https://gradle.org/docs/current/userguide/custom_tasks.html#incremental_tasks ? +@CacheableTask class GenerateWireMockClientStubsFromDslTask extends ConventionTask { @InputDirectory From 761e3cabef1716033b636f7e9c294b3db0e1b8d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 6 Jul 2017 15:24:55 +0200 Subject: [PATCH 03/15] Fix test with new Groovy --- .../accurest/dsl/WireMockGroovyDslSpec.groovy | 2 +- .../util/JsonToJsonPathsConverterSpec.groovy | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy index 2b5157a3..2c5dc94a 100755 --- a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy @@ -191,7 +191,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie }, "response" : { "status" : 200, - "body" : "{\\"created\\":\\"2014-02-02 12:23:43\\",\\"id\\":\\"123\\",\\"name\\":\\"Jan\\",\\"surname\\":\\"Kowalsky\\"}", + "body" : "{\\"id\\":\\"123\\",\\"surname\\":\\"Kowalsky\\",\\"name\\":\\"Jan\\",\\"created\\":\\"2014-02-02 12:23:43\\"}", "headers" : { "Content-Type" : "text/plain" } diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/util/JsonToJsonPathsConverterSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/util/JsonToJsonPathsConverterSpec.groovy index 5cfdfab4..e2dffd12 100644 --- a/accurest-core/src/test/groovy/io/codearte/accurest/util/JsonToJsonPathsConverterSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/util/JsonToJsonPathsConverterSpec.groovy @@ -180,16 +180,16 @@ class JsonToJsonPathsConverterSpec extends Specification { JsonPaths pathAndValues = JsonToJsonPathsConverter.transformToJsonPathWithTestsSideValues(new JsonSlurper().parseText(json)) then: pathAndValues.find { - it.method() == """.field("extensions").field("7").isEqualTo(28)""" && - it.jsonPath() == '''$.extensions[?(@.7 == 28)]''' + it.method() == """.field("extensions").field("7").isEqualTo(28.00)""" && + it.jsonPath() == '''$.extensions[?(@.7 == 28.00)]''' } pathAndValues.find { - it.method() == """.field("extensions").field("14").isEqualTo(41)""" && - it.jsonPath() == '''$.extensions[?(@.14 == 41)]''' + it.method() == """.field("extensions").field("14").isEqualTo(41.00)""" && + it.jsonPath() == '''$.extensions[?(@.14 == 41.00)]''' } pathAndValues.find { - it.method() == """.field("extensions").field("30").isEqualTo(60)""" && - it.jsonPath() == '''$.extensions[?(@.30 == 60)]''' + it.method() == """.field("extensions").field("30").isEqualTo(60.00)""" && + it.jsonPath() == '''$.extensions[?(@.30 == 60.00)]''' } and: assertThatJsonPathsInMapAreValid(json, pathAndValues) From aac930b524afc4bb320619fa89e5e80e2180bf5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 6 Jul 2017 16:13:12 +0200 Subject: [PATCH 04/15] Fix static compilation issues with Groovy 2.4.10 --- .../io/codearte/accurest/stubrunner/StubRepository.groovy | 4 ++-- .../io/codearte/accurest/stubrunner/StubRunnerExecutor.groovy | 2 +- .../accurest/stubrunner/StubRunnerOptionsBuilder.groovy | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRepository.groovy b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRepository.groovy index 78527dbd..791d92d2 100644 --- a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRepository.groovy +++ b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRepository.groovy @@ -45,7 +45,7 @@ class StubRepository { } private List contextDescriptors() { - return path.exists() ? collectMappingDescriptors(path) : [] + return path.exists() ? collectMappingDescriptors(path) : [] as List } private List collectMappingDescriptors(File descriptorsDirectory) { @@ -59,7 +59,7 @@ class StubRepository { } private Collection accurestDescriptors() { - return path.exists() ? collectAccurestDescriptors(path) : [] + return path.exists() ? collectAccurestDescriptors(path) : [] as Collection } private Collection collectAccurestDescriptors(File descriptorsDirectory) { diff --git a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerExecutor.groovy b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerExecutor.groovy index 2852327f..08a7a5f4 100644 --- a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerExecutor.groovy +++ b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerExecutor.groovy @@ -104,7 +104,7 @@ class StubRunnerExecutor implements StubFinder { Map> labels() { return getAccurestContracts().collectEntries { [(it.key.toColonSeparatedDependencyNotation()) : it.value.collect { it.label }] - } as Map> + } as Map> } private void sendMessageIfApplicable(GroovyDsl groovyDsl) { diff --git a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerOptionsBuilder.groovy b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerOptionsBuilder.groovy index 903b21c7..826b016b 100644 --- a/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerOptionsBuilder.groovy +++ b/stub-runner/stub-runner/src/main/groovy/io/codearte/accurest/stubrunner/StubRunnerOptionsBuilder.groovy @@ -90,7 +90,7 @@ class StubRunnerOptionsBuilder { } private static List stubsToList(String stubIdsToPortMapping) { - return stubIdsToPortMapping.split(',').collect { it } + return stubIdsToPortMapping.split(',').toList() } private void addStub(List notations) { From 54e41b227815e43c367dded48f70f5975895d564 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 6 Jul 2017 16:13:33 +0200 Subject: [PATCH 05/15] Fix compatibility with Gradle 3 --- .../io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy index 779d156b..80d90892 100644 --- a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy +++ b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/AccurestIntegrationSpec.groovy @@ -67,7 +67,7 @@ abstract class AccurestIntegrationSpec extends Specification { protected void runTasksSuccessfully(String... tasks) { BuildResult result = run(tasks) result.tasks.each { - assert it.outcome == TaskOutcome.SUCCESS || it.outcome == TaskOutcome.UP_TO_DATE + assert it.outcome == TaskOutcome.SUCCESS || it.outcome == TaskOutcome.UP_TO_DATE || it.outcome == TaskOutcome.NO_SOURCE } } From e0572e282d7230ffef7c34395b07ee5d47d85a50 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 6 Jul 2017 16:31:10 +0200 Subject: [PATCH 06/15] Fix compatibility with Gradle 3 in functional tests --- .../sampleJerseyProject/build.gradle | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle index 3e3e1075..a33308b1 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle @@ -4,7 +4,7 @@ buildscript { mavenCentral() } dependencies { - classpath "org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE" + classpath "org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE" } } @@ -12,8 +12,8 @@ group = 'io.codearte.accurest.testprojects' ext { restAssuredVersion = '2.5.0' - spockVersion = '1.0-groovy-2.4' - wiremockVersion = '2.0.10-beta' + spockVersion = '1.1-groovy-2.4' + wiremockVersion = '2.1.7' accurestStubsBaseDirectory = 'src/test/resources/stubs' } @@ -45,6 +45,7 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService') wireMockStubsOutputDir = file(new File(stubsOutputDirRoot, 'repository/mappings/')) contractsOutputDir = file(new File(stubsOutputDirRoot, 'repository/accurest/')) } + ext['jetty.version'] = '9.2.17.v20160517' accurest { targetFramework = 'Spock' @@ -64,14 +65,23 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService') } dependencies { - compile 'org.glassfish.jersey.containers:jersey-container-jetty-http:2.15' + compile('org.glassfish.jersey.containers:jersey-container-jetty-http:2.23.2') { + exclude group: 'org.eclipse.jetty' + } compile 'org.springframework.boot:spring-boot-starter-jersey' compile 'org.springframework.boot:spring-boot-starter-jetty' testRuntime "org.spockframework:spock-spring:$spockVersion" - compile 'org.glassfish.jersey.connectors:jersey-apache-connector:2.15' - testCompile 'org.springframework:spring-test' + compile('org.glassfish.jersey.connectors:jersey-apache-connector:2.23.2') { + exclude group: 'org.eclipse.jetty' + } + testCompile "org.mockito:mockito-core" + testCompile "org.springframework:spring-test" + testCompile "org.springframework.boot:spring-boot-test" + testCompile("com.github.tomakehurst:wiremock:2.1.7") { + exclude group: 'org.eclipse.jetty' + } } task cleanup(type: Delete) { From 294674b078cd8b8545c79f6f03bc2a72ca9f7047 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 6 Jul 2017 18:20:43 +0200 Subject: [PATCH 07/15] Adjust functional tests to Gradle 3 --- .../functionalTest/bootSimple/build.gradle | 4 ++-- .../functionalTest/bootSimple/gradle.properties | 4 ++-- .../functionalTest/messagingProject/build.gradle | 3 ++- .../sampleJerseyProject/build.gradle | 2 +- .../LoanApplicationServiceSpec.groovy | 4 ++-- .../functionalTest/sampleProject/build.gradle | 14 ++++++++++---- .../shouldMarkClientAsFraud.groovy | 2 +- .../shouldMarkClientAsNotFraud.groovy | 2 +- .../LoanApplicationServiceSpec.groovy | 4 ++-- .../functionalTest/scenarioProject/build.gradle | 13 +++++++++---- .../1_shouldMarkClientAsNotFraud.groovy | 2 +- .../2_shouldMarkClientAsFraud.groovy | 4 ++-- .../LoanApplicationServiceSpec.groovy | 4 ++-- build.gradle | 2 +- .../messaging/camel/CamelStubRunnerSpec.groovy | 9 ++++++--- .../stub-runner-messaging-stream/build.gradle | 1 + 16 files changed, 45 insertions(+), 29 deletions(-) diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle index 602bb14c..9825f1c2 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/build.gradle @@ -39,11 +39,11 @@ repositories { dependencies { compile "org.springframework:spring-web:$springVersion" compile "org.springframework:spring-context-support:$springVersion" - compile "org.codehaus.groovy:groovy-all:2.4.5" + compile "org.codehaus.groovy:groovy-all:2.4.10" compile 'com.jayway.jsonpath:json-path-assert:2.2.0' testCompile "com.github.tomakehurst:wiremock:2.0.10-beta" - testCompile "org.spockframework:spock-spring:1.0-groovy-2.4" + testCompile "org.spockframework:spock-spring:1.1-groovy-2.4" testCompile "com.jayway.restassured:rest-assured:$restAssuredVersion" testCompile "com.jayway.restassured:spring-mock-mvc:$restAssuredVersion" testCompile "ch.qos.logback:logback-classic:1.1.2" diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/gradle.properties b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/gradle.properties index 03c9b16b..c7ed974c 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/gradle.properties +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/bootSimple/gradle.properties @@ -1,6 +1,6 @@ groupId=com.ofg jacksonMapper=1.9.13 restAssuredVersion=2.4.0 -springVersion=4.1.7.RELEASE +springVersion=4.3.9.RELEASE -springBootVersion=1.3.3.RELEASE \ No newline at end of file +springBootVersion=1.4.7.RELEASE \ No newline at end of file diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle index 8b476c92..d6f54720 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle @@ -45,7 +45,7 @@ repositories { } dependencies { - compile "org.codehaus.groovy:groovy-all:2.4.5" + compile "org.codehaus.groovy:groovy-all:2.4.10" compile "org.springframework.boot:spring-boot-starter-web:${springBootVersion}" compile "org.springframework.boot:spring-boot-starter-actuator:${springBootVersion}" compile "org.springframework.boot:spring-boot-starter-integration:${springBootVersion}" @@ -54,6 +54,7 @@ dependencies { testCompile "org.spockframework:spock-spring:1.0-groovy-2.4" testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" +// testCompile "org.springframework.boot:spring-boot-test" testCompile "ch.qos.logback:logback-classic:1.1.2" testCompile 'com.jayway.restassured:spring-mock-mvc:2.9.0' // needed if you're going to use Spring MockMvc } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle index a33308b1..6973342e 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/build.gradle @@ -27,7 +27,7 @@ subprojects { } dependencies { - testCompile 'org.codehaus.groovy:groovy-all:2.4.5' + testCompile 'org.codehaus.groovy:groovy-all:2.4.10' testCompile "org.spockframework:spock-core:$spockVersion" testCompile 'junit:junit:4.12' testCompile "com.github.tomakehurst:wiremock:$wiremockVersion" diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy index 21ee7a4d..f7a60a80 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleJerseyProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy @@ -9,12 +9,12 @@ import com.blogspot.toomuchcoding.frauddetection.model.LoanApplicationStatus import com.github.tomakehurst.wiremock.junit.WireMockClassRule import org.junit.ClassRule import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootContextLoader import org.springframework.test.context.ContextConfiguration import spock.lang.Shared import spock.lang.Specification -@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application) +@ContextConfiguration(loader = SpringBootContextLoader, classes = Application) class LoanApplicationServiceSpec extends Specification { public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort() diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle index 606fc7ba..03423683 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle @@ -4,17 +4,18 @@ buildscript { mavenLocal() } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE") + classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE") } } ext { restAssuredVersion = '2.5.0' spockVersion = '1.0-groovy-2.4' - wiremockVersion = '2.0.10-beta' + wiremockVersion = '2.1.7' accurestStubsBaseDirectory = 'src/test/resources/stubs' } +ext['jetty.version'] = '9.2.17.v20160517' group = 'io.codearte.accurest.testprojects' @@ -27,10 +28,13 @@ subprojects { } dependencies { - testCompile "org.codehaus.groovy:groovy-all:2.4.5" + testCompile "org.codehaus.groovy:groovy-all:2.4.10" testCompile "org.spockframework:spock-core:$spockVersion" testCompile("junit:junit:4.12") - testCompile "com.github.tomakehurst:wiremock:$wiremockVersion" + testCompile("com.github.tomakehurst:wiremock:$wiremockVersion") { + exclude group: 'org.eclipse.jetty' + } + } } @@ -67,7 +71,9 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService') compile("org.springframework.boot:spring-boot-starter-actuator") testRuntime "org.spockframework:spock-spring:$spockVersion" + 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" } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy index 44b1c086..42ccdab3 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsFraud.groovy @@ -20,7 +20,7 @@ io.codearte.accurest.dsl.GroovyDsl.make { "rejectionReason": "Amount too high" }""") headers { - header('Content-Type': 'application/vnd.fraud.v1+json') + header('Content-Type': 'application/vnd.fraud.v1+json;charset=UTF-8') } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy index 7bc64d0d..69bd67d7 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/fraudDetectionService/mappings/fraudDetectionService/shouldMarkClientAsNotFraud.groovy @@ -21,7 +21,7 @@ io.codearte.accurest.dsl.GroovyDsl.make { rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)'))) ) headers { - header('Content-Type': 'application/vnd.fraud.v1+json') + header('Content-Type': 'application/vnd.fraud.v1+json;charset=UTF-8') } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy index 21ee7a4d..f7a60a80 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy @@ -9,12 +9,12 @@ import com.blogspot.toomuchcoding.frauddetection.model.LoanApplicationStatus import com.github.tomakehurst.wiremock.junit.WireMockClassRule import org.junit.ClassRule import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootContextLoader import org.springframework.test.context.ContextConfiguration import spock.lang.Shared import spock.lang.Specification -@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application) +@ContextConfiguration(loader = SpringBootContextLoader, classes = Application) class LoanApplicationServiceSpec extends Specification { public static int port = org.springframework.util.SocketUtils.findAvailableTcpPort() diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/build.gradle index 6b72e88a..7a1ca899 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/build.gradle @@ -4,17 +4,18 @@ buildscript { mavenLocal() } dependencies { - classpath("org.springframework.boot:spring-boot-gradle-plugin:1.2.6.RELEASE") + classpath("org.springframework.boot:spring-boot-gradle-plugin:1.4.0.RELEASE") } } ext { restAssuredVersion = '2.5.0' spockVersion = '1.0-groovy-2.4' - wiremockVersion = '2.0.10-beta' + wiremockVersion = '2.1.7' accurestStubsBaseDirectory = 'src/test/resources/stubs' } +ext['jetty.version'] = '9.2.17.v20160517' group = 'io.codearte.accurest.testprojects' @@ -28,10 +29,12 @@ subprojects { } dependencies { - testCompile "org.codehaus.groovy:groovy-all:2.4.5" + testCompile "org.codehaus.groovy:groovy-all:2.4.10" testCompile "org.spockframework:spock-core:$spockVersion" testCompile("junit:junit:4.12") - testCompile "com.github.tomakehurst:wiremock:$wiremockVersion" + testCompile("com.github.tomakehurst:wiremock:$wiremockVersion") { + exclude group: 'org.eclipse.jetty' + } } } @@ -96,7 +99,9 @@ configure([project(':fraudDetectionService'), project(':loanApplicationService') compile("org.springframework.boot:spring-boot-starter-actuator") testRuntime "org.spockframework:spock-spring:$spockVersion" + 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" } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/1_shouldMarkClientAsNotFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/1_shouldMarkClientAsNotFraud.groovy index 7bc64d0d..7557fb33 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/1_shouldMarkClientAsNotFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/1_shouldMarkClientAsNotFraud.groovy @@ -21,7 +21,7 @@ io.codearte.accurest.dsl.GroovyDsl.make { rejectionReason: $(client(null), server(execute('assertThatRejectionReasonIsNull($it)'))) ) headers { - header('Content-Type': 'application/vnd.fraud.v1+json') + header('Content-Type': 'application/vnd.fraud.v1+json;charset=UTF-8') } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/2_shouldMarkClientAsFraud.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/2_shouldMarkClientAsFraud.groovy index 44b1c086..4272dd8a 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/2_shouldMarkClientAsFraud.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/fraudDetectionService/mappings/fraudDetectionService/2_shouldMarkClientAsFraud.groovy @@ -20,8 +20,8 @@ io.codearte.accurest.dsl.GroovyDsl.make { "rejectionReason": "Amount too high" }""") headers { - header('Content-Type': 'application/vnd.fraud.v1+json') - } + header('Content-Type': 'application/vnd.fraud.v1+json;charset=UTF-8') + } } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy index 5a7d0ae9..14133d63 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/scenarioProject/loanApplicationService/src/test/groovy/com/blogspot/toomuchcoding/LoanApplicationServiceSpec.groovy @@ -9,13 +9,13 @@ import com.blogspot.toomuchcoding.frauddetection.model.LoanApplicationStatus import com.github.tomakehurst.wiremock.junit.WireMockClassRule import org.junit.ClassRule import org.springframework.beans.factory.annotation.Autowired -import org.springframework.boot.test.SpringApplicationContextLoader +import org.springframework.boot.test.context.SpringBootContextLoader import org.springframework.test.context.ContextConfiguration import spock.lang.Shared import spock.lang.Specification import spock.lang.Stepwise -@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Application) +@ContextConfiguration(loader = SpringBootContextLoader, classes = Application) @Stepwise class LoanApplicationServiceSpec extends Specification { diff --git a/build.gradle b/build.gradle index 036333de..26fec613 100644 --- a/build.gradle +++ b/build.gradle @@ -150,7 +150,7 @@ project(':accurest-gradle-plugin') { messagingLibs project(':accurest-messaging-root:accurest-messaging-integration') messagingLibs project(':accurest-messaging-root:accurest-messaging-core') messagingLibs project(':accurest-testing-utils') - messagingLibs 'org.codehaus.groovy:groovy-all:2.4.5' + messagingLibs 'org.codehaus.groovy:groovy-all:2.4.10' accurestGradlePluginLibs project(':accurest-gradle-plugin') } diff --git a/stub-runner/stub-runner-messaging/stub-runner-messaging-camel/src/test/groovy/io/codearte/accurest/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy b/stub-runner/stub-runner-messaging/stub-runner-messaging-camel/src/test/groovy/io/codearte/accurest/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy index 28e80533..34e6c4fb 100644 --- a/stub-runner/stub-runner-messaging/stub-runner-messaging-camel/src/test/groovy/io/codearte/accurest/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy +++ b/stub-runner/stub-runner-messaging/stub-runner-messaging-camel/src/test/groovy/io/codearte/accurest/stubrunner/messaging/camel/CamelStubRunnerSpec.groovy @@ -145,9 +145,12 @@ class CamelStubRunnerSpec extends Specification { return json.bookName == 'foo' } - @Bean - ActiveMQComponent activeMQComponent(@Value('${activemq.url:vm://localhost?broker.persistent=false}') String url) { - return new ActiveMQComponent(brokerURL: url) + @Configuration + private static class AvtiveMQConfiguration { + @Bean + ActiveMQComponent activeMQComponent(@Value('${activemq.url:vm://localhost?broker.persistent=false}') String url) { + return new ActiveMQComponent(brokerURL: url) + } } GroovyDsl dsl = diff --git a/stub-runner/stub-runner-messaging/stub-runner-messaging-stream/build.gradle b/stub-runner/stub-runner-messaging/stub-runner-messaging-stream/build.gradle index b03e790e..b21ab1db 100644 --- a/stub-runner/stub-runner-messaging/stub-runner-messaging-stream/build.gradle +++ b/stub-runner/stub-runner-messaging/stub-runner-messaging-stream/build.gradle @@ -16,6 +16,7 @@ dependencies { testCompile "org.springframework:spring-context:${springVersion}" testCompile "org.springframework:spring-beans:${springVersion}" + testCompile "org.springframework:spring-web:${springVersion}" testCompile "org.springframework.cloud:spring-cloud-stream-test-support:${springStreamVersion}" testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" testCompile('org.spockframework:spock-spring:1.0-groovy-2.4') { From 3aa1b20098ab82502628b813fdb9c0490ad6ec17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Fri, 7 Jul 2017 11:50:37 +0200 Subject: [PATCH 08/15] Try to fix issue with missing Java 7 --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 599d7dc7..c5fbf7c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,7 @@ language: java sudo: required dist: trusty +group: deprecated-2017Q2 before_install: - "export JAVA_OPTS='-Xmx1024m -XX:MaxPermSize=256m'" From 231dca7a83818d7361789c593d21cc64f66789bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Fri, 7 Jul 2017 13:27:48 +0200 Subject: [PATCH 09/15] Enhance input/output awareness in Gradle tasks Make tasks cacheable. --- .../plugin/AccurestGradlePlugin.groovy | 14 +-- .../plugin/GenerateServerTestsTask.groovy | 16 ++- ...erateWireMockClientStubsFromDslTask.groovy | 15 +-- .../AccurestGradleConfigProperties.groovy | 101 ++++++++++++++++++ 4 files changed, 117 insertions(+), 29 deletions(-) create mode 100644 accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGradleConfigProperties.groovy diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy index 658f63bb..afe5eb3c 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy @@ -1,6 +1,6 @@ package io.codearte.accurest.plugin -import io.codearte.accurest.config.AccurestConfigProperties +import io.codearte.accurest.plugin.config.AccurestGradleConfigProperties import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task @@ -20,7 +20,7 @@ class AccurestGradlePlugin implements Plugin { @Override void apply(Project project) { this.project = project - AccurestConfigProperties extension = project.extensions.create('accurest', AccurestConfigProperties) + AccurestGradleConfigProperties extension = project.extensions.create('accurest', AccurestGradleConfigProperties) project.check.dependsOn(GENERATE_SERVER_TESTS_TASK_NAME) @@ -45,7 +45,7 @@ class AccurestGradlePlugin implements Plugin { } } - void setConfigurationDefaults(AccurestConfigProperties extension) { + void setConfigurationDefaults(AccurestGradleConfigProperties extension) { extension.with { generatedTestSourcesDir = project.file("${project.buildDir}/generated-test-sources/accurest") contractsDslDir = defaultAccurestContractsDir() //TODO: Use sourceset @@ -57,24 +57,20 @@ class AccurestGradlePlugin implements Plugin { project.file("${project.rootDir}/src/test/resources/accurest") } - private void createGenerateTestsTask(AccurestConfigProperties extension) { + private void createGenerateTestsTask(AccurestGradleConfigProperties extension) { Task task = project.tasks.create(GENERATE_SERVER_TESTS_TASK_NAME, GenerateServerTestsTask) task.description = "Generate server tests from GroovyDSL" task.group = GROUP_NAME task.conventionMapping.with { - contractsDslDir = { extension.contractsDslDir } - generatedTestSourcesDir = { extension.generatedTestSourcesDir } configProperties = { extension } } } - private void createAndConfigureGenerateWireMockClientStubsFromDslTask(AccurestConfigProperties extension) { + private void createAndConfigureGenerateWireMockClientStubsFromDslTask(AccurestGradleConfigProperties extension) { Task task = project.tasks.create(DSL_TO_WIREMOCK_CLIENT_TASK_NAME, GenerateWireMockClientStubsFromDslTask) task.description = "Generate WireMock client stubs from GroovyDSL" task.group = GROUP_NAME task.conventionMapping.with { - contractsDslDir = { extension.contractsDslDir } - stubsOutputDir = { extension.stubsOutputDir } configProperties = { extension } } } diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy index d6fe06a9..a9ed48e9 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy @@ -2,22 +2,18 @@ package io.codearte.accurest.plugin import io.codearte.accurest.AccurestException import io.codearte.accurest.TestGenerator -import io.codearte.accurest.config.AccurestConfigProperties +import io.codearte.accurest.plugin.config.AccurestGradleConfigProperties import org.gradle.api.GradleException import org.gradle.api.internal.ConventionTask -import org.gradle.api.tasks.InputDirectory -import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.CacheableTask +import org.gradle.api.tasks.Nested import org.gradle.api.tasks.TaskAction +@CacheableTask class GenerateServerTestsTask extends ConventionTask { - @InputDirectory - File contractsDslDir - @OutputDirectory - File generatedTestSourcesDir - - //TODO: How to deal with @Input*, @Output* and that domain object? - AccurestConfigProperties configProperties + @Nested + AccurestGradleConfigProperties configProperties @TaskAction void generate() { diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy index eec9cb52..35964c43 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy @@ -1,29 +1,24 @@ package io.codearte.accurest.plugin -import io.codearte.accurest.config.AccurestConfigProperties +import io.codearte.accurest.plugin.config.AccurestGradleConfigProperties import io.codearte.accurest.wiremock.DslToWireMockClientConverter import io.codearte.accurest.wiremock.RecursiveFilesConverter import org.gradle.api.internal.ConventionTask import org.gradle.api.tasks.CacheableTask -import org.gradle.api.tasks.InputDirectory -import org.gradle.api.tasks.OutputDirectory +import org.gradle.api.tasks.Nested import org.gradle.api.tasks.TaskAction //TODO: Implement as an incremental task: https://gradle.org/docs/current/userguide/custom_tasks.html#incremental_tasks ? @CacheableTask class GenerateWireMockClientStubsFromDslTask extends ConventionTask { - @InputDirectory - File contractsDslDir - @OutputDirectory - File stubsOutputDir - - AccurestConfigProperties configProperties + @Nested + AccurestGradleConfigProperties configProperties @TaskAction void generate() { logger.info("Accurest Plugin: Invoking GroovyDSL to WireMock client stubs conversion") - logger.debug("From '${getContractsDslDir()}' to '${getStubsOutputDir()}'") + logger.debug("From '${getConfigProperties().getContractsDslDir()}' to '${getConfigProperties().getStubsOutputDir()}'") RecursiveFilesConverter converter = new RecursiveFilesConverter(new DslToWireMockClientConverter(), getConfigProperties()) converter.processFiles() } diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGradleConfigProperties.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGradleConfigProperties.groovy new file mode 100644 index 00000000..ac024087 --- /dev/null +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGradleConfigProperties.groovy @@ -0,0 +1,101 @@ +package io.codearte.accurest.plugin.config + +import groovy.transform.CompileStatic +import io.codearte.accurest.config.AccurestConfigProperties +import io.codearte.accurest.config.TestFramework +import io.codearte.accurest.config.TestMode +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.Optional +import org.gradle.api.tasks.OutputDirectory + +@CompileStatic +class AccurestGradleConfigProperties extends AccurestConfigProperties { + + @Override + @Input + TestFramework getTargetFramework() { + return super.getTargetFramework() + } + + @Override + @Input + TestMode getTestMode() { + return super.getTestMode() + } + + @Override + @Input + String getBasePackageForTests() { + return super.getBasePackageForTests() + } + + @Override + @Input + @Optional + String getBaseClassForTests() { + return super.getBaseClassForTests() + } + + @Override + @Input + @Optional + String getNameSuffixForTests() { + return super.getNameSuffixForTests() + } + + @Override + @Input + @Optional + String getRuleClassForTests() { + return super.getRuleClassForTests() + } + + @Override + @Input + String getJsonAssertVersion() { + return super.getJsonAssertVersion() + } + + @Override + @Input + List getExcludedFiles() { + return super.getExcludedFiles() + } + + @Override + @Input + List getIgnoredFiles() { + return super.getIgnoredFiles() + } + + @Override + @Input + String[] getImports() { + return super.getImports() + } + + @Override + @Input + String[] getStaticImports() { + return super.getStaticImports() + } + + @Override + @InputDirectory + File getContractsDslDir() { + return super.getContractsDslDir() + } + + @Override + @OutputDirectory + File getGeneratedTestSourcesDir() { + return super.getGeneratedTestSourcesDir() + } + + @Override + @OutputDirectory + File getStubsOutputDir() { + return super.getStubsOutputDir() + } +} From f31398de579e15a45326518a13a0a48cefa0f027 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Fri, 7 Jul 2017 13:44:47 +0200 Subject: [PATCH 10/15] Fix functional test --- .../io/codearte/accurest/plugin/BasicFunctionalSpec.groovy | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy index 015825cc..93d0c52c 100755 --- a/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy +++ b/accurest-gradle-plugin/src/test/groovy/io/codearte/accurest/plugin/BasicFunctionalSpec.groovy @@ -12,7 +12,7 @@ class BasicFunctionalSpec extends AccurestIntegrationSpec { private static final String GENERATED_TEST = "build//generated-test-sources//accurest//accurest//com//ofg//twitter_places_analyzer//PairIdSpec.groovy" private static final String GENERATED_CLIENT_JSON_STUB = "build//production//bootSimple-stubs//repository//mappings//com//ofg//twitter-places-analyzer//pairId//collerate_PlacesFrom_Tweet.json" private static final String GROOVY_DSL_CONTRACT = "repository//mappings//com//ofg//twitter-places-analyzer//pairId//collerate_PlacesFrom_Tweet.groovy" - private static final String TEST_EXECUTION_XML_REPORT = "build/test-results/TEST-accurest.com.ofg.twitter_places_analyzer.PairIdSpec.xml" + private static final String TEST_EXECUTION_XML_REPORT = "build/test-results/test/TEST-accurest.com.ofg.twitter_places_analyzer.PairIdSpec.xml" def setup() { setupForProject("functionalTest/bootSimple") From 4e2ea84ce4dbbe1ac9caf92d9f42ab961a07d109 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Fri, 7 Jul 2017 13:47:29 +0200 Subject: [PATCH 11/15] Upgrade Axion to version compatible with Gradle 3 --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 26fec613..daed1104 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { if (project.hasProperty('fatJar')) jcenter() } dependencies { - classpath "pl.allegro.tech.build:axion-release-plugin:1.3.2" + classpath "pl.allegro.tech.build:axion-release-plugin:1.4.1" classpath "com.bmuschko:gradle-nexus-plugin:2.3" classpath "io.codearte.gradle.nexus:gradle-nexus-staging-plugin:0.5.3" if (project.hasProperty('fatJar')) classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.3' From 1c8ff14a713bfbf7b4c7ef7600a2a12ea7f7e120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Fri, 7 Jul 2017 14:02:44 +0200 Subject: [PATCH 12/15] Restore original assertion in test --- .../io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy index 2c5dc94a..c8fbf47d 100755 --- a/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy +++ b/accurest-core/src/test/groovy/io/codearte/accurest/dsl/WireMockGroovyDslSpec.groovy @@ -183,6 +183,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie when: String wireMockStub = new WireMockStubStrategy("Test", new Contract(null, false, 0, null), groovyDsl).toWireMockClientStub() then: + //TODO: That assertion fails on some environments due to 2 ways how body array is created - with 'created' at the beginning or 'id' AssertionUtil.assertThatJsonsAreEqual((''' { "request" : { @@ -191,7 +192,7 @@ class WireMockGroovyDslSpec extends Specification implements WireMockStubVerifie }, "response" : { "status" : 200, - "body" : "{\\"id\\":\\"123\\",\\"surname\\":\\"Kowalsky\\",\\"name\\":\\"Jan\\",\\"created\\":\\"2014-02-02 12:23:43\\"}", + "body" : "{\\"created\\":\\"2014-02-02 12:23:43\\",\\"id\\":\\"123\\",\\"name\\":\\"Jan\\",\\"surname\\":\\"Kowalsky\\"}", "headers" : { "Content-Type" : "text/plain" } From c738c79b5cec2cb38d3e93dce274be618f0cc865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Fri, 7 Jul 2017 15:04:14 +0200 Subject: [PATCH 13/15] Remove redundant comment --- .../test/resources/functionalTest/messagingProject/build.gradle | 1 - 1 file changed, 1 deletion(-) diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle index d6f54720..52f14661 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/messagingProject/build.gradle @@ -54,7 +54,6 @@ dependencies { testCompile "org.spockframework:spock-spring:1.0-groovy-2.4" testCompile "org.springframework.boot:spring-boot-starter-test:${springBootVersion}" -// testCompile "org.springframework.boot:spring-boot-test" testCompile "ch.qos.logback:logback-classic:1.1.2" testCompile 'com.jayway.restassured:spring-mock-mvc:2.9.0' // needed if you're going to use Spring MockMvc } From d368ba7111f288ea27e15b1fc0eb94c2e9ce283c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Fri, 7 Jul 2017 15:27:29 +0200 Subject: [PATCH 14/15] Fix issue wit missing Travis job --- .travis.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index c5fbf7c9..8bc50682 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,14 +9,12 @@ before_install: - "mkdir $HOME/.m2/repository/io/codearte/accurest/ --parents" - "cp -r stub-runner/stub-runner-spring/src/test/resources/m2repo/repository/io/codearte/accurest/stubs $HOME/.m2/repository/io/codearte/accurest/" -jdk: - - oraclejdk8 - install: ./gradlew assemble -s script: ./gradlew check funcTest install -s --continue && jdk_switcher use oraclejdk8 && ./scripts/runTests.sh && jdk_switcher use $TRAVIS_JDK_VERSION && ./gradlew uploadSnapshotArchives -x check -s matrix: include: + - jdk: oraclejdk8 # Automatic snapshot release only in Java 7 build - jdk: oraclejdk7 env: From df81fa95607103b15f9f08de7cfefdd36aa02097 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Zaj=C4=85czkowski?= Date: Thu, 13 Jul 2017 15:54:26 +0200 Subject: [PATCH 15/15] Hack to eliminate overlapping output in tasks --- .../plugin/AccurestGradlePlugin.groovy | 16 ++++---- .../plugin/GenerateServerTestsTask.groovy | 4 +- ...erateWireMockClientStubsFromDslTask.groovy | 4 +- ...restClientStubsTaskConfigProperties.groovy | 41 +++++++++++++++++++ ...curestGenericGradleConfigProperties.groovy | 26 ++++++++++++ ...estServerTestsTaskConfigProperties.groovy} | 12 +++--- .../functionalTest/sampleProject/build.gradle | 1 - 7 files changed, 86 insertions(+), 18 deletions(-) create mode 100644 accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestClientStubsTaskConfigProperties.groovy create mode 100644 accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGenericGradleConfigProperties.groovy rename accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/{AccurestGradleConfigProperties.groovy => AccurestServerTestsTaskConfigProperties.groovy} (82%) diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy index afe5eb3c..12aca9eb 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/AccurestGradlePlugin.groovy @@ -1,6 +1,8 @@ package io.codearte.accurest.plugin -import io.codearte.accurest.plugin.config.AccurestGradleConfigProperties +import io.codearte.accurest.plugin.config.AccurestClientStubsTaskConfigProperties +import io.codearte.accurest.plugin.config.AccurestGenericGradleConfigProperties +import io.codearte.accurest.plugin.config.AccurestServerTestsTaskConfigProperties import org.gradle.api.Plugin import org.gradle.api.Project import org.gradle.api.Task @@ -20,7 +22,7 @@ class AccurestGradlePlugin implements Plugin { @Override void apply(Project project) { this.project = project - AccurestGradleConfigProperties extension = project.extensions.create('accurest', AccurestGradleConfigProperties) + AccurestGenericGradleConfigProperties extension = project.extensions.create('accurest', AccurestGenericGradleConfigProperties) project.check.dependsOn(GENERATE_SERVER_TESTS_TASK_NAME) @@ -45,7 +47,7 @@ class AccurestGradlePlugin implements Plugin { } } - void setConfigurationDefaults(AccurestGradleConfigProperties extension) { + void setConfigurationDefaults(AccurestGenericGradleConfigProperties extension) { extension.with { generatedTestSourcesDir = project.file("${project.buildDir}/generated-test-sources/accurest") contractsDslDir = defaultAccurestContractsDir() //TODO: Use sourceset @@ -57,21 +59,21 @@ class AccurestGradlePlugin implements Plugin { project.file("${project.rootDir}/src/test/resources/accurest") } - private void createGenerateTestsTask(AccurestGradleConfigProperties extension) { + private void createGenerateTestsTask(AccurestGenericGradleConfigProperties extension) { Task task = project.tasks.create(GENERATE_SERVER_TESTS_TASK_NAME, GenerateServerTestsTask) task.description = "Generate server tests from GroovyDSL" task.group = GROUP_NAME task.conventionMapping.with { - configProperties = { extension } + configProperties = { AccurestServerTestsTaskConfigProperties.fromGenericConfig(extension) } } } - private void createAndConfigureGenerateWireMockClientStubsFromDslTask(AccurestGradleConfigProperties extension) { + private void createAndConfigureGenerateWireMockClientStubsFromDslTask(AccurestGenericGradleConfigProperties extension) { Task task = project.tasks.create(DSL_TO_WIREMOCK_CLIENT_TASK_NAME, GenerateWireMockClientStubsFromDslTask) task.description = "Generate WireMock client stubs from GroovyDSL" task.group = GROUP_NAME task.conventionMapping.with { - configProperties = { extension } + configProperties = { AccurestClientStubsTaskConfigProperties.fromGenericConfig(extension) } } } diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy index a9ed48e9..94e33db5 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateServerTestsTask.groovy @@ -2,7 +2,7 @@ package io.codearte.accurest.plugin import io.codearte.accurest.AccurestException import io.codearte.accurest.TestGenerator -import io.codearte.accurest.plugin.config.AccurestGradleConfigProperties +import io.codearte.accurest.plugin.config.AccurestServerTestsTaskConfigProperties import org.gradle.api.GradleException import org.gradle.api.internal.ConventionTask import org.gradle.api.tasks.CacheableTask @@ -13,7 +13,7 @@ import org.gradle.api.tasks.TaskAction class GenerateServerTestsTask extends ConventionTask { @Nested - AccurestGradleConfigProperties configProperties + AccurestServerTestsTaskConfigProperties configProperties @TaskAction void generate() { diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy index 35964c43..c979b740 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/GenerateWireMockClientStubsFromDslTask.groovy @@ -1,6 +1,6 @@ package io.codearte.accurest.plugin -import io.codearte.accurest.plugin.config.AccurestGradleConfigProperties +import io.codearte.accurest.plugin.config.AccurestClientStubsTaskConfigProperties import io.codearte.accurest.wiremock.DslToWireMockClientConverter import io.codearte.accurest.wiremock.RecursiveFilesConverter import org.gradle.api.internal.ConventionTask @@ -13,7 +13,7 @@ import org.gradle.api.tasks.TaskAction class GenerateWireMockClientStubsFromDslTask extends ConventionTask { @Nested - AccurestGradleConfigProperties configProperties + AccurestClientStubsTaskConfigProperties configProperties @TaskAction void generate() { diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestClientStubsTaskConfigProperties.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestClientStubsTaskConfigProperties.groovy new file mode 100644 index 00000000..f2629a30 --- /dev/null +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestClientStubsTaskConfigProperties.groovy @@ -0,0 +1,41 @@ +package io.codearte.accurest.plugin.config + +import groovy.transform.CompileStatic +import org.gradle.api.tasks.Input +import org.gradle.api.tasks.InputDirectory +import org.gradle.api.tasks.OutputDirectory + +@CompileStatic +class AccurestClientStubsTaskConfigProperties extends AccurestGenericGradleConfigProperties { + + @Override + @Input + List getExcludedFiles() { + return super.getExcludedFiles() + } + + @Override + @Input + List getIgnoredFiles() { + return super.getIgnoredFiles() + } + + @Override + @InputDirectory + File getContractsDslDir() { + return super.getContractsDslDir() + } + + @Override + @OutputDirectory + File getStubsOutputDir() { + return super.getStubsOutputDir() + } + + static AccurestClientStubsTaskConfigProperties fromGenericConfig(AccurestGenericGradleConfigProperties configToCloneFrom) { + return new AccurestClientStubsTaskConfigProperties().with { + it.clonePropertiesFrom(configToCloneFrom) + return it + } + } +} diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGenericGradleConfigProperties.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGenericGradleConfigProperties.groovy new file mode 100644 index 00000000..cda76be3 --- /dev/null +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGenericGradleConfigProperties.groovy @@ -0,0 +1,26 @@ +package io.codearte.accurest.plugin.config + +import groovy.transform.CompileStatic +import io.codearte.accurest.config.AccurestConfigProperties + +@CompileStatic +class AccurestGenericGradleConfigProperties extends AccurestConfigProperties { + + protected void clonePropertiesFrom(AccurestGenericGradleConfigProperties configToCloneFrom) { + //shallow copy which is enough to make workaround for overlapping outputs in tasks + targetFramework = configToCloneFrom.targetFramework + testMode = configToCloneFrom.testMode + basePackageForTests = configToCloneFrom.basePackageForTests + baseClassForTests = configToCloneFrom.baseClassForTests + nameSuffixForTests = configToCloneFrom.nameSuffixForTests + ruleClassForTests = configToCloneFrom.ruleClassForTests + jsonAssertVersion = configToCloneFrom.jsonAssertVersion + excludedFiles = configToCloneFrom.excludedFiles + ignoredFiles = configToCloneFrom.ignoredFiles + imports = configToCloneFrom.imports + staticImports = configToCloneFrom.staticImports + contractsDslDir = configToCloneFrom.contractsDslDir + generatedTestSourcesDir = configToCloneFrom.generatedTestSourcesDir + stubsOutputDir = configToCloneFrom.stubsOutputDir + } +} diff --git a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGradleConfigProperties.groovy b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestServerTestsTaskConfigProperties.groovy similarity index 82% rename from accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGradleConfigProperties.groovy rename to accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestServerTestsTaskConfigProperties.groovy index ac024087..15715ed3 100644 --- a/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestGradleConfigProperties.groovy +++ b/accurest-gradle-plugin/src/main/groovy/io/codearte/accurest/plugin/config/AccurestServerTestsTaskConfigProperties.groovy @@ -1,7 +1,6 @@ package io.codearte.accurest.plugin.config import groovy.transform.CompileStatic -import io.codearte.accurest.config.AccurestConfigProperties import io.codearte.accurest.config.TestFramework import io.codearte.accurest.config.TestMode import org.gradle.api.tasks.Input @@ -10,7 +9,7 @@ import org.gradle.api.tasks.Optional import org.gradle.api.tasks.OutputDirectory @CompileStatic -class AccurestGradleConfigProperties extends AccurestConfigProperties { +class AccurestServerTestsTaskConfigProperties extends AccurestGenericGradleConfigProperties { @Override @Input @@ -93,9 +92,10 @@ class AccurestGradleConfigProperties extends AccurestConfigProperties { return super.getGeneratedTestSourcesDir() } - @Override - @OutputDirectory - File getStubsOutputDir() { - return super.getStubsOutputDir() + static AccurestServerTestsTaskConfigProperties fromGenericConfig(AccurestGenericGradleConfigProperties configToCloneFrom) { + return new AccurestServerTestsTaskConfigProperties().with { + it.clonePropertiesFrom(configToCloneFrom) + return it + } } } diff --git a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle index 03423683..b9e5b08c 100644 --- a/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle +++ b/accurest-gradle-plugin/src/test/resources/functionalTest/sampleProject/build.gradle @@ -34,7 +34,6 @@ subprojects { testCompile("com.github.tomakehurst:wiremock:$wiremockVersion") { exclude group: 'org.eclipse.jetty' } - } }