How do I get Spring MVC to invoke validation in a JUnit test?
问题 I have a POJO called Browser that I've annotated with Hibernate Validator annotations. import org.hibernate.validator.constraints.NotEmpty; public class Browser { @NotEmpty private String userAgent; @NotEmpty private String browserName; ... } I've written the following unit test that tries to verify my Controller method catches validation errors. @Test public void testInvalidData() throws Exception { Browser browser = new Browser("opera", null); MockHttpServletRequest request = new