SpringSource/spring-test-mvc — pull request #33 by scottfrederick (2012-04-11 18:28:11+00:00)
Title: Added methods to ModelRequestMatcher to verify field errors

This pull request supports more granular verification of errors in model attributes. This is useful when testing form submissions with @Valid-annotated beans, for example. These changes enable tests like this:

```java
@Test
public void submitForm() throws Exception {
mockMvc.perform(post("/addPerson").
param("firstName", ""). // validation error
param("lastName", ""). // validation error
param("age", 20)). // validation OK
andExpect(status().isOk()).
andExpect(view().name("add")).
andExpect(model().attributeExists("person", "otherBean")).
andExpect(model().attributeHasNoErrors("otherBean")).
andExpect(model().attributeHasFieldErrors("person", "firstName", "lastName")));
}
```