|
16 | 16 |
|
17 | 17 | package org.springframework.web.servlet.mvc.annotation; |
18 | 18 |
|
19 | | -import static org.junit.Assert.assertEquals; |
20 | | -import static org.junit.Assert.assertFalse; |
21 | | -import static org.junit.Assert.assertNotNull; |
22 | | -import static org.junit.Assert.assertNull; |
23 | | -import static org.junit.Assert.assertSame; |
24 | | -import static org.junit.Assert.assertTrue; |
25 | | -import static org.junit.Assert.fail; |
26 | | - |
27 | 19 | import java.io.IOException; |
28 | 20 | import java.io.Serializable; |
29 | 21 | import java.io.Writer; |
|
43 | 35 | import java.util.Locale; |
44 | 36 | import java.util.Map; |
45 | 37 | import java.util.Set; |
46 | | - |
47 | 38 | import javax.servlet.ServletConfig; |
48 | 39 | import javax.servlet.ServletContext; |
49 | 40 | import javax.servlet.ServletException; |
|
54 | 45 | import javax.validation.Valid; |
55 | 46 | import javax.validation.constraints.NotNull; |
56 | 47 |
|
57 | | -import org.junit.Ignore; |
| 48 | +import static org.junit.Assert.*; |
58 | 49 | import org.junit.Test; |
| 50 | + |
59 | 51 | import org.springframework.aop.framework.autoproxy.DefaultAdvisorAutoProxyCreator; |
60 | 52 | import org.springframework.aop.interceptor.SimpleTraceInterceptor; |
61 | 53 | import org.springframework.aop.support.DefaultPointcutAdvisor; |
|
90 | 82 | import org.springframework.util.StringUtils; |
91 | 83 | import org.springframework.validation.BindingResult; |
92 | 84 | import org.springframework.validation.Errors; |
| 85 | +import org.springframework.validation.FieldError; |
93 | 86 | import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean; |
94 | 87 | import org.springframework.web.bind.WebDataBinder; |
95 | 88 | import org.springframework.web.bind.annotation.CookieValue; |
@@ -1303,6 +1296,9 @@ public List<TestBean> getTestBeans() { |
1303 | 1296 |
|
1304 | 1297 | @RequestMapping("/myPath.do") |
1305 | 1298 | public String myHandle(@ModelAttribute("myCommand") TestBean tb, BindingResult errors, ModelMap model) { |
| 1299 | + FieldError error = errors.getFieldError("age"); |
| 1300 | + assertNotNull("Must have field error for age property", error); |
| 1301 | + assertEquals("value2", error.getRejectedValue()); |
1306 | 1302 | if (!model.containsKey("myKey")) { |
1307 | 1303 | model.addAttribute("myKey", "myValue"); |
1308 | 1304 | } |
|
0 commit comments