I'm on Spring Boot 1.5.10.
As far as I can see, all function signatures of TestRestTemplate.delete()
are void methods.
This has two implications:
- It is not possible to get the http status of the response (for use in tests)
- It is not possible to get the body of the response (for use in tests)
One might argue that there should not be a body for DELETE
, but in my use case this is given by some specs and therefore can't be avoided. As long as this is supported by the http standard, there should also be a way to (implement and) test this.
PS: This is the place to look at:
https://github.com/spring-projects/spring-boot/blob/master/spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java#L682
Comment From: wilkinsona
Thanks for the suggestion, but the signatures of TestRestTemplate
's methods are aligned with those of RestOperations
in Spring Framework. We have a test that enforces that verifies this alignment. For TestRestTemplate
to change as you have suggested a change would have to be made to Spring Framework.
I'd recommend using one of the exchange
variants which will allow you to make a DELETE
request and access the status and body of the response.
Comment From: thomaszbz
@wilkinsona Thank you for responding so quickly. It worked great with exchange
. It was just a bit more code.
Comment From: vihang16
can you please suggest how did you do with exchange?
Comment From: snicoll
@vihang16 exchange
lets you get access to ResponseEntity
that should give you all you need. Please ask follow-up questions on StackOverflow.