mirror of
https://github.com/spring-projects/spring-boot.git
synced 2024-09-03 04:26:12 +08:00
Add validation test to ws sample
Fixes gh-481
This commit is contained in:
parent
d82a728efe
commit
ba9f92e74f
8
spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/ui/MessageControllerWebTests.java
Normal file → Executable file
8
spring-boot-samples/spring-boot-sample-web-ui/src/test/java/sample/ui/MessageControllerWebTests.java
Normal file → Executable file
@ -26,6 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
|
|||||||
* A Basic Spring MVC Test for the Sample Controller"
|
* A Basic Spring MVC Test for the Sample Controller"
|
||||||
*
|
*
|
||||||
* @author Biju Kunjummen
|
* @author Biju Kunjummen
|
||||||
|
* @author Doo-Hwan, Kwak
|
||||||
*/
|
*/
|
||||||
@RunWith(SpringJUnit4ClassRunner.class)
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
@WebAppConfiguration
|
@WebAppConfiguration
|
||||||
@ -55,6 +56,13 @@ public class MessageControllerWebTests {
|
|||||||
.andExpect(header().string("location", RegexMatcher.matches("/[0-9]+")));
|
.andExpect(header().string("location", RegexMatcher.matches("/[0-9]+")));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateValidation() throws Exception{
|
||||||
|
this.mockMvc.perform(post("/").param("text", "").param("summary", ""))
|
||||||
|
.andExpect(status().isOk())
|
||||||
|
.andExpect(content().string(containsString("is required")));
|
||||||
|
}
|
||||||
|
|
||||||
private static class RegexMatcher extends TypeSafeMatcher<String> {
|
private static class RegexMatcher extends TypeSafeMatcher<String> {
|
||||||
private final String regex;
|
private final String regex;
|
||||||
|
|
||||||
|
2
spring-boot-samples/spring-boot-sample-websocket/pom.xml
Normal file → Executable file
2
spring-boot-samples/spring-boot-sample-websocket/pom.xml
Normal file → Executable file
@ -2,7 +2,7 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>spring-boot-sample-websocket</artifactId>
|
<artifactId>spring-boot-sample-websocket</artifactId>
|
||||||
<packaging>war</packaging>
|
<packaging>jar</packaging>
|
||||||
<parent>
|
<parent>
|
||||||
<!-- Your own application should inherit from spring-boot-starter-parent -->
|
<!-- Your own application should inherit from spring-boot-starter-parent -->
|
||||||
<groupId>org.springframework.boot</groupId>
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
Loading…
Reference in New Issue
Block a user