Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
spring-boot
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
DEMO
spring-boot
Commits
ff6a146c
Commit
ff6a146c
authored
Nov 11, 2014
by
Andy Wilkinson
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '1.1.x'
parents
67709607
a832944c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
9 deletions
+11
-9
TestRestTemplate.java
.../java/org/springframework/boot/test/TestRestTemplate.java
+8
-7
TestRestTemplateTests.java
.../org/springframework/boot/test/TestRestTemplateTests.java
+3
-2
No files found.
spring-boot/src/main/java/org/springframework/boot/test/TestRestTemplate.java
View file @
ff6a146c
...
@@ -55,7 +55,7 @@ public class TestRestTemplate extends RestTemplate {
...
@@ -55,7 +55,7 @@ public class TestRestTemplate extends RestTemplate {
* Create a new {@link TestRestTemplate} instance.
* Create a new {@link TestRestTemplate} instance.
* @param httpClientOptions client options to use if the Apache HTTP Client is used
* @param httpClientOptions client options to use if the Apache HTTP Client is used
*/
*/
public
TestRestTemplate
(
Ht
p
pClientOption
...
httpClientOptions
)
{
public
TestRestTemplate
(
Ht
t
pClientOption
...
httpClientOptions
)
{
this
(
null
,
null
,
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
* @param httpClientOptions client options to use if the Apache HTTP Client is used
*/
*/
public
TestRestTemplate
(
String
username
,
String
password
,
public
TestRestTemplate
(
String
username
,
String
password
,
Ht
p
pClientOption
...
httpClientOptions
)
{
Ht
t
pClientOption
...
httpClientOptions
)
{
if
(
ClassUtils
.
isPresent
(
"org.apache.http.client.config.RequestConfig"
,
null
))
{
if
(
ClassUtils
.
isPresent
(
"org.apache.http.client.config.RequestConfig"
,
null
))
{
setRequestFactory
(
new
CustomHttpComponentsClientHttpRequestFactory
(
setRequestFactory
(
new
CustomHttpComponentsClientHttpRequestFactory
(
httpClientOptions
));
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.
* Options used to customize the Apache Http Client if it is used.
*/
*/
public
static
enum
Ht
p
pClientOption
{
public
static
enum
Ht
t
pClientOption
{
/**
/**
* Enable cookies.
* Enable cookies.
...
@@ -139,12 +139,12 @@ public class TestRestTemplate extends RestTemplate {
...
@@ -139,12 +139,12 @@ public class TestRestTemplate extends RestTemplate {
private
final
boolean
enableRedirects
;
private
final
boolean
enableRedirects
;
public
CustomHttpComponentsClientHttpRequestFactory
(
public
CustomHttpComponentsClientHttpRequestFactory
(
Ht
p
pClientOption
[]
httpClientOptions
)
{
Ht
t
pClientOption
[]
httpClientOptions
)
{
Set
<
Ht
ppClientOption
>
options
=
new
HashSet
<
TestRestTemplate
.
Htp
pClientOption
>(
Set
<
Ht
tpClientOption
>
options
=
new
HashSet
<
TestRestTemplate
.
Htt
pClientOption
>(
Arrays
.
asList
(
httpClientOptions
));
Arrays
.
asList
(
httpClientOptions
));
this
.
cookieSpec
=
(
options
.
contains
(
Ht
p
pClientOption
.
ENABLE_COOKIES
)
?
CookieSpecs
.
STANDARD
this
.
cookieSpec
=
(
options
.
contains
(
Ht
t
pClientOption
.
ENABLE_COOKIES
)
?
CookieSpecs
.
STANDARD
:
CookieSpecs
.
IGNORE_COOKIES
);
:
CookieSpecs
.
IGNORE_COOKIES
);
this
.
enableRedirects
=
options
.
contains
(
Ht
p
pClientOption
.
ENABLE_REDIRECTS
);
this
.
enableRedirects
=
options
.
contains
(
Ht
t
pClientOption
.
ENABLE_REDIRECTS
);
}
}
@Override
@Override
...
@@ -162,4 +162,5 @@ public class TestRestTemplate extends RestTemplate {
...
@@ -162,4 +162,5 @@ public class TestRestTemplate extends RestTemplate {
}
}
}
}
}
}
spring-boot/src/test/java/org/springframework/boot/test/TestRestTemplateTests.java
View file @
ff6a146c
...
@@ -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.apache.http.client.config.RequestConfig
;
import
org.junit.Test
;
import
org.junit.Test
;
import
org.springframework.boot.test.TestRestTemplate.CustomHttpComponentsClientHttpRequestFactory
;
import
org.springframework.boot.test.TestRestTemplate.CustomHttpComponentsClientHttpRequestFactory
;
import
org.springframework.boot.test.TestRestTemplate.Ht
p
pClientOption
;
import
org.springframework.boot.test.TestRestTemplate.Ht
t
pClientOption
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.InterceptingClientHttpRequestFactory
;
import
org.springframework.http.client.InterceptingClientHttpRequestFactory
;
...
@@ -49,10 +49,11 @@ public class TestRestTemplateTests {
...
@@ -49,10 +49,11 @@ public class TestRestTemplateTests {
@Test
@Test
public
void
options
()
throws
Exception
{
public
void
options
()
throws
Exception
{
TestRestTemplate
template
=
new
TestRestTemplate
(
TestRestTemplate
template
=
new
TestRestTemplate
(
Ht
p
pClientOption
.
ENABLE_REDIRECTS
);
Ht
t
pClientOption
.
ENABLE_REDIRECTS
);
CustomHttpComponentsClientHttpRequestFactory
factory
=
(
CustomHttpComponentsClientHttpRequestFactory
)
template
CustomHttpComponentsClientHttpRequestFactory
factory
=
(
CustomHttpComponentsClientHttpRequestFactory
)
template
.
getRequestFactory
();
.
getRequestFactory
();
RequestConfig
config
=
factory
.
getRequestConfig
();
RequestConfig
config
=
factory
.
getRequestConfig
();
assertThat
(
config
.
isRedirectsEnabled
(),
equalTo
(
true
));
assertThat
(
config
.
isRedirectsEnabled
(),
equalTo
(
true
));
}
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment