Polish 'Add redirects(...) method to RestTemplateBuilder'

Remove deprecations and new methods in `TestRestTemplate` in favor of
passing in a configured `RestTemplateBuilder`.

See gh-43258
This commit is contained in:
Phillip Webb
2024-12-04 13:33:12 -08:00
parent f450b28a7c
commit 8b83afdb68
2 changed files with 43 additions and 33 deletions

View File

@@ -948,22 +948,6 @@ public class TestRestTemplate {
return template;
}
/**
* Creates a new {@code TestRestTemplate} with the same configuration as this one,
* except that it will use the given {@code redirects} strategies. The request factory
* used is a new instance of the underlying {@link RestTemplate}'s request factory
* type (when possible).
* @param redirects the redirects
* @return the new template
* @since 3.4.1
*/
public TestRestTemplate withRedirects(Redirects redirects) {
TestRestTemplate template = new TestRestTemplate(this.builder.redirects(redirects), null, null,
this.httpClientOptions);
template.setUriTemplateHandler(getRestTemplate().getUriTemplateHandler());
return template;
}
@SuppressWarnings({ "rawtypes", "unchecked" })
private RequestEntity<?> createRequestEntityWithRootAppliedUri(RequestEntity<?> requestEntity) {
return new RequestEntity(requestEntity.getBody(), requestEntity.getHeaders(), requestEntity.getMethod(),
@@ -1006,10 +990,7 @@ public class TestRestTemplate {
/**
* Enable redirects.
* @deprecated since 3.4.1 for removal in 3.6.0 in favor of
* {@link #withRedirects(Redirects)}
*/
@Deprecated(since = "3.4.1", forRemoval = true)
ENABLE_REDIRECTS,
/**