Provide access to root URI from TestRestTemplate
Closes gh-10641
This commit is contained in:
@@ -78,6 +78,7 @@ import org.springframework.web.util.UriTemplateHandler;
|
||||
* @author Dave Syer
|
||||
* @author Phillip Webb
|
||||
* @author Andy Wilkinson
|
||||
* @author Kristine Jetzke
|
||||
* @since 1.4.0
|
||||
*/
|
||||
public class TestRestTemplate {
|
||||
@@ -165,6 +166,15 @@ public class TestRestTemplate {
|
||||
this.restTemplate.setUriTemplateHandler(handler);
|
||||
}
|
||||
|
||||
public String getRootUri() {
|
||||
UriTemplateHandler uriTemplateHandler = this.restTemplate.getUriTemplateHandler();
|
||||
if (RootUriTemplateHandler.class
|
||||
.isAssignableFrom(uriTemplateHandler.getClass())) {
|
||||
return ((RootUriTemplateHandler) uriTemplateHandler).getRootUri();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve a representation by doing a GET on the specified URL. The response (if
|
||||
* any) is converted and returned.
|
||||
|
||||
Reference in New Issue
Block a user