Closed atetzner closed 4 years ago
Spring Dependency management removes the transitive dependencies of rest-assured to org.codehaus.groovy:groovy and org.codehaus.groovy:groovy-xml
That doesn't appear to be the case. Here's the test runtime classpath without dependency management:
testRuntimeClasspath - Runtime classpath of compilation 'test' (target (jvm)).
+--- org.jetbrains.kotlin:kotlin-reflect:1.3.61
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61
| \--- org.jetbrains:annotations:13.0
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61 (*)
| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61 (*)
+--- io.rest-assured:rest-assured:4.1.1
| +--- org.codehaus.groovy:groovy:2.5.6 -> 2.5.8
| +--- org.codehaus.groovy:groovy-xml:2.5.6 -> 2.5.8
| | \--- org.codehaus.groovy:groovy:2.5.8
| +--- org.apache.httpcomponents:httpclient:4.5.3 -> 4.5.10
| | +--- org.apache.httpcomponents:httpcore:4.4.12
| | \--- commons-codec:commons-codec:1.11 -> 1.13
| +--- org.apache.httpcomponents:httpmime:4.5.3 -> 4.5.10
| | \--- org.apache.httpcomponents:httpclient:4.5.10 (*)
| +--- org.hamcrest:hamcrest:2.1
| +--- org.ccil.cowan.tagsoup:tagsoup:1.2.1
| +--- io.rest-assured:json-path:4.1.1 -> 3.3.0
| | +--- org.codehaus.groovy:groovy-json:2.4.15 -> 2.5.8
| | | \--- org.codehaus.groovy:groovy:2.5.8
| | +--- org.codehaus.groovy:groovy:2.4.15 -> 2.5.8
| | \--- io.rest-assured:rest-assured-common:3.3.0
| | +--- org.codehaus.groovy:groovy:2.4.15 -> 2.5.8
| | \--- org.apache.commons:commons-lang3:3.4 -> 3.9
| \--- io.rest-assured:xml-path:4.1.1 -> 3.3.0
| +--- org.codehaus.groovy:groovy-xml:2.4.15 -> 2.5.8 (*)
| +--- org.codehaus.groovy:groovy:2.4.15 -> 2.5.8
| +--- io.rest-assured:rest-assured-common:3.3.0 (*)
| +--- org.apache.commons:commons-lang3:3.4 -> 3.9
| +--- org.ccil.cowan.tagsoup:tagsoup:1.2.1
| +--- javax.xml.bind:jaxb-api:2.2.12 -> 2.3.1
| | \--- javax.activation:javax.activation-api:1.2.0
| +--- com.sun.xml.bind:jaxb-osgi:2.2.10
| \--- org.apache.sling:org.apache.sling.javax.activation:0.1.0
| \--- javax.activation:activation:1.1.1
\--- junit:junit:4.12
\--- org.hamcrest:hamcrest-core:1.3 -> 2.1
\--- org.hamcrest:hamcrest:2.1
And with dependency management:
+--- org.jetbrains.kotlin:kotlin-reflect:1.3.61
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61
| +--- org.jetbrains.kotlin:kotlin-stdlib-common:1.3.61
| \--- org.jetbrains:annotations:13.0
+--- org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.61
| +--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61 (*)
| \--- org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.61
| \--- org.jetbrains.kotlin:kotlin-stdlib:1.3.61 (*)
+--- io.rest-assured:rest-assured:4.1.1
| +--- org.codehaus.groovy:groovy:2.5.6
| +--- org.codehaus.groovy:groovy-xml:2.5.6
| | \--- org.codehaus.groovy:groovy:2.5.6
| +--- org.apache.httpcomponents:httpclient:4.5.3
| | +--- org.apache.httpcomponents:httpcore:4.4.6
| | +--- commons-logging:commons-logging:1.2
| | \--- commons-codec:commons-codec:1.9
| +--- org.apache.httpcomponents:httpmime:4.5.3
| | \--- org.apache.httpcomponents:httpclient:4.5.3 (*)
| +--- org.hamcrest:hamcrest:2.1
| +--- org.ccil.cowan.tagsoup:tagsoup:1.2.1
| +--- io.rest-assured:json-path:4.1.1
| | +--- org.codehaus.groovy:groovy-json:2.5.6
| | | \--- org.codehaus.groovy:groovy:2.5.6
| | +--- org.codehaus.groovy:groovy:2.5.6
| | \--- io.rest-assured:rest-assured-common:4.1.1
| | +--- org.codehaus.groovy:groovy:2.5.6
| | \--- org.apache.commons:commons-lang3:3.4
| \--- io.rest-assured:xml-path:4.1.1
| +--- org.codehaus.groovy:groovy-xml:2.5.6 (*)
| +--- org.codehaus.groovy:groovy:2.5.6
| +--- io.rest-assured:rest-assured-common:4.1.1 (*)
| +--- org.apache.commons:commons-lang3:3.4
| +--- org.ccil.cowan.tagsoup:tagsoup:1.2.1
| +--- javax.xml.bind:jaxb-api:2.3.1
| | \--- javax.activation:javax.activation-api:1.2.0
| +--- com.sun.xml.bind:jaxb-osgi:2.3.0.1
| \--- org.apache.sling:org.apache.sling.javax.activation:0.1.0
| \--- javax.activation:activation:1.1.1
\--- junit:junit:4.12
\--- org.hamcrest:hamcrest-core:1.3
As you can see, the Groovy dependencies are present in each case, just with slightly different versions (2.5.6 vs 2.5.8).
A more notable difference is with io.rest-assured:json-path
where the versions are 4.1.1 and 3.3.0. It's this difference that is causing the problem and is due to Spring Boot's dependency management. Spring Boot 2.2.x uses REST Assured 3.3.x and you are trying to use 4.4.x. The documentation for Spring Boot's Gradle plugin describes how to customise the version of a managed dependency. In this particular case, you need to configure rest-assured.version
to be 4.1.1
:
extra["rest-assured.version"] = "4.1.1"
You'll also need to provide a replacement for Commons Logging which is excluded by Spring Boot's dependency management. Uncommenting the dependency on spring-boot-starter
will accomplish that via spring-jcl
.
Thanks for ponting this out and sorry about the wrong error description. I investigated this problem in my productive project and found out that missing groovy
and groovy-xml
is the problem for this error. After that I built up this demo for the github issue and as the error message has been the same, I assumed the cause to be the same. Obviously this wasn't the case ...
In my productive code, rest-assured is pushed to 4.4.1 although spring dependency management should keep it at 3.3.0 ; this is also the reason for me to use 4.4.1 in this demo. As I didn't specify the rest-assured version anywhere in my code, I assumed spring dependencymanagement to set the version to 4.4.1 , but something other must mess up with my dependencies :(
Thanks for your help @wilkinsona !
Description
Spring Dependency management removes the transitive dependencies of rest-assured to
org.codehaus.groovy:groovy
andorg.codehaus.groovy:groovy-xml
. This causes RestAssured tests to fail at runtime when using e.g. thebody()
method.Steps to reproduce
./gradlew test
the test will run sucessfully.plugins
and thedependencies
block of thebuild.gradle.kts
file and run./gradlew test
again. The test will fail with:Example project files
build.gradle.kts
com.example.demo.RestAssuredTest