Browse Source

Rename HtppClientOption to HttpClientOption

Fixes gh-1874
pull/2035/head
Phillip Webb 11 years ago
parent
commit
a832944c05
  1. 15
      spring-boot/src/main/java/org/springframework/boot/test/TestRestTemplate.java
  2. 5
      spring-boot/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java

15
spring-boot/src/main/java/org/springframework/boot/test/TestRestTemplate.java

@ -55,7 +55,7 @@ public class TestRestTemplate extends RestTemplate { @@ -55,7 +55,7 @@ public class TestRestTemplate extends RestTemplate {
* Create a new {@link TestRestTemplate} instance.
* @param httpClientOptions client options to use if the Apache HTTP Client is used
*/
public TestRestTemplate(HtppClientOption... httpClientOptions) {
public TestRestTemplate(HttpClientOption... httpClientOptions) {
this(null, null, httpClientOptions);
}
@ -66,7 +66,7 @@ public class TestRestTemplate extends RestTemplate { @@ -66,7 +66,7 @@ public class TestRestTemplate extends RestTemplate {
* @param httpClientOptions client options to use if the Apache HTTP Client is used
*/
public TestRestTemplate(String username, String password,
HtppClientOption... httpClientOptions) {
HttpClientOption... httpClientOptions) {
if (ClassUtils.isPresent("org.apache.http.client.config.RequestConfig", null)) {
setRequestFactory(new CustomHttpComponentsClientHttpRequestFactory(
httpClientOptions));
@ -94,7 +94,7 @@ public class TestRestTemplate extends RestTemplate { @@ -94,7 +94,7 @@ public class TestRestTemplate extends RestTemplate {
/**
* Options used to customize the Apache Http Client if it is used.
*/
public static enum HtppClientOption {
public static enum HttpClientOption {
/**
* Enable cookies.
@ -139,12 +139,12 @@ public class TestRestTemplate extends RestTemplate { @@ -139,12 +139,12 @@ public class TestRestTemplate extends RestTemplate {
private final boolean enableRedirects;
public CustomHttpComponentsClientHttpRequestFactory(
HtppClientOption[] httpClientOptions) {
Set<HtppClientOption> options = new HashSet<TestRestTemplate.HtppClientOption>(
HttpClientOption[] httpClientOptions) {
Set<HttpClientOption> options = new HashSet<TestRestTemplate.HttpClientOption>(
Arrays.asList(httpClientOptions));
this.cookieSpec = (options.contains(HtppClientOption.ENABLE_COOKIES) ? CookieSpecs.STANDARD
this.cookieSpec = (options.contains(HttpClientOption.ENABLE_COOKIES) ? CookieSpecs.STANDARD
: CookieSpecs.IGNORE_COOKIES);
this.enableRedirects = options.contains(HtppClientOption.ENABLE_REDIRECTS);
this.enableRedirects = options.contains(HttpClientOption.ENABLE_REDIRECTS);
}
@Override
@ -162,4 +162,5 @@ public class TestRestTemplate extends RestTemplate { @@ -162,4 +162,5 @@ public class TestRestTemplate extends RestTemplate {
}
}
}

5
spring-boot/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java

@ -19,7 +19,7 @@ package org.springframework.boot.test; @@ -19,7 +19,7 @@ package org.springframework.boot.test;
import org.apache.http.client.config.RequestConfig;
import org.junit.Test;
import org.springframework.boot.test.TestRestTemplate.CustomHttpComponentsClientHttpRequestFactory;
import org.springframework.boot.test.TestRestTemplate.HtppClientOption;
import org.springframework.boot.test.TestRestTemplate.HttpClientOption;
import org.springframework.http.client.HttpComponentsClientHttpRequestFactory;
import org.springframework.http.client.InterceptingClientHttpRequestFactory;
@ -49,10 +49,11 @@ public class TestRestTemplateTests { @@ -49,10 +49,11 @@ public class TestRestTemplateTests {
@Test
public void options() throws Exception {
TestRestTemplate template = new TestRestTemplate(
HtppClientOption.ENABLE_REDIRECTS);
HttpClientOption.ENABLE_REDIRECTS);
CustomHttpComponentsClientHttpRequestFactory factory = (CustomHttpComponentsClientHttpRequestFactory) template
.getRequestFactory();
RequestConfig config = factory.getRequestConfig();
assertThat(config.isRedirectsEnabled(), equalTo(true));
}
}

Loading…
Cancel
Save