@ -50,16 +50,19 @@ import org.springframework.util.Assert;
import org.springframework.web.client.DefaultResponseErrorHandler ;
import org.springframework.web.client.DefaultResponseErrorHandler ;
import org.springframework.web.client.RequestCallback ;
import org.springframework.web.client.RequestCallback ;
import org.springframework.web.client.ResponseExtractor ;
import org.springframework.web.client.ResponseExtractor ;
import org.springframework.web.client.RestClientException ;
import org.springframework.web.client.RestTemplate ;
import org.springframework.web.client.RestTemplate ;
import org.springframework.web.util.DefaultUriBuilderFactory ;
import org.springframework.web.util.DefaultUriBuilderFactory ;
import org.springframework.web.util.UriTemplateHandler ;
import org.springframework.web.util.UriTemplateHandler ;
/ * *
/ * *
* Convenient alternative of { @link RestTemplate } that is suitable for integration tests .
* Convenient alternative of { @link RestTemplate } that is suitable for integration tests .
* They are fault tolerant , and optionally can carry Basic authentication headers . If
* { @code TestRestTemplate } is fault tolerant . This means that 4 xx and 5 xx do not result
* Apache Http Client 4.3 .2 or better is available ( recommended ) it will be used as the
* in an exception being thrown and can instead be detected via the { @link ResponseEntity
* client , and by default configured to ignore cookies and redirects .
* response entity } and its { @link ResponseEntity # getStatusCode ( ) status code } .
* < p >
* A { @code TestRestTemplate } can optionally carry Basic authentication headers . If Apache
* Http Client 4.3 .2 or better is available ( recommended ) it will be used as the client ,
* and by default configured to ignore cookies and redirects .
* < p >
* < p >
* Note : To prevent injection problems this class intentionally does not extend
* Note : To prevent injection problems this class intentionally does not extend
* { @link RestTemplate } . If you need access to the underlying { @link RestTemplate } use
* { @link RestTemplate } . If you need access to the underlying { @link RestTemplate } use
@ -176,10 +179,9 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error on client - side HTTP error
* @see RestTemplate # getForObject ( String , Class , Object . . . )
* @see RestTemplate # getForObject ( String , Class , Object . . . )
* /
* /
public < T > T getForObject ( String url , Class < T > responseType , Object . . . urlVariables ) throws RestClientException {
public < T > T getForObject ( String url , Class < T > responseType , Object . . . urlVariables ) {
return this . restTemplate . getForObject ( url , responseType , urlVariables ) ;
return this . restTemplate . getForObject ( url , responseType , urlVariables ) ;
}
}
@ -193,11 +195,9 @@ public class TestRestTemplate {
* @param urlVariables the map containing variables for the URI template
* @param urlVariables the map containing variables for the URI template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # getForObject ( String , Class , Object . . . )
* @see RestTemplate # getForObject ( String , Class , Object . . . )
* /
* /
public < T > T getForObject ( String url , Class < T > responseType , Map < String , ? > urlVariables )
public < T > T getForObject ( String url , Class < T > responseType , Map < String , ? > urlVariables ) {
throws RestClientException {
return this . restTemplate . getForObject ( url , responseType , urlVariables ) ;
return this . restTemplate . getForObject ( url , responseType , urlVariables ) ;
}
}
@ -208,10 +208,9 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # getForObject ( java . net . URI , java . lang . Class )
* @see RestTemplate # getForObject ( java . net . URI , java . lang . Class )
* /
* /
public < T > T getForObject ( URI url , Class < T > responseType ) throws RestClientException {
public < T > T getForObject ( URI url , Class < T > responseType ) {
return this . restTemplate . getForObject ( applyRootUriIfNecessary ( url ) , responseType ) ;
return this . restTemplate . getForObject ( applyRootUriIfNecessary ( url ) , responseType ) ;
}
}
@ -225,12 +224,10 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the entity
* @return the entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # getForEntity ( java . lang . String , java . lang . Class ,
* @see RestTemplate # getForEntity ( java . lang . String , java . lang . Class ,
* java . lang . Object [ ] )
* java . lang . Object [ ] )
* /
* /
public < T > ResponseEntity < T > getForEntity ( String url , Class < T > responseType , Object . . . urlVariables )
public < T > ResponseEntity < T > getForEntity ( String url , Class < T > responseType , Object . . . urlVariables ) {
throws RestClientException {
return this . restTemplate . getForEntity ( url , responseType , urlVariables ) ;
return this . restTemplate . getForEntity ( url , responseType , urlVariables ) ;
}
}
@ -244,11 +241,9 @@ public class TestRestTemplate {
* @param urlVariables the map containing variables for the URI template
* @param urlVariables the map containing variables for the URI template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # getForEntity ( java . lang . String , java . lang . Class , java . util . Map )
* @see RestTemplate # getForEntity ( java . lang . String , java . lang . Class , java . util . Map )
* /
* /
public < T > ResponseEntity < T > getForEntity ( String url , Class < T > responseType , Map < String , ? > urlVariables )
public < T > ResponseEntity < T > getForEntity ( String url , Class < T > responseType , Map < String , ? > urlVariables ) {
throws RestClientException {
return this . restTemplate . getForEntity ( url , responseType , urlVariables ) ;
return this . restTemplate . getForEntity ( url , responseType , urlVariables ) ;
}
}
@ -259,10 +254,9 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # getForEntity ( java . net . URI , java . lang . Class )
* @see RestTemplate # getForEntity ( java . net . URI , java . lang . Class )
* /
* /
public < T > ResponseEntity < T > getForEntity ( URI url , Class < T > responseType ) throws RestClientException {
public < T > ResponseEntity < T > getForEntity ( URI url , Class < T > responseType ) {
return this . restTemplate . getForEntity ( applyRootUriIfNecessary ( url ) , responseType ) ;
return this . restTemplate . getForEntity ( applyRootUriIfNecessary ( url ) , responseType ) ;
}
}
@ -273,10 +267,9 @@ public class TestRestTemplate {
* @param url the URL
* @param url the URL
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @return all HTTP headers of that resource
* @return all HTTP headers of that resource
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # headForHeaders ( java . lang . String , java . lang . Object [ ] )
* @see RestTemplate # headForHeaders ( java . lang . String , java . lang . Object [ ] )
* /
* /
public HttpHeaders headForHeaders ( String url , Object . . . urlVariables ) throws RestClientException {
public HttpHeaders headForHeaders ( String url , Object . . . urlVariables ) {
return this . restTemplate . headForHeaders ( url , urlVariables ) ;
return this . restTemplate . headForHeaders ( url , urlVariables ) ;
}
}
@ -287,10 +280,9 @@ public class TestRestTemplate {
* @param url the URL
* @param url the URL
* @param urlVariables the map containing variables for the URI template
* @param urlVariables the map containing variables for the URI template
* @return all HTTP headers of that resource
* @return all HTTP headers of that resource
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # headForHeaders ( java . lang . String , java . util . Map )
* @see RestTemplate # headForHeaders ( java . lang . String , java . util . Map )
* /
* /
public HttpHeaders headForHeaders ( String url , Map < String , ? > urlVariables ) throws RestClientException {
public HttpHeaders headForHeaders ( String url , Map < String , ? > urlVariables ) {
return this . restTemplate . headForHeaders ( url , urlVariables ) ;
return this . restTemplate . headForHeaders ( url , urlVariables ) ;
}
}
@ -298,10 +290,9 @@ public class TestRestTemplate {
* Retrieve all headers of the resource specified by the URL .
* Retrieve all headers of the resource specified by the URL .
* @param url the URL
* @param url the URL
* @return all HTTP headers of that resource
* @return all HTTP headers of that resource
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # headForHeaders ( java . net . URI )
* @see RestTemplate # headForHeaders ( java . net . URI )
* /
* /
public HttpHeaders headForHeaders ( URI url ) throws RestClientException {
public HttpHeaders headForHeaders ( URI url ) {
return this . restTemplate . headForHeaders ( applyRootUriIfNecessary ( url ) ) ;
return this . restTemplate . headForHeaders ( applyRootUriIfNecessary ( url ) ) ;
}
}
@ -318,12 +309,11 @@ public class TestRestTemplate {
* @param request the Object to be POSTed , may be { @code null }
* @param request the Object to be POSTed , may be { @code null }
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @return the value for the { @code Location } header
* @return the value for the { @code Location } header
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForLocation ( java . lang . String , java . lang . Object ,
* @see RestTemplate # postForLocation ( java . lang . String , java . lang . Object ,
* java . lang . Object [ ] )
* java . lang . Object [ ] )
* /
* /
public URI postForLocation ( String url , Object request , Object . . . urlVariables ) throws RestClientException {
public URI postForLocation ( String url , Object request , Object . . . urlVariables ) {
return this . restTemplate . postForLocation ( url , request , urlVariables ) ;
return this . restTemplate . postForLocation ( url , request , urlVariables ) ;
}
}
@ -340,12 +330,11 @@ public class TestRestTemplate {
* @param request the Object to be POSTed , may be { @code null }
* @param request the Object to be POSTed , may be { @code null }
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @return the value for the { @code Location } header
* @return the value for the { @code Location } header
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForLocation ( java . lang . String , java . lang . Object ,
* @see RestTemplate # postForLocation ( java . lang . String , java . lang . Object ,
* java . util . Map )
* java . util . Map )
* /
* /
public URI postForLocation ( String url , Object request , Map < String , ? > urlVariables ) throws RestClientException {
public URI postForLocation ( String url , Object request , Map < String , ? > urlVariables ) {
return this . restTemplate . postForLocation ( url , request , urlVariables ) ;
return this . restTemplate . postForLocation ( url , request , urlVariables ) ;
}
}
@ -359,11 +348,10 @@ public class TestRestTemplate {
* @param url the URL
* @param url the URL
* @param request the Object to be POSTed , may be { @code null }
* @param request the Object to be POSTed , may be { @code null }
* @return the value for the { @code Location } header
* @return the value for the { @code Location } header
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForLocation ( java . net . URI , java . lang . Object )
* @see RestTemplate # postForLocation ( java . net . URI , java . lang . Object )
* /
* /
public URI postForLocation ( URI url , Object request ) throws RestClientException {
public URI postForLocation ( URI url , Object request ) {
return this . restTemplate . postForLocation ( applyRootUriIfNecessary ( url ) , request ) ;
return this . restTemplate . postForLocation ( applyRootUriIfNecessary ( url ) , request ) ;
}
}
@ -381,13 +369,11 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForObject ( java . lang . String , java . lang . Object ,
* @see RestTemplate # postForObject ( java . lang . String , java . lang . Object ,
* java . lang . Class , java . lang . Object [ ] )
* java . lang . Class , java . lang . Object [ ] )
* /
* /
public < T > T postForObject ( String url , Object request , Class < T > responseType , Object . . . urlVariables )
public < T > T postForObject ( String url , Object request , Class < T > responseType , Object . . . urlVariables ) {
throws RestClientException {
return this . restTemplate . postForObject ( url , request , responseType , urlVariables ) ;
return this . restTemplate . postForObject ( url , request , responseType , urlVariables ) ;
}
}
@ -405,13 +391,11 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForObject ( java . lang . String , java . lang . Object ,
* @see RestTemplate # postForObject ( java . lang . String , java . lang . Object ,
* java . lang . Class , java . util . Map )
* java . lang . Class , java . util . Map )
* /
* /
public < T > T postForObject ( String url , Object request , Class < T > responseType , Map < String , ? > urlVariables )
public < T > T postForObject ( String url , Object request , Class < T > responseType , Map < String , ? > urlVariables ) {
throws RestClientException {
return this . restTemplate . postForObject ( url , request , responseType , urlVariables ) ;
return this . restTemplate . postForObject ( url , request , responseType , urlVariables ) ;
}
}
@ -426,11 +410,10 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForObject ( java . net . URI , java . lang . Object , java . lang . Class )
* @see RestTemplate # postForObject ( java . net . URI , java . lang . Object , java . lang . Class )
* /
* /
public < T > T postForObject ( URI url , Object request , Class < T > responseType ) throws RestClientException {
public < T > T postForObject ( URI url , Object request , Class < T > responseType ) {
return this . restTemplate . postForObject ( applyRootUriIfNecessary ( url ) , request , responseType ) ;
return this . restTemplate . postForObject ( applyRootUriIfNecessary ( url ) , request , responseType ) ;
}
}
@ -448,13 +431,12 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForEntity ( java . lang . String , java . lang . Object ,
* @see RestTemplate # postForEntity ( java . lang . String , java . lang . Object ,
* java . lang . Class , java . lang . Object [ ] )
* java . lang . Class , java . lang . Object [ ] )
* /
* /
public < T > ResponseEntity < T > postForEntity ( String url , Object request , Class < T > responseType ,
public < T > ResponseEntity < T > postForEntity ( String url , Object request , Class < T > responseType ,
Object . . . urlVariables ) throws RestClientException {
Object . . . urlVariables ) {
return this . restTemplate . postForEntity ( url , request , responseType , urlVariables ) ;
return this . restTemplate . postForEntity ( url , request , responseType , urlVariables ) ;
}
}
@ -472,13 +454,12 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForEntity ( java . lang . String , java . lang . Object ,
* @see RestTemplate # postForEntity ( java . lang . String , java . lang . Object ,
* java . lang . Class , java . util . Map )
* java . lang . Class , java . util . Map )
* /
* /
public < T > ResponseEntity < T > postForEntity ( String url , Object request , Class < T > responseType ,
public < T > ResponseEntity < T > postForEntity ( String url , Object request , Class < T > responseType ,
Map < String , ? > urlVariables ) throws RestClientException {
Map < String , ? > urlVariables ) {
return this . restTemplate . postForEntity ( url , request , responseType , urlVariables ) ;
return this . restTemplate . postForEntity ( url , request , responseType , urlVariables ) ;
}
}
@ -493,12 +474,10 @@ public class TestRestTemplate {
* @param responseType the response type to return
* @param responseType the response type to return
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # postForEntity ( java . net . URI , java . lang . Object , java . lang . Class )
* @see RestTemplate # postForEntity ( java . net . URI , java . lang . Object , java . lang . Class )
* /
* /
public < T > ResponseEntity < T > postForEntity ( URI url , Object request , Class < T > responseType )
public < T > ResponseEntity < T > postForEntity ( URI url , Object request , Class < T > responseType ) {
throws RestClientException {
return this . restTemplate . postForEntity ( applyRootUriIfNecessary ( url ) , request , responseType ) ;
return this . restTemplate . postForEntity ( applyRootUriIfNecessary ( url ) , request , responseType ) ;
}
}
@ -509,14 +488,16 @@ public class TestRestTemplate {
* < p >
* < p >
* The { @code request } parameter can be a { @link HttpEntity } in order to add
* The { @code request } parameter can be a { @link HttpEntity } in order to add
* additional HTTP headers to the request .
* additional HTTP headers to the request .
* < p >
* If you need to assert the request result consider using the
* { @link TestRestTemplate # exchange exchange } method .
* @param url the URL
* @param url the URL
* @param request the Object to be PUT , may be { @code null }
* @param request the Object to be PUT , may be { @code null }
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # put ( java . lang . String , java . lang . Object , java . lang . Object [ ] )
* @see RestTemplate # put ( java . lang . String , java . lang . Object , java . lang . Object [ ] )
* /
* /
public void put ( String url , Object request , Object . . . urlVariables ) throws RestClientException {
public void put ( String url , Object request , Object . . . urlVariables ) {
this . restTemplate . put ( url , request , urlVariables ) ;
this . restTemplate . put ( url , request , urlVariables ) ;
}
}
@ -527,14 +508,16 @@ public class TestRestTemplate {
* < p >
* < p >
* The { @code request } parameter can be a { @link HttpEntity } in order to add
* The { @code request } parameter can be a { @link HttpEntity } in order to add
* additional HTTP headers to the request .
* additional HTTP headers to the request .
* < p >
* If you need to assert the request result consider using the
* { @link TestRestTemplate # exchange exchange } method .
* @param url the URL
* @param url the URL
* @param request the Object to be PUT , may be { @code null }
* @param request the Object to be PUT , may be { @code null }
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # put ( java . lang . String , java . lang . Object , java . util . Map )
* @see RestTemplate # put ( java . lang . String , java . lang . Object , java . util . Map )
* /
* /
public void put ( String url , Object request , Map < String , ? > urlVariables ) throws RestClientException {
public void put ( String url , Object request , Map < String , ? > urlVariables ) {
this . restTemplate . put ( url , request , urlVariables ) ;
this . restTemplate . put ( url , request , urlVariables ) ;
}
}
@ -543,13 +526,15 @@ public class TestRestTemplate {
* < p >
* < p >
* The { @code request } parameter can be a { @link HttpEntity } in order to add
* The { @code request } parameter can be a { @link HttpEntity } in order to add
* additional HTTP headers to the request .
* additional HTTP headers to the request .
* < p >
* If you need to assert the request result consider using the
* { @link TestRestTemplate # exchange exchange } method .
* @param url the URL
* @param url the URL
* @param request the Object to be PUT , may be { @code null }
* @param request the Object to be PUT , may be { @code null }
* @throws RestClientException on client - side HTTP error
* @see HttpEntity
* @see HttpEntity
* @see RestTemplate # put ( java . net . URI , java . lang . Object )
* @see RestTemplate # put ( java . net . URI , java . lang . Object )
* /
* /
public void put ( URI url , Object request ) throws RestClientException {
public void put ( URI url , Object request ) {
this . restTemplate . put ( applyRootUriIfNecessary ( url ) , request ) ;
this . restTemplate . put ( applyRootUriIfNecessary ( url ) , request ) ;
}
}
@ -567,12 +552,10 @@ public class TestRestTemplate {
* @param uriVariables the variables to expand the template
* @param uriVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @since 1.4 .4
* @since 1.4 .4
* @see HttpEntity
* @see HttpEntity
* /
* /
public < T > T patchForObject ( String url , Object request , Class < T > responseType , Object . . . uriVariables )
public < T > T patchForObject ( String url , Object request , Class < T > responseType , Object . . . uriVariables ) {
throws RestClientException {
return this . restTemplate . patchForObject ( url , request , responseType , uriVariables ) ;
return this . restTemplate . patchForObject ( url , request , responseType , uriVariables ) ;
}
}
@ -590,12 +573,10 @@ public class TestRestTemplate {
* @param uriVariables the variables to expand the template
* @param uriVariables the variables to expand the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @since 1.4 .4
* @since 1.4 .4
* @see HttpEntity
* @see HttpEntity
* /
* /
public < T > T patchForObject ( String url , Object request , Class < T > responseType , Map < String , ? > uriVariables )
public < T > T patchForObject ( String url , Object request , Class < T > responseType , Map < String , ? > uriVariables ) {
throws RestClientException {
return this . restTemplate . patchForObject ( url , request , responseType , uriVariables ) ;
return this . restTemplate . patchForObject ( url , request , responseType , uriVariables ) ;
}
}
@ -610,11 +591,10 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the converted object
* @return the converted object
* @throws RestClientException on client - side HTTP error
* @since 1.4 .4
* @since 1.4 .4
* @see HttpEntity
* @see HttpEntity
* /
* /
public < T > T patchForObject ( URI url , Object request , Class < T > responseType ) throws RestClientException {
public < T > T patchForObject ( URI url , Object request , Class < T > responseType ) {
return this . restTemplate . patchForObject ( applyRootUriIfNecessary ( url ) , request , responseType ) ;
return this . restTemplate . patchForObject ( applyRootUriIfNecessary ( url ) , request , responseType ) ;
}
}
@ -622,12 +602,14 @@ public class TestRestTemplate {
* Delete the resources at the specified URI .
* Delete the resources at the specified URI .
* < p >
* < p >
* URI Template variables are expanded using the given URI variables , if any .
* URI Template variables are expanded using the given URI variables , if any .
* < p >
* If you need to assert the request result consider using the
* { @link TestRestTemplate # exchange exchange } method .
* @param url the URL
* @param url the URL
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # delete ( java . lang . String , java . lang . Object [ ] )
* @see RestTemplate # delete ( java . lang . String , java . lang . Object [ ] )
* /
* /
public void delete ( String url , Object . . . urlVariables ) throws RestClientException {
public void delete ( String url , Object . . . urlVariables ) {
this . restTemplate . delete ( url , urlVariables ) ;
this . restTemplate . delete ( url , urlVariables ) ;
}
}
@ -635,22 +617,26 @@ public class TestRestTemplate {
* Delete the resources at the specified URI .
* Delete the resources at the specified URI .
* < p >
* < p >
* URI Template variables are expanded using the given map .
* URI Template variables are expanded using the given map .
* < p >
* If you need to assert the request result consider using the
* { @link TestRestTemplate # exchange exchange } method .
* @param url the URL
* @param url the URL
* @param urlVariables the variables to expand the template
* @param urlVariables the variables to expand the template
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # delete ( java . lang . String , java . util . Map )
* @see RestTemplate # delete ( java . lang . String , java . util . Map )
* /
* /
public void delete ( String url , Map < String , ? > urlVariables ) throws RestClientException {
public void delete ( String url , Map < String , ? > urlVariables ) {
this . restTemplate . delete ( url , urlVariables ) ;
this . restTemplate . delete ( url , urlVariables ) ;
}
}
/ * *
/ * *
* Delete the resources at the specified URL .
* Delete the resources at the specified URL .
* < p >
* If you need to assert the request result consider using the
* { @link TestRestTemplate # exchange exchange } method .
* @param url the URL
* @param url the URL
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # delete ( java . net . URI )
* @see RestTemplate # delete ( java . net . URI )
* /
* /
public void delete ( URI url ) throws RestClientException {
public void delete ( URI url ) {
this . restTemplate . delete ( applyRootUriIfNecessary ( url ) ) ;
this . restTemplate . delete ( applyRootUriIfNecessary ( url ) ) ;
}
}
@ -661,10 +647,9 @@ public class TestRestTemplate {
* @param url the URL
* @param url the URL
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @return the value of the allow header
* @return the value of the allow header
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # optionsForAllow ( java . lang . String , java . lang . Object [ ] )
* @see RestTemplate # optionsForAllow ( java . lang . String , java . lang . Object [ ] )
* /
* /
public Set < HttpMethod > optionsForAllow ( String url , Object . . . urlVariables ) throws RestClientException {
public Set < HttpMethod > optionsForAllow ( String url , Object . . . urlVariables ) {
return this . restTemplate . optionsForAllow ( url , urlVariables ) ;
return this . restTemplate . optionsForAllow ( url , urlVariables ) ;
}
}
@ -675,10 +660,9 @@ public class TestRestTemplate {
* @param url the URL
* @param url the URL
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @return the value of the allow header
* @return the value of the allow header
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # optionsForAllow ( java . lang . String , java . util . Map )
* @see RestTemplate # optionsForAllow ( java . lang . String , java . util . Map )
* /
* /
public Set < HttpMethod > optionsForAllow ( String url , Map < String , ? > urlVariables ) throws RestClientException {
public Set < HttpMethod > optionsForAllow ( String url , Map < String , ? > urlVariables ) {
return this . restTemplate . optionsForAllow ( url , urlVariables ) ;
return this . restTemplate . optionsForAllow ( url , urlVariables ) ;
}
}
@ -686,10 +670,9 @@ public class TestRestTemplate {
* Return the value of the Allow header for the given URL .
* Return the value of the Allow header for the given URL .
* @param url the URL
* @param url the URL
* @return the value of the allow header
* @return the value of the allow header
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # optionsForAllow ( java . net . URI )
* @see RestTemplate # optionsForAllow ( java . net . URI )
* /
* /
public Set < HttpMethod > optionsForAllow ( URI url ) throws RestClientException {
public Set < HttpMethod > optionsForAllow ( URI url ) {
return this . restTemplate . optionsForAllow ( applyRootUriIfNecessary ( url ) ) ;
return this . restTemplate . optionsForAllow ( applyRootUriIfNecessary ( url ) ) ;
}
}
@ -706,12 +689,11 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* org . springframework . http . HttpEntity , java . lang . Class , java . lang . Object [ ] )
* org . springframework . http . HttpEntity , java . lang . Class , java . lang . Object [ ] )
* /
* /
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
Class < T > responseType , Object . . . urlVariables ) throws RestClientException {
Class < T > responseType , Object . . . urlVariables ) {
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
}
}
@ -728,12 +710,11 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* org . springframework . http . HttpEntity , java . lang . Class , java . util . Map )
* org . springframework . http . HttpEntity , java . lang . Class , java . util . Map )
* /
* /
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
Class < T > responseType , Map < String , ? > urlVariables ) throws RestClientException {
Class < T > responseType , Map < String , ? > urlVariables ) {
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
}
}
@ -747,12 +728,11 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( java . net . URI , org . springframework . http . HttpMethod ,
* @see RestTemplate # exchange ( java . net . URI , org . springframework . http . HttpMethod ,
* org . springframework . http . HttpEntity , java . lang . Class )
* org . springframework . http . HttpEntity , java . lang . Class )
* /
* /
public < T > ResponseEntity < T > exchange ( URI url , HttpMethod method , HttpEntity < ? > requestEntity ,
public < T > ResponseEntity < T > exchange ( URI url , HttpMethod method , HttpEntity < ? > requestEntity ,
Class < T > responseType ) throws RestClientException {
Class < T > responseType ) {
return this . restTemplate . exchange ( applyRootUriIfNecessary ( url ) , method , requestEntity , responseType ) ;
return this . restTemplate . exchange ( applyRootUriIfNecessary ( url ) , method , requestEntity , responseType ) ;
}
}
@ -772,13 +752,12 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* org . springframework . http . HttpEntity ,
* org . springframework . http . HttpEntity ,
* org . springframework . core . ParameterizedTypeReference , java . lang . Object [ ] )
* org . springframework . core . ParameterizedTypeReference , java . lang . Object [ ] )
* /
* /
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
ParameterizedTypeReference < T > responseType , Object . . . urlVariables ) throws RestClientException {
ParameterizedTypeReference < T > responseType , Object . . . urlVariables ) {
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
}
}
@ -798,13 +777,12 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* @see RestTemplate # exchange ( java . lang . String , org . springframework . http . HttpMethod ,
* org . springframework . http . HttpEntity ,
* org . springframework . http . HttpEntity ,
* org . springframework . core . ParameterizedTypeReference , java . util . Map )
* org . springframework . core . ParameterizedTypeReference , java . util . Map )
* /
* /
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
public < T > ResponseEntity < T > exchange ( String url , HttpMethod method , HttpEntity < ? > requestEntity ,
ParameterizedTypeReference < T > responseType , Map < String , ? > urlVariables ) throws RestClientException {
ParameterizedTypeReference < T > responseType , Map < String , ? > urlVariables ) {
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
return this . restTemplate . exchange ( url , method , requestEntity , responseType , urlVariables ) ;
}
}
@ -823,13 +801,12 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( java . net . URI , org . springframework . http . HttpMethod ,
* @see RestTemplate # exchange ( java . net . URI , org . springframework . http . HttpMethod ,
* org . springframework . http . HttpEntity ,
* org . springframework . http . HttpEntity ,
* org . springframework . core . ParameterizedTypeReference )
* org . springframework . core . ParameterizedTypeReference )
* /
* /
public < T > ResponseEntity < T > exchange ( URI url , HttpMethod method , HttpEntity < ? > requestEntity ,
public < T > ResponseEntity < T > exchange ( URI url , HttpMethod method , HttpEntity < ? > requestEntity ,
ParameterizedTypeReference < T > responseType ) throws RestClientException {
ParameterizedTypeReference < T > responseType ) {
return this . restTemplate . exchange ( applyRootUriIfNecessary ( url ) , method , requestEntity , responseType ) ;
return this . restTemplate . exchange ( applyRootUriIfNecessary ( url ) , method , requestEntity , responseType ) ;
}
}
@ -845,11 +822,9 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( org . springframework . http . RequestEntity , java . lang . Class )
* @see RestTemplate # exchange ( org . springframework . http . RequestEntity , java . lang . Class )
* /
* /
public < T > ResponseEntity < T > exchange ( RequestEntity < ? > requestEntity , Class < T > responseType )
public < T > ResponseEntity < T > exchange ( RequestEntity < ? > requestEntity , Class < T > responseType ) {
throws RestClientException {
return this . restTemplate . exchange ( createRequestEntityWithRootAppliedUri ( requestEntity ) , responseType ) ;
return this . restTemplate . exchange ( createRequestEntityWithRootAppliedUri ( requestEntity ) , responseType ) ;
}
}
@ -866,12 +841,10 @@ public class TestRestTemplate {
* @param responseType the type of the return value
* @param responseType the type of the return value
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return the response as entity
* @return the response as entity
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # exchange ( org . springframework . http . RequestEntity ,
* @see RestTemplate # exchange ( org . springframework . http . RequestEntity ,
* org . springframework . core . ParameterizedTypeReference )
* org . springframework . core . ParameterizedTypeReference )
* /
* /
public < T > ResponseEntity < T > exchange ( RequestEntity < ? > requestEntity , ParameterizedTypeReference < T > responseType )
public < T > ResponseEntity < T > exchange ( RequestEntity < ? > requestEntity , ParameterizedTypeReference < T > responseType ) {
throws RestClientException {
return this . restTemplate . exchange ( createRequestEntityWithRootAppliedUri ( requestEntity ) , responseType ) ;
return this . restTemplate . exchange ( createRequestEntityWithRootAppliedUri ( requestEntity ) , responseType ) ;
}
}
@ -887,13 +860,12 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return an arbitrary object , as returned by the { @link ResponseExtractor }
* @return an arbitrary object , as returned by the { @link ResponseExtractor }
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # execute ( java . lang . String , org . springframework . http . HttpMethod ,
* @see RestTemplate # execute ( java . lang . String , org . springframework . http . HttpMethod ,
* org . springframework . web . client . RequestCallback ,
* org . springframework . web . client . RequestCallback ,
* org . springframework . web . client . ResponseExtractor , java . lang . Object [ ] )
* org . springframework . web . client . ResponseExtractor , java . lang . Object [ ] )
* /
* /
public < T > T execute ( String url , HttpMethod method , RequestCallback requestCallback ,
public < T > T execute ( String url , HttpMethod method , RequestCallback requestCallback ,
ResponseExtractor < T > responseExtractor , Object . . . urlVariables ) throws RestClientException {
ResponseExtractor < T > responseExtractor , Object . . . urlVariables ) {
return this . restTemplate . execute ( url , method , requestCallback , responseExtractor , urlVariables ) ;
return this . restTemplate . execute ( url , method , requestCallback , responseExtractor , urlVariables ) ;
}
}
@ -909,13 +881,12 @@ public class TestRestTemplate {
* @param urlVariables the variables to expand in the template
* @param urlVariables the variables to expand in the template
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return an arbitrary object , as returned by the { @link ResponseExtractor }
* @return an arbitrary object , as returned by the { @link ResponseExtractor }
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # execute ( java . lang . String , org . springframework . http . HttpMethod ,
* @see RestTemplate # execute ( java . lang . String , org . springframework . http . HttpMethod ,
* org . springframework . web . client . RequestCallback ,
* org . springframework . web . client . RequestCallback ,
* org . springframework . web . client . ResponseExtractor , java . util . Map )
* org . springframework . web . client . ResponseExtractor , java . util . Map )
* /
* /
public < T > T execute ( String url , HttpMethod method , RequestCallback requestCallback ,
public < T > T execute ( String url , HttpMethod method , RequestCallback requestCallback ,
ResponseExtractor < T > responseExtractor , Map < String , ? > urlVariables ) throws RestClientException {
ResponseExtractor < T > responseExtractor , Map < String , ? > urlVariables ) {
return this . restTemplate . execute ( url , method , requestCallback , responseExtractor , urlVariables ) ;
return this . restTemplate . execute ( url , method , requestCallback , responseExtractor , urlVariables ) ;
}
}
@ -928,13 +899,12 @@ public class TestRestTemplate {
* @param responseExtractor object that extracts the return value from the response
* @param responseExtractor object that extracts the return value from the response
* @param < T > the type of the return value
* @param < T > the type of the return value
* @return an arbitrary object , as returned by the { @link ResponseExtractor }
* @return an arbitrary object , as returned by the { @link ResponseExtractor }
* @throws RestClientException on client - side HTTP error
* @see RestTemplate # execute ( java . net . URI , org . springframework . http . HttpMethod ,
* @see RestTemplate # execute ( java . net . URI , org . springframework . http . HttpMethod ,
* org . springframework . web . client . RequestCallback ,
* org . springframework . web . client . RequestCallback ,
* org . springframework . web . client . ResponseExtractor )
* org . springframework . web . client . ResponseExtractor )
* /
* /
public < T > T execute ( URI url , HttpMethod method , RequestCallback requestCallback ,
public < T > T execute ( URI url , HttpMethod method , RequestCallback requestCallback ,
ResponseExtractor < T > responseExtractor ) throws RestClientException {
ResponseExtractor < T > responseExtractor ) {
return this . restTemplate . execute ( applyRootUriIfNecessary ( url ) , method , requestCallback , responseExtractor ) ;
return this . restTemplate . execute ( applyRootUriIfNecessary ( url ) , method , requestCallback , responseExtractor ) ;
}
}