Question, possible bug
I've been using v1.2.3.RELEASE for a long time and wrote a lot of contracts in the following manner:
import java.time.LocalDate
def fixedDate = LocalDate.of(2011, 1, 1)
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
request {
method('GET')
url('/dummy')
headers {
header("Content-Type": 'application/json')
}
}
response {
status 204
body(
dateField: $(consumer(fixedDate), producer(regex(isoDate())))
)
}
}
After I tried to update the version of spring-cloud-contract to v.2.1.0.RELEASE, my contracts have become no longer valid:
java.lang.StackOverflowError
at sun.misc.URLClassPath$JarLoader.getResource(URLClassPath.java:1043)
at sun.misc.URLClassPath.getResource(URLClassPath.java:249)
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:363)
at java.net.URLClassLoader.findClass(URLClassLoader.java:362)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:411)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
...
I haven't found any mentioning about that in the documentation.
Further investigation led me to the conclusion that this strange behavior took place starting from v.1.2.4.RELEASE.
For your convinience, I've written a test to reproduce this behavior (put it in a WireMockGroovyDslSpec to run it):
def 'should convert groovy dsl stub with LocalDate or at least give a meaningful error/warning'() {
given:
def fixedDate = LocalDate.of(2011, 1, 1)
org.springframework.cloud.contract.spec.Contract groovyDsl = org.springframework.cloud.contract.spec.Contract.make {
request {
method('GET')
url('/dummy')
headers {
header("Content-Type": 'application/json')
}
}
response {
status 204
body(
dateField: $(consumer(fixedDate), producer(regex(isoDate())))
)
}
}
when:
String wireMockStub = new WireMockStubStrategy("Test", new ContractMetadata(null, false, 0, null, groovyDsl), groovyDsl).toWireMockClientStub()
then:
AssertionUtil.assertThatJsonsAreEqual('''
{
"request": {
"method": "GET",
"headers": {
"Content-Type": {
"equalTo": "application/json"
}
},
"url": "/dummy"
},
"response": {
"status": 204,
"body": "{\\"dateField\\":\\"2011-01-01\\"}",
"transformers" : [ "response-template", "foo-transformer" ]
}
}
''', wireMockStub)
and:
stubMappingIsValidWireMockStub(wireMockStub)
}
The stack trace doesn't give a clear explanation of mistake nor what was wrong. Documentation lacks this kind of details. Either it is a bug or expected behavior, some clarity is needed. Either in a stack trace or in the documentation. Better both, in my opinion.
Question, possible bug
I've been using
v1.2.3.RELEASEfor a long time and wrote a lot of contracts in the following manner:After I tried to update the version of spring-cloud-contract to
v.2.1.0.RELEASE, my contracts have become no longer valid:I haven't found any mentioning about that in the documentation.
Further investigation led me to the conclusion that this strange behavior took place starting from
v.1.2.4.RELEASE.For your convinience, I've written a test to reproduce this behavior (put it in a
WireMockGroovyDslSpecto run it):The stack trace doesn't give a clear explanation of mistake nor what was wrong. Documentation lacks this kind of details. Either it is a bug or expected behavior, some clarity is needed. Either in a stack trace or in the documentation. Better both, in my opinion.