To test the services, start it and do:
- curl -X GET "http://localhost:8080/api/v1/xxxx" and you will receive a valid response "just a test"
To check that the error response is correct:
- curl -X GET "http://localhost:8080/api/v1/testFail" and you will receive an error response
{
"timestamp": 1481654921954,
"status": 409,
"error": "Conflict",
"exception": "com.example.MyCustomException",
"message": "CUSTOM_MESSAGE_HERE",
"path": "/api/v1/xxxx"
}
To test with contracts:
- Run mvn clean test
A Build failure message appear:
Tests in error:
RestTest.validate_negative:28 » IllegalArgument json string can not be null or...
Tests run: 3, Failures: 0, Errors: 2, Skipped: 0
Check the autogenerated class: /test-negative-contract/target/generated-test-sources/contracts/org/springframework/cloud/contract/verifier/tests/com/example/external/consumer/RestTest.java
And line 28 is:
DocumentContext parsedJson = JsonPath.parse(response.getBody().asString());
If you inspect that in debug mode, you can see that response.getBody().asString() is empty