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
9f532b65
Commit
9f532b65
authored
Mar 18, 2014
by
Dave Syer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add docs for RestTemplates test utils
Fixes gh-500
parent
879b31f3
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
spring-boot-features.adoc
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
+28
-0
No files found.
spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc
View file @
9f532b65
...
@@ -1525,6 +1525,34 @@ public class MyTest {
...
@@ -1525,6 +1525,34 @@ public class MyTest {
}
}
----
----
[[boot-features-rest-templates-test-utility]]
==== RestTemplates
`RestTemplates` is a static convenience factory for instances of
`RestTemplate` that are useful in integration tests. You can get a
vanilla template or one that sends Basic HTTP authentication (with a
username and password). And in either case the template will behave in
a friendly way for testing, not following redirects (so you can assert
the response location), ignoring cookies (so the template is
stateless), and not throwing exceptions on server-side errors. It is
recommended, but not mandatory, to use Apache HTTP Client (version
4.3.2 or better), and if you have that on your classpath the
`RestTemplates` will respond by configuring the client appropriately.
[source,java,indent=0]
----
public class MyTest {
RestTemplate template = RestTemplates.get();
@Test
public void testRequest() throws Exception {
HttpHeaders headers = template.getForEntity("http://myhost.com", String.class).getHeaders();
assertThat(headers.getLocation().toString(), containsString("myotherhost"));
}
}
----
[[boot-features-developing-auto-configuration]]
[[boot-features-developing-auto-configuration]]
...
...
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