Polishing

This commit is contained in:
Juergen Hoeller 2017-03-07 11:02:26 +01:00
parent 2f85cbf0d9
commit 9aaed2bcef
3 changed files with 6 additions and 7 deletions

View File

@ -259,7 +259,8 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
}
else {
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);
}
}
@ -273,7 +274,8 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
while (tokens.hasMoreTokens()) {
String cookieName = tokens.nextToken().trim();
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();
processCookie(request, cookies, new Cookie(cookieName, cookieValue));
}
@ -384,7 +386,7 @@ final class HtmlUnitRequestBuilder implements RequestBuilder, Mergeable {
private Locale parseLocale(String 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 country = matcher.group(2);
if (country == null) {

View File

@ -72,7 +72,6 @@ public class RestTemplateIntegrationTests extends AbstractMockWebServerTestCase
public ClientHttpRequestFactory clientHttpRequestFactory;
@Parameters
@SuppressWarnings("deprecation")
public static Iterable<? extends ClientHttpRequestFactory> data() {
return Arrays.asList(
new SimpleClientHttpRequestFactory(),

View File

@ -146,7 +146,7 @@ public class RestTemplateTests {
verify(response).close();
}
@Test // SPR-15201
@Test // SPR-15201
public void uriTemplateWithTrailingSlash() throws Exception {
String url = "http://example.com/spring/";
given(requestFactory.createRequest(new URI(url), HttpMethod.GET)).willReturn(request);
@ -280,7 +280,6 @@ public class RestTemplateTests {
@Test
public void getForObjectWithCustomUriTemplateHandler() throws Exception {
DefaultUriBuilderFactory uriTemplateHandler = new DefaultUriBuilderFactory();
template.setUriTemplateHandler(uriTemplateHandler);
@ -306,7 +305,6 @@ public class RestTemplateTests {
verify(response).close();
}
@Test
public void headForHeaders() throws Exception {
given(requestFactory.createRequest(new URI("http://example.com"), HttpMethod.HEAD)).willReturn(request);