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
31af68a9
Commit
31af68a9
authored
Aug 08, 2013
by
Biju Kunjummen
Committed by
Dave Syer
Aug 09, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added a Spring MVC test for the Sample MessageController
parent
0e798a32
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
MessageControllerWebTest.java
...ingframework/boot/sample/ui/MessageControllerWebTest.java
+55
-0
No files found.
spring-boot-samples/spring-boot-sample-web-ui/src/test/java/org/springframework/boot/sample/ui/MessageControllerWebTest.java
0 → 100644
View file @
31af68a9
package
org
.
springframework
.
boot
.
sample
.
ui
;
import
org.junit.Before
;
import
org.junit.Test
;
import
org.junit.runner.RunWith
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.test.context.ContextConfiguration
;
import
org.springframework.test.context.junit4.SpringJUnit4ClassRunner
;
import
org.springframework.test.context.web.WebAppConfiguration
;
import
org.springframework.test.web.servlet.MockMvc
;
import
org.springframework.test.web.servlet.setup.MockMvcBuilders
;
import
org.springframework.web.context.WebApplicationContext
;
import
static
org
.
hamcrest
.
Matchers
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
request
.
MockMvcRequestBuilders
.*;
import
static
org
.
springframework
.
test
.
web
.
servlet
.
result
.
MockMvcResultMatchers
.*;
/**
* A Basic Spring MVC Test for the Sample Controller"
*
* @author Biju Kunjummen
*/
@RunWith
(
SpringJUnit4ClassRunner
.
class
)
@WebAppConfiguration
@ContextConfiguration
(
classes
=
SampleWebUiApplication
.
class
)
public
class
MessageControllerWebTest
{
@Autowired
private
WebApplicationContext
wac
;
private
MockMvc
mockMvc
;
@Before
public
void
setup
()
{
this
.
mockMvc
=
MockMvcBuilders
.
webAppContextSetup
(
this
.
wac
).
build
();
}
@Test
public
void
testHome
()
throws
Exception
{
this
.
mockMvc
.
perform
(
get
(
"/"
))
.
andExpect
(
status
().
isOk
())
.
andExpect
(
content
().
string
(
containsString
(
"<title>Messages"
)));
}
@Test
public
void
testCreate
()
throws
Exception
{
this
.
mockMvc
.
perform
(
post
(
"/"
).
param
(
"text"
,
"FOO text"
).
param
(
"summary"
,
"FOO"
))
.
andExpect
(
status
().
isMovedTemporarily
())
.
andExpect
(
header
().
string
(
"location"
,
"/1"
));
}
}
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