Polishing
This commit is contained in:
@@ -259,7 +259,8 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Assert.isTrue(uriComponents.getPath().startsWith(this.contextPath),
|
Assert.isTrue(uriComponents.getPath().startsWith(this.contextPath),
|
||||||
() -> uriComponents.getPath() + " should start with contextPath " + this.contextPath);
|
() -> "\"" + uriComponents.getPath() +
|
||||||
|
"\" should start with context path \"" + this.contextPath + "\"");
|
||||||
request.setContextPath(this.contextPath);
|
request.setContextPath(this.contextPath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -273,7 +274,8 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
|||||||
while (tokens.hasMoreTokens()) {
|
while (tokens.hasMoreTokens()) {
|
||||||
String cookieName = tokens.nextToken().trim();
|
String cookieName = tokens.nextToken().trim();
|
||||||
Assert.isTrue(tokens.hasMoreTokens(),
|
Assert.isTrue(tokens.hasMoreTokens(),
|
||||||
() -> "Expected value for cookie name '" + cookieName + "'. Full cookie was " + cookieHeaderValue);
|
() -> "Expected value for cookie name '" + cookieName +
|
||||||
|
"': full cookie header was [" + cookieHeaderValue + "]");
|
||||||
String cookieValue = tokens.nextToken().trim();
|
String cookieValue = tokens.nextToken().trim();
|
||||||
processCookie(request, cookies, new Cookie(cookieName, cookieValue));
|
processCookie(request, cookies, new Cookie(cookieName, cookieValue));
|
||||||
}
|
}
|
||||||
@@ -384,7 +386,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
|
|||||||
|
|
||||||
private Locale parseLocale(String locale) {
|
private Locale parseLocale(String locale) {
|
||||||
Matcher matcher = LOCALE_PATTERN.matcher(locale);
|
Matcher matcher = LOCALE_PATTERN.matcher(locale);
|
||||||
Assert.isTrue(matcher.matches(), () -> "Invalid locale " + locale);
|
Assert.isTrue(matcher.matches(), () -> "Invalid locale value [" + locale + "]");
|
||||||
String language = matcher.group(1);
|
String language = matcher.group(1);
|
||||||
String country = matcher.group(2);
|
String country = matcher.group(2);
|
||||||
if (country == null) {
|
if (country == null) {
|
||||||
|
|||||||
@@ -72,7 +72,6 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
|
|||||||
public ClientHttpRequestFactory clientHttpRequestFactory;
|
public ClientHttpRequestFactory clientHttpRequestFactory;
|
||||||
|
|
||||||
@Parameters
|
@Parameters
|
||||||
@SuppressWarnings("deprecation")
|
|
||||||
public static Iterable<? extends ClientHttpRequestFactory> data() {
|
public static Iterable<? extends ClientHttpRequestFactory> data() {
|
||||||
return Arrays.asList(
|
return Arrays.asList(
|
||||||
new SimpleClientHttpRequestFactory(),
|
new SimpleClientHttpRequestFactory(),
|
||||||
|
|||||||
@@ -146,7 +146,7 @@ public class RestTemplateTests {
|
|||||||
verify(response).close();
|
verify(response).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test // SPR-15201
|
@Test // SPR-15201
|
||||||
public void uriTemplateWithTrailingSlash() throws Exception {
|
public void uriTemplateWithTrailingSlash() throws Exception {
|
||||||
String url = "http://example.com/spring/";
|
String url = "http://example.com/spring/";
|
||||||
given(requestFactory.createRequest(new URI(url), HttpMethod.GET)).willReturn(request);
|
given(requestFactory.createRequest(new URI(url), HttpMethod.GET)).willReturn(request);
|
||||||
@@ -280,7 +280,6 @@ public class RestTemplateTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void getForObjectWithCustomUriTemplateHandler() throws Exception {
|
public void getForObjectWithCustomUriTemplateHandler() throws Exception {
|
||||||
|
|
||||||
DefaultUriBuilderFactory uriTemplateHandler = new DefaultUriBuilderFactory();
|
DefaultUriBuilderFactory uriTemplateHandler = new DefaultUriBuilderFactory();
|
||||||
template.setUriTemplateHandler(uriTemplateHandler);
|
template.setUriTemplateHandler(uriTemplateHandler);
|
||||||
|
|
||||||
@@ -306,7 +305,6 @@ public class RestTemplateTests {
|
|||||||
verify(response).close();
|
verify(response).close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void headForHeaders() throws Exception {
|
public void headForHeaders() throws Exception {
|
||||||
given(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.HEAD)).willReturn(request);
|
given(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.HEAD)).willReturn(request);
|
||||||
|
|||||||
Reference in New Issue
Block a user