There is an inconsistency between WebTestClient and RestTestClient when the controller does not return any body. exec("/empty").returnResult().getResponseBody()
in WebTestClient returns an empty byte[] while RestTestClient returns null.
See the reproducer here https://github.com/lukas-krecan/JsonUnit/compare/reproducer?expand=1
It's not a big deal, feel free to close it if it is intentional. I was just a bit surprised by that and thought you may not be aware.
Comment From: rstoyanchev
There are some recent related changes in #35399, so worth using snapshots.
That said, I'm getting null
with .exchange().expectBody().returnResult().getResponseBody()
even with WebTestClient
, which makes sense given the call to bodyToMono and block, which returns null
if the Mono completes empty as a result of a response without any buffers.
I didn't try checking out the repository yet to see what's different.