Java Code Examples for org.springframework.validation.BeanPropertyBindingResult#rejectValue()
The following examples show how to use
org.springframework.validation.BeanPropertyBindingResult#rejectValue() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InputTagTests.java From spring-analysis-note with MIT License | 6 votes |
@Test public void withErrors() throws Exception { this.tag.setPath("name"); this.tag.setCssClass("good"); this.tag.setCssErrorClass("bad"); BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.rob, COMMAND_NAME); errors.rejectValue("name", "some.code", "Default Message"); errors.rejectValue("name", "too.short", "Too Short"); exposeBindingResult(errors); assertEquals(Tag.SKIP_BODY, this.tag.doStartTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", getType()); assertValueAttribute(output, "Rob"); assertContainsAttribute(output, "class", "bad"); }
Example 2
Source File: InputTagTests.java From java-technology-stack with MIT License | 6 votes |
@Test public void withErrors() throws Exception { this.tag.setPath("name"); this.tag.setCssClass("good"); this.tag.setCssErrorClass("bad"); BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.rob, COMMAND_NAME); errors.rejectValue("name", "some.code", "Default Message"); errors.rejectValue("name", "too.short", "Too Short"); exposeBindingResult(errors); assertEquals(Tag.SKIP_BODY, this.tag.doStartTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", getType()); assertValueAttribute(output, "Rob"); assertContainsAttribute(output, "class", "bad"); }
Example 3
Source File: InputTagTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test public void withErrors() throws Exception { this.tag.setPath("name"); this.tag.setCssClass("good"); this.tag.setCssErrorClass("bad"); BeanPropertyBindingResult errors = new BeanPropertyBindingResult(this.rob, COMMAND_NAME); errors.rejectValue("name", "some.code", "Default Message"); errors.rejectValue("name", "too.short", "Too Short"); exposeBindingResult(errors); assertEquals(Tag.SKIP_BODY, this.tag.doStartTag()); String output = getOutput(); assertTagOpened(output); assertTagClosed(output); assertContainsAttribute(output, "type", getType()); assertValueAttribute(output, "Rob"); assertContainsAttribute(output, "class", "bad"); }
Example 4
Source File: DefaultHandlerExceptionResolverTests.java From spring-analysis-note with MIT License | 5 votes |
@Test public void handleMethodArgumentNotValid() throws Exception { BeanPropertyBindingResult errors = new BeanPropertyBindingResult(new TestBean(), "testBean"); errors.rejectValue("name", "invalid"); MethodParameter parameter = new MethodParameter(this.getClass().getMethod("handle", String.class), 0); MethodArgumentNotValidException ex = new MethodArgumentNotValidException(parameter, errors); ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex); assertNotNull("No ModelAndView returned", mav); assertTrue("No Empty ModelAndView returned", mav.isEmpty()); assertEquals("Invalid status code", 400, response.getStatus()); }
Example 5
Source File: DefaultHandlerExceptionResolverTests.java From java-technology-stack with MIT License | 5 votes |
@Test public void handleMethodArgumentNotValid() throws Exception { BeanPropertyBindingResult errors = new BeanPropertyBindingResult(new TestBean(), "testBean"); errors.rejectValue("name", "invalid"); MethodParameter parameter = new MethodParameter(this.getClass().getMethod("handle", String.class), 0); MethodArgumentNotValidException ex = new MethodArgumentNotValidException(parameter, errors); ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex); assertNotNull("No ModelAndView returned", mav); assertTrue("No Empty ModelAndView returned", mav.isEmpty()); assertEquals("Invalid status code", 400, response.getStatus()); }
Example 6
Source File: DefaultHandlerExceptionResolverTests.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Test public void handleMethodArgumentNotValid() throws Exception { BeanPropertyBindingResult errors = new BeanPropertyBindingResult(new TestBean(), "testBean"); errors.rejectValue("name", "invalid"); MethodParameter parameter = new MethodParameter(this.getClass().getMethod("handle", String.class), 0); MethodArgumentNotValidException ex = new MethodArgumentNotValidException(parameter, errors); ModelAndView mav = exceptionResolver.resolveException(request, response, null, ex); assertNotNull("No ModelAndView returned", mav); assertTrue("No Empty ModelAndView returned", mav.isEmpty()); assertEquals("Invalid status code", 400, response.getStatus()); }