In Boot 2.4.2, both overloads of TestRestTemplate#exchange
that accept RequestEntity
call getUrl
on it. When the RequestEntity
has been initialized with a URI template instead of a java.net.URI
, this triggers an UnsupportedOperationException
.
var req = RequestEntity.get("http://localhost/helloworld").build();
var resp = testRestTemplate.exchange(req, String.class);
Internally, the real RestTemplate
dispatches based on the concrete type of RequestEntity
, but TestRestTemplate
fails to check.
see spring-projects/spring-framework#26500
Comment From: wilkinsona
It looks like we must be missing some tests. I think this change in behaviour is due to this change that was made in Framework 5.3.0.M1.