spring-cloud-contract: Error: constant string too long
Hi, I’m using spring-cloud-contract version 1.2.7.RELEASE.
When I try to load ‘text/html’ response body data from a file (when defining Groovy contract) and that data is more than 65536 bytes, I get an error ‘constant string too long’ when compiling Java generated test class.
Generated test has a lines similar to these:
String responseBody = response.getBody().asString(); assertThat(responseBody).isEqualTo("Here goes a very long string read from file in Groovy contract."); // here's the failure
Loading file to response body in a contract:
... contentType(textHtml()) ... body(file("myFileWithLongString.txt")) ...
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 15 (8 by maintainers)
Please change
file('fileWithALongStringMoreThan65536Bytes.txt')tofileAsBytes('fileWithALongStringMoreThan65536Bytes.txt'). Then your generated test will look like this: