Skip to content

Commit a6fa8ad

Browse files
crocarneirowilkinsona
authored andcommitted
Improve documentation of TestRestTemplate's fault tolerance
See gh-26227
1 parent f4fd81f commit a6fa8ad

File tree

1 file changed

+18
-41
lines changed
  • spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client

1 file changed

+18
-41
lines changed

spring-boot-project/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java

Lines changed: 18 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,6 @@ public String getRootUri() {
175175
* @param urlVariables the variables to expand the template
176176
* @param <T> the type of the return value
177177
* @return the converted object
178-
* @throws RestClientException on client-side HTTP error on client-side HTTP error
179178
* @see RestTemplate#getForObject(String, Class, Object...)
180179
*/
181180
public <T> T getForObject(String url, Class<T> responseType, Object... urlVariables) throws RestClientException {
@@ -192,7 +191,6 @@ public <T> T getForObject(String url, Class<T> responseType, Object... urlVariab
192191
* @param urlVariables the map containing variables for the URI template
193192
* @param <T> the type of the return value
194193
* @return the converted object
195-
* @throws RestClientException on client-side HTTP error
196194
* @see RestTemplate#getForObject(String, Class, Object...)
197195
*/
198196
public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> urlVariables)
@@ -207,7 +205,6 @@ public <T> T getForObject(String url, Class<T> responseType, Map<String, ?> urlV
207205
* @param responseType the type of the return value
208206
* @param <T> the type of the return value
209207
* @return the converted object
210-
* @throws RestClientException on client-side HTTP error
211208
* @see RestTemplate#getForObject(java.net.URI, java.lang.Class)
212209
*/
213210
public <T> T getForObject(URI url, Class<T> responseType) throws RestClientException {
@@ -224,7 +221,6 @@ public <T> T getForObject(URI url, Class<T> responseType) throws RestClientExcep
224221
* @param urlVariables the variables to expand the template
225222
* @param <T> the type of the return value
226223
* @return the entity
227-
* @throws RestClientException on client-side HTTP error
228224
* @see RestTemplate#getForEntity(java.lang.String, java.lang.Class,
229225
* java.lang.Object[])
230226
*/
@@ -243,7 +239,6 @@ public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Obj
243239
* @param urlVariables the map containing variables for the URI template
244240
* @param <T> the type of the return value
245241
* @return the converted object
246-
* @throws RestClientException on client-side HTTP error
247242
* @see RestTemplate#getForEntity(java.lang.String, java.lang.Class, java.util.Map)
248243
*/
249244
public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map<String, ?> urlVariables)
@@ -258,7 +253,6 @@ public <T> ResponseEntity<T> getForEntity(String url, Class<T> responseType, Map
258253
* @param responseType the type of the return value
259254
* @param <T> the type of the return value
260255
* @return the converted object
261-
* @throws RestClientException on client-side HTTP error
262256
* @see RestTemplate#getForEntity(java.net.URI, java.lang.Class)
263257
*/
264258
public <T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws RestClientException {
@@ -272,7 +266,6 @@ public <T> ResponseEntity<T> getForEntity(URI url, Class<T> responseType) throws
272266
* @param url the URL
273267
* @param urlVariables the variables to expand the template
274268
* @return all HTTP headers of that resource
275-
* @throws RestClientException on client-side HTTP error
276269
* @see RestTemplate#headForHeaders(java.lang.String, java.lang.Object[])
277270
*/
278271
public HttpHeaders headForHeaders(String url, Object... urlVariables) throws RestClientException {
@@ -286,7 +279,6 @@ public HttpHeaders headForHeaders(String url, Object... urlVariables) throws Res
286279
* @param url the URL
287280
* @param urlVariables the map containing variables for the URI template
288281
* @return all HTTP headers of that resource
289-
* @throws RestClientException on client-side HTTP error
290282
* @see RestTemplate#headForHeaders(java.lang.String, java.util.Map)
291283
*/
292284
public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throws RestClientException {
@@ -297,7 +289,6 @@ public HttpHeaders headForHeaders(String url, Map<String, ?> urlVariables) throw
297289
* Retrieve all headers of the resource specified by the URL.
298290
* @param url the URL
299291
* @return all HTTP headers of that resource
300-
* @throws RestClientException on client-side HTTP error
301292
* @see RestTemplate#headForHeaders(java.net.URI)
302293
*/
303294
public HttpHeaders headForHeaders(URI url) throws RestClientException {
@@ -317,7 +308,6 @@ public HttpHeaders headForHeaders(URI url) throws RestClientException {
317308
* @param request the Object to be POSTed, may be {@code null}
318309
* @param urlVariables the variables to expand the template
319310
* @return the value for the {@code Location} header
320-
* @throws RestClientException on client-side HTTP error
321311
* @see HttpEntity
322312
* @see RestTemplate#postForLocation(java.lang.String, java.lang.Object,
323313
* java.lang.Object[])
@@ -339,7 +329,6 @@ public URI postForLocation(String url, Object request, Object... urlVariables) t
339329
* @param request the Object to be POSTed, may be {@code null}
340330
* @param urlVariables the variables to expand the template
341331
* @return the value for the {@code Location} header
342-
* @throws RestClientException on client-side HTTP error
343332
* @see HttpEntity
344333
* @see RestTemplate#postForLocation(java.lang.String, java.lang.Object,
345334
* java.util.Map)
@@ -358,7 +347,6 @@ public URI postForLocation(String url, Object request, Map<String, ?> urlVariabl
358347
* @param url the URL
359348
* @param request the Object to be POSTed, may be {@code null}
360349
* @return the value for the {@code Location} header
361-
* @throws RestClientException on client-side HTTP error
362350
* @see HttpEntity
363351
* @see RestTemplate#postForLocation(java.net.URI, java.lang.Object)
364352
*/
@@ -380,7 +368,6 @@ public URI postForLocation(URI url, Object request) throws RestClientException {
380368
* @param urlVariables the variables to expand the template
381369
* @param <T> the type of the return value
382370
* @return the converted object
383-
* @throws RestClientException on client-side HTTP error
384371
* @see HttpEntity
385372
* @see RestTemplate#postForObject(java.lang.String, java.lang.Object,
386373
* java.lang.Class, java.lang.Object[])
@@ -404,7 +391,6 @@ public <T> T postForObject(String url, Object request, Class<T> responseType, Ob
404391
* @param urlVariables the variables to expand the template
405392
* @param <T> the type of the return value
406393
* @return the converted object
407-
* @throws RestClientException on client-side HTTP error
408394
* @see HttpEntity
409395
* @see RestTemplate#postForObject(java.lang.String, java.lang.Object,
410396
* java.lang.Class, java.util.Map)
@@ -425,7 +411,6 @@ public <T> T postForObject(String url, Object request, Class<T> responseType, Ma
425411
* @param responseType the type of the return value
426412
* @param <T> the type of the return value
427413
* @return the converted object
428-
* @throws RestClientException on client-side HTTP error
429414
* @see HttpEntity
430415
* @see RestTemplate#postForObject(java.net.URI, java.lang.Object, java.lang.Class)
431416
*/
@@ -447,7 +432,6 @@ public <T> T postForObject(URI url, Object request, Class<T> responseType) throw
447432
* @param urlVariables the variables to expand the template
448433
* @param <T> the type of the return value
449434
* @return the converted object
450-
* @throws RestClientException on client-side HTTP error
451435
* @see HttpEntity
452436
* @see RestTemplate#postForEntity(java.lang.String, java.lang.Object,
453437
* java.lang.Class, java.lang.Object[])
@@ -471,7 +455,6 @@ public <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T>
471455
* @param urlVariables the variables to expand the template
472456
* @param <T> the type of the return value
473457
* @return the converted object
474-
* @throws RestClientException on client-side HTTP error
475458
* @see HttpEntity
476459
* @see RestTemplate#postForEntity(java.lang.String, java.lang.Object,
477460
* java.lang.Class, java.util.Map)
@@ -492,7 +475,6 @@ public <T> ResponseEntity<T> postForEntity(String url, Object request, Class<T>
492475
* @param responseType the response type to return
493476
* @param <T> the type of the return value
494477
* @return the converted object
495-
* @throws RestClientException on client-side HTTP error
496478
* @see HttpEntity
497479
* @see RestTemplate#postForEntity(java.net.URI, java.lang.Object, java.lang.Class)
498480
*/
@@ -508,10 +490,12 @@ public <T> ResponseEntity<T> postForEntity(URI url, Object request, Class<T> res
508490
* <p>
509491
* The {@code request} parameter can be a {@link HttpEntity} in order to add
510492
* additional HTTP headers to the request.
493+
* <p>
494+
* If you need to assert the request result consider using the
495+
* {@link TestRestTemplate#exchange exchange} method.
511496
* @param url the URL
512497
* @param request the Object to be PUT, may be {@code null}
513498
* @param urlVariables the variables to expand the template
514-
* @throws RestClientException on client-side HTTP error
515499
* @see HttpEntity
516500
* @see RestTemplate#put(java.lang.String, java.lang.Object, java.lang.Object[])
517501
*/
@@ -526,10 +510,12 @@ public void put(String url, Object request, Object... urlVariables) throws RestC
526510
* <p>
527511
* The {@code request} parameter can be a {@link HttpEntity} in order to add
528512
* additional HTTP headers to the request.
513+
* <p>
514+
* If you need to assert the request result consider using the
515+
* {@link TestRestTemplate#exchange exchange} method.
529516
* @param url the URL
530517
* @param request the Object to be PUT, may be {@code null}
531518
* @param urlVariables the variables to expand the template
532-
* @throws RestClientException on client-side HTTP error
533519
* @see HttpEntity
534520
* @see RestTemplate#put(java.lang.String, java.lang.Object, java.util.Map)
535521
*/
@@ -542,9 +528,11 @@ public void put(String url, Object request, Map<String, ?> urlVariables) throws
542528
* <p>
543529
* The {@code request} parameter can be a {@link HttpEntity} in order to add
544530
* additional HTTP headers to the request.
531+
* <p>
532+
* If you need to assert the request result consider using the
533+
* {@link TestRestTemplate#exchange exchange} method.
545534
* @param url the URL
546535
* @param request the Object to be PUT, may be {@code null}
547-
* @throws RestClientException on client-side HTTP error
548536
* @see HttpEntity
549537
* @see RestTemplate#put(java.net.URI, java.lang.Object)
550538
*/
@@ -566,7 +554,6 @@ public void put(URI url, Object request) throws RestClientException {
566554
* @param uriVariables the variables to expand the template
567555
* @param <T> the type of the return value
568556
* @return the converted object
569-
* @throws RestClientException on client-side HTTP error
570557
* @since 1.4.4
571558
* @see HttpEntity
572559
*/
@@ -589,7 +576,6 @@ public <T> T patchForObject(String url, Object request, Class<T> responseType, O
589576
* @param uriVariables the variables to expand the template
590577
* @param <T> the type of the return value
591578
* @return the converted object
592-
* @throws RestClientException on client-side HTTP error
593579
* @since 1.4.4
594580
* @see HttpEntity
595581
*/
@@ -609,7 +595,6 @@ public <T> T patchForObject(String url, Object request, Class<T> responseType, M
609595
* @param responseType the type of the return value
610596
* @param <T> the type of the return value
611597
* @return the converted object
612-
* @throws RestClientException on client-side HTTP error
613598
* @since 1.4.4
614599
* @see HttpEntity
615600
*/
@@ -621,9 +606,11 @@ public <T> T patchForObject(URI url, Object request, Class<T> responseType) thro
621606
* Delete the resources at the specified URI.
622607
* <p>
623608
* URI Template variables are expanded using the given URI variables, if any.
609+
* <p>
610+
* If you need to assert the request result consider using the
611+
* {@link TestRestTemplate#exchange exchange} method.
624612
* @param url the URL
625613
* @param urlVariables the variables to expand in the template
626-
* @throws RestClientException on client-side HTTP error
627614
* @see RestTemplate#delete(java.lang.String, java.lang.Object[])
628615
*/
629616
public void delete(String url, Object... urlVariables) throws RestClientException {
@@ -634,9 +621,11 @@ public void delete(String url, Object... urlVariables) throws RestClientExceptio
634621
* Delete the resources at the specified URI.
635622
* <p>
636623
* URI Template variables are expanded using the given map.
624+
* <p>
625+
* If you need to assert the request result consider using the
626+
* {@link TestRestTemplate#exchange exchange} method.
637627
* @param url the URL
638628
* @param urlVariables the variables to expand the template
639-
* @throws RestClientException on client-side HTTP error
640629
* @see RestTemplate#delete(java.lang.String, java.util.Map)
641630
*/
642631
public void delete(String url, Map<String, ?> urlVariables) throws RestClientException {
@@ -645,8 +634,10 @@ public void delete(String url, Map<String, ?> urlVariables) throws RestClientExc
645634

646635
/**
647636
* Delete the resources at the specified URL.
637+
* <p>
638+
* If you need to assert the request result consider using the
639+
* {@link TestRestTemplate#exchange exchange} method.
648640
* @param url the URL
649-
* @throws RestClientException on client-side HTTP error
650641
* @see RestTemplate#delete(java.net.URI)
651642
*/
652643
public void delete(URI url) throws RestClientException {
@@ -660,7 +651,6 @@ public void delete(URI url) throws RestClientException {
660651
* @param url the URL
661652
* @param urlVariables the variables to expand in the template
662653
* @return the value of the allow header
663-
* @throws RestClientException on client-side HTTP error
664654
* @see RestTemplate#optionsForAllow(java.lang.String, java.lang.Object[])
665655
*/
666656
public Set<HttpMethod> optionsForAllow(String url, Object... urlVariables) throws RestClientException {
@@ -674,7 +664,6 @@ public Set<HttpMethod> optionsForAllow(String url, Object... urlVariables) throw
674664
* @param url the URL
675665
* @param urlVariables the variables to expand in the template
676666
* @return the value of the allow header
677-
* @throws RestClientException on client-side HTTP error
678667
* @see RestTemplate#optionsForAllow(java.lang.String, java.util.Map)
679668
*/
680669
public Set<HttpMethod> optionsForAllow(String url, Map<String, ?> urlVariables) throws RestClientException {
@@ -685,7 +674,6 @@ public Set<HttpMethod> optionsForAllow(String url, Map<String, ?> urlVariables)
685674
* Return the value of the Allow header for the given URL.
686675
* @param url the URL
687676
* @return the value of the allow header
688-
* @throws RestClientException on client-side HTTP error
689677
* @see RestTemplate#optionsForAllow(java.net.URI)
690678
*/
691679
public Set<HttpMethod> optionsForAllow(URI url) throws RestClientException {
@@ -705,7 +693,6 @@ public Set<HttpMethod> optionsForAllow(URI url) throws RestClientException {
705693
* @param urlVariables the variables to expand in the template
706694
* @param <T> the type of the return value
707695
* @return the response as entity
708-
* @throws RestClientException on client-side HTTP error
709696
* @see RestTemplate#exchange(java.lang.String, org.springframework.http.HttpMethod,
710697
* org.springframework.http.HttpEntity, java.lang.Class, java.lang.Object[])
711698
*/
@@ -727,7 +714,6 @@ public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<
727714
* @param urlVariables the variables to expand in the template
728715
* @param <T> the type of the return value
729716
* @return the response as entity
730-
* @throws RestClientException on client-side HTTP error
731717
* @see RestTemplate#exchange(java.lang.String, org.springframework.http.HttpMethod,
732718
* org.springframework.http.HttpEntity, java.lang.Class, java.util.Map)
733719
*/
@@ -746,7 +732,6 @@ public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<
746732
* @param responseType the type of the return value
747733
* @param <T> the type of the return value
748734
* @return the response as entity
749-
* @throws RestClientException on client-side HTTP error
750735
* @see RestTemplate#exchange(java.net.URI, org.springframework.http.HttpMethod,
751736
* org.springframework.http.HttpEntity, java.lang.Class)
752737
*/
@@ -771,7 +756,6 @@ public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?>
771756
* @param urlVariables the variables to expand in the template
772757
* @param <T> the type of the return value
773758
* @return the response as entity
774-
* @throws RestClientException on client-side HTTP error
775759
* @see RestTemplate#exchange(java.lang.String, org.springframework.http.HttpMethod,
776760
* org.springframework.http.HttpEntity,
777761
* org.springframework.core.ParameterizedTypeReference, java.lang.Object[])
@@ -797,7 +781,6 @@ public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<
797781
* @param urlVariables the variables to expand in the template
798782
* @param <T> the type of the return value
799783
* @return the response as entity
800-
* @throws RestClientException on client-side HTTP error
801784
* @see RestTemplate#exchange(java.lang.String, org.springframework.http.HttpMethod,
802785
* org.springframework.http.HttpEntity,
803786
* org.springframework.core.ParameterizedTypeReference, java.util.Map)
@@ -822,7 +805,6 @@ public <T> ResponseEntity<T> exchange(String url, HttpMethod method, HttpEntity<
822805
* @param responseType the type of the return value
823806
* @param <T> the type of the return value
824807
* @return the response as entity
825-
* @throws RestClientException on client-side HTTP error
826808
* @see RestTemplate#exchange(java.net.URI, org.springframework.http.HttpMethod,
827809
* org.springframework.http.HttpEntity,
828810
* org.springframework.core.ParameterizedTypeReference)
@@ -844,7 +826,6 @@ public <T> ResponseEntity<T> exchange(URI url, HttpMethod method, HttpEntity<?>
844826
* @param responseType the type of the return value
845827
* @param <T> the type of the return value
846828
* @return the response as entity
847-
* @throws RestClientException on client-side HTTP error
848829
* @see RestTemplate#exchange(org.springframework.http.RequestEntity, java.lang.Class)
849830
*/
850831
public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> responseType)
@@ -865,7 +846,6 @@ public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Class<T> r
865846
* @param responseType the type of the return value
866847
* @param <T> the type of the return value
867848
* @return the response as entity
868-
* @throws RestClientException on client-side HTTP error
869849
* @see RestTemplate#exchange(org.springframework.http.RequestEntity,
870850
* org.springframework.core.ParameterizedTypeReference)
871851
*/
@@ -886,7 +866,6 @@ public <T> ResponseEntity<T> exchange(RequestEntity<?> requestEntity, Parameteri
886866
* @param urlVariables the variables to expand in the template
887867
* @param <T> the type of the return value
888868
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
889-
* @throws RestClientException on client-side HTTP error
890869
* @see RestTemplate#execute(java.lang.String, org.springframework.http.HttpMethod,
891870
* org.springframework.web.client.RequestCallback,
892871
* org.springframework.web.client.ResponseExtractor, java.lang.Object[])
@@ -908,7 +887,6 @@ public <T> T execute(String url, HttpMethod method, RequestCallback requestCallb
908887
* @param urlVariables the variables to expand in the template
909888
* @param <T> the type of the return value
910889
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
911-
* @throws RestClientException on client-side HTTP error
912890
* @see RestTemplate#execute(java.lang.String, org.springframework.http.HttpMethod,
913891
* org.springframework.web.client.RequestCallback,
914892
* org.springframework.web.client.ResponseExtractor, java.util.Map)
@@ -927,7 +905,6 @@ public <T> T execute(String url, HttpMethod method, RequestCallback requestCallb
927905
* @param responseExtractor object that extracts the return value from the response
928906
* @param <T> the type of the return value
929907
* @return an arbitrary object, as returned by the {@link ResponseExtractor}
930-
* @throws RestClientException on client-side HTTP error
931908
* @see RestTemplate#execute(java.net.URI, org.springframework.http.HttpMethod,
932909
* org.springframework.web.client.RequestCallback,
933910
* org.springframework.web.client.ResponseExtractor)

0 commit comments

Comments
 (0)