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
53d7fd5a
Commit
53d7fd5a
authored
Aug 20, 2016
by
Maciej Walkowiak
Committed by
Andy Wilkinson
Aug 22, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add constructor to TestRestTemplate that takes a RestTemplateBuilder
Closes gh-6706 See gh-6702
parent
6cb18835
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
0 deletions
+24
-0
TestRestTemplate.java
...pringframework/boot/test/web/client/TestRestTemplate.java
+13
-0
TestRestTemplateTests.java
...framework/boot/test/web/client/TestRestTemplateTests.java
+11
-0
No files found.
spring-boot-test/src/main/java/org/springframework/boot/test/web/client/TestRestTemplate.java
View file @
53d7fd5a
...
@@ -82,6 +82,19 @@ public class TestRestTemplate {
...
@@ -82,6 +82,19 @@ public class TestRestTemplate {
private
final
RestTemplate
restTemplate
;
private
final
RestTemplate
restTemplate
;
/**
* Create a new {@link TestRestTemplate} instance.
* @param restTemplateBuilder builder used to configure underlying {@link RestTemplate}
*/
public
TestRestTemplate
(
RestTemplateBuilder
restTemplateBuilder
)
{
this
(
buildRestTemplate
(
restTemplateBuilder
));
}
private
static
RestTemplate
buildRestTemplate
(
RestTemplateBuilder
restTemplateBuilder
)
{
Assert
.
notNull
(
restTemplateBuilder
,
"RestTemplateBuilder must not be null"
);
return
restTemplateBuilder
.
build
();
}
/**
/**
* 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
...
...
spring-boot-test/src/test/java/org/springframework/boot/test/web/client/TestRestTemplateTests.java
View file @
53d7fd5a
...
@@ -24,6 +24,7 @@ import org.junit.Test;
...
@@ -24,6 +24,7 @@ import org.junit.Test;
import
org.springframework.boot.test.web.client.TestRestTemplate.CustomHttpComponentsClientHttpRequestFactory
;
import
org.springframework.boot.test.web.client.TestRestTemplate.CustomHttpComponentsClientHttpRequestFactory
;
import
org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption
;
import
org.springframework.boot.test.web.client.TestRestTemplate.HttpClientOption
;
import
org.springframework.boot.web.client.RestTemplateBuilder
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.HttpMethod
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.HttpComponentsClientHttpRequestFactory
;
import
org.springframework.http.client.InterceptingClientHttpRequestFactory
;
import
org.springframework.http.client.InterceptingClientHttpRequestFactory
;
...
@@ -33,6 +34,7 @@ import org.springframework.web.client.RestOperations;
...
@@ -33,6 +34,7 @@ import org.springframework.web.client.RestOperations;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.client.RestTemplate
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
assertj
.
core
.
api
.
Assertions
.
assertThat
;
import
static
org
.
mockito
.
BDDMockito
.
given
;
import
static
org
.
mockito
.
Mockito
.
mock
;
import
static
org
.
mockito
.
Mockito
.
mock
;
/**
/**
...
@@ -43,6 +45,15 @@ import static org.mockito.Mockito.mock;
...
@@ -43,6 +45,15 @@ import static org.mockito.Mockito.mock;
*/
*/
public
class
TestRestTemplateTests
{
public
class
TestRestTemplateTests
{
@Test
public
void
fromRestTemplateBuilder
()
{
RestTemplateBuilder
builder
=
mock
(
RestTemplateBuilder
.
class
);
RestTemplate
delegate
=
new
RestTemplate
();
given
(
builder
.
build
()).
willReturn
(
delegate
);
assertThat
(
new
TestRestTemplate
(
builder
).
getRestTemplate
())
.
isEqualTo
(
delegate
);
}
@Test
@Test
public
void
simple
()
{
public
void
simple
()
{
// The Apache client is on the classpath so we get the fully-fledged factory
// The Apache client is on the classpath so we get the fully-fledged factory
...
...
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