Remove the few remaining usages of UriTemplate

Also update Javadoc of UriTemplate to point to UriComponentsBuilder and
UriBuilderFactory as more flexible options.

See gh-24094
This commit is contained in:
Rossen Stoyanchev
2019-11-28 11:28:49 +00:00
parent df2ed75df0
commit b44daa8b71
7 changed files with 38 additions and 29 deletions

View File

@@ -27,7 +27,7 @@ import java.util.Map;
import org.junit.jupiter.api.Test;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.web.util.UriTemplate;
import org.springframework.web.util.UriComponentsBuilder;
import static org.assertj.core.api.Assertions.assertThat;
@@ -58,7 +58,7 @@ public class RequestEntityTests {
@Test
public void uriVariablesExpansion() throws URISyntaxException {
URI uri = new UriTemplate("https://example.com/{foo}").expand("bar");
URI uri = UriComponentsBuilder.fromUriString("https://example.com/{foo}").buildAndExpand("bar").toUri();
RequestEntity.get(uri).accept(MediaType.TEXT_PLAIN).build();
String url = "https://www.{host}.com/{path}";
@@ -66,7 +66,7 @@ public class RequestEntityTests {
String path = "foo/bar";
URI expected = new URI("https://www.example.com/foo/bar");
uri = new UriTemplate(url).expand(host, path);
uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(host, path).toUri();
RequestEntity<?> entity = RequestEntity.get(uri).build();
assertThat(entity.getUrl()).isEqualTo(expected);
@@ -74,7 +74,7 @@ public class RequestEntityTests {
uriVariables.put("host", host);
uriVariables.put("path", path);
uri = new UriTemplate(url).expand(uriVariables);
uri = UriComponentsBuilder.fromUriString(url).buildAndExpand(uriVariables).toUri();
entity = RequestEntity.get(uri).build();
assertThat(entity.getUrl()).isEqualTo(expected);
}