From 13791cad53c4f8f341d74f5a4658af92821d6c7a Mon Sep 17 00:00:00 2001 From: Andy Wilkinson Date: Thu, 9 Feb 2017 14:00:53 +0000 Subject: [PATCH] Use DefaultUriBuilderFactory instead of DefaultUriTemplateHandler Closes gh-8247 --- .../test/web/client/LocalHostUriTemplateHandler.java | 9 +++++---- .../boot/test/web/client/TestRestTemplate.java | 4 ++-- .../boot/test/web/client/TestRestTemplateTests.java | 8 ++++---- .../boot/web/client/RootUriTemplateHandler.java | 6 +++--- 4 files changed, 14 insertions(+), 13 deletions(-) diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandler.java b/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandler.java index bcc48bb33e..1658597457 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandler.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/LocalHostUriTemplateHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,7 +20,7 @@ import org.springframework.boot.bind.RelaxedPropertyResolver; import org.springframework.boot.web.client.RootUriTemplateHandler; import org.springframework.core.env.Environment; import org.springframework.util.Assert; -import org.springframework.web.util.DefaultUriTemplateHandler; +import org.springframework.web.util.DefaultUriBuilderFactory; import org.springframework.web.util.UriTemplateHandler; /** @@ -58,12 +58,13 @@ public class LocalHostUriTemplateHandler extends RootUriTemplateHandler { * @since 1.4.1 */ public LocalHostUriTemplateHandler(Environment environment, String scheme) { - super(new DefaultUriTemplateHandler()); + super(new DefaultUriBuilderFactory()); Assert.notNull(environment, "Environment must not be null"); Assert.notNull(scheme, "Scheme must not be null"); this.environment = environment; this.scheme = scheme; - this.servletPropertyResolver = new RelaxedPropertyResolver(environment, "server.servlet."); + this.servletPropertyResolver = new RelaxedPropertyResolver(environment, + "server.servlet."); } @Override diff --git a/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java b/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java index f205f4414f..2ddca34889 100644 --- a/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java +++ b/spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java @@ -57,7 +57,7 @@ import org.springframework.web.client.RequestCallback; import org.springframework.web.client.ResponseExtractor; import org.springframework.web.client.RestClientException; import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.DefaultUriTemplateHandler; +import org.springframework.web.util.DefaultUriBuilderFactory; import org.springframework.web.util.UriTemplateHandler; /** @@ -161,7 +161,7 @@ public class TestRestTemplate { /** * Configure the {@link UriTemplateHandler} to use to expand URI templates. By default - * the {@link DefaultUriTemplateHandler} is used which relies on Spring's URI template + * the {@link DefaultUriBuilderFactory} is used which relies on Spring's URI template * support and exposes several useful properties that customize its behavior for * encoding and for prepending a common base URL. An alternative implementation may be * used to plug an external URI template library. diff --git a/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java b/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java index 030f93a493..3ac0a6fca9 100644 --- a/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java +++ b/spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java @@ -47,12 +47,12 @@ import org.springframework.util.ReflectionUtils.MethodCallback; import org.springframework.web.client.ResponseErrorHandler; import org.springframework.web.client.RestOperations; import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.DefaultUriTemplateHandler; +import org.springframework.web.util.DefaultUriBuilderFactory; import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.ArgumentMatchers.eq; import static org.mockito.BDDMockito.given; -import static org.mockito.Matchers.any; -import static org.mockito.Matchers.eq; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; @@ -102,7 +102,7 @@ public class TestRestTemplateTests { public void restOperationsAreAvailable() throws Exception { RestTemplate delegate = mock(RestTemplate.class); given(delegate.getUriTemplateHandler()) - .willReturn(new DefaultUriTemplateHandler()); + .willReturn(new DefaultUriBuilderFactory()); final TestRestTemplate restTemplate = new TestRestTemplate(delegate); ReflectionUtils.doWithMethods(RestOperations.class, new MethodCallback() { diff --git a/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java b/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java index 0defbeec78..c8c8f31e25 100644 --- a/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java +++ b/spring-boot/src/main/java/org/springframework/boot/web/client/RootUriTemplateHandler.java @@ -1,5 +1,5 @@ /* - * Copyright 2012-2016 the original author or authors. + * Copyright 2012-2017 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import java.util.Map; import org.springframework.util.Assert; import org.springframework.util.StringUtils; import org.springframework.web.client.RestTemplate; -import org.springframework.web.util.DefaultUriTemplateHandler; +import org.springframework.web.util.DefaultUriBuilderFactory; import org.springframework.web.util.UriTemplateHandler; /** @@ -47,7 +47,7 @@ public class RootUriTemplateHandler implements UriTemplateHandler { * @param rootUri the root URI to be used to prefix relative URLs */ public RootUriTemplateHandler(String rootUri) { - this(rootUri, new DefaultUriTemplateHandler()); + this(rootUri, new DefaultUriBuilderFactory()); } /**