Add validation test to ws sample

Fixes gh-481
This commit is contained in:
kozazz
2014-03-12 15:40:30 +09:00
committed by Dave Syer
parent d82a728efe
commit ba9f92e74f
2 changed files with 9 additions and 1 deletions

View File

@@ -26,6 +26,7 @@ import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.
* A Basic Spring MVC Test for the Sample Controller"
*
* @author Biju Kunjummen
* @author Doo-Hwan, Kwak
*/
@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@@ -55,6 +56,13 @@ public class MessageControllerWebTests {
.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 final String regex;