Package org.springframework.validation

Examples of org.springframework.validation.BindException


   
    protected void setUp() throws Exception {
        IEmployee target = new Employee();
       
        this.callback = new DefaultErrorRenderingCallback();   
        this.errors = new BindException(target, "command");
        this.errors.addError(new ObjectError("command", new String[]{"ErrorCode1"}, null, "Default Message 1"));
        this.messageSource = new DelegatingMessageSource();
    }
View Full Code Here


   
    protected void setUp() throws Exception {
        MockHttpServletRequest request = new MockHttpServletRequest();
        IEmployee target = new Employee();
       
        this.errors = new BindException(target, "command");
        this.errors.addError(new ObjectError("command", new String[]{"ErrorCode1"}, null, "Default Message 1"));
       
        this.submitEvent = new AjaxSubmitEventImpl("submitEvent", request);
        this.submitEvent.setCommandObject(target);
    }
View Full Code Here

        validatorControl2.verify();
    }

    public void testValidate_WhenAllValidatorsSupport() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        validatorControl1.expectAndReturn(validator1.supports(object.getClass()), true);
        validator1.validate(object, errors);
        validatorControl2.expectAndReturn(validator2.supports(object.getClass()), true);
        validator2.validate(object, errors);
View Full Code Here

        validatorControl2.verify();
    }

    public void testValidate_WhenOnlyOneValidatorSupports() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        validatorControl1.expectAndReturn(validator1.supports(object.getClass()), true);
        validator1.validate(object, errors);
        validatorControl2.expectAndReturn(validator2.supports(object.getClass()), false);
View Full Code Here

        validatorControl2.verify();
    }

    public void testValidate_WhenNoValidatorSupports() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        validatorControl1.expectAndReturn(validator1.supports(object.getClass()), false);
        validatorControl2.expectAndReturn(validator2.supports(object.getClass()), false);

        validatorControl1.replay();
View Full Code Here

        conditionControl.verify();
    }

    public void testValidate_WhenConditionCheckPass() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        conditionControl.expectAndReturn(condition.check(object), true);
        innerValidator.validate(object, errors);

        conditionControl.replay();
View Full Code Here

        innerValidatorControl.verify();
    }

    public void testValidate_WhenConditionCheckFail() throws Exception {
        Object object = new Object();
        BindException errors = new BindException(object, "name");

        conditionControl.expectAndReturn(condition.check(object), false);

        conditionControl.replay();
        innerValidatorControl.replay();
View Full Code Here

    public void testValidate_WithPageSettings() {
        DefaultPageBeanValidator validator = getValidator(0);

        FooBean bean = new FooBean();
        BindException errors = new BindException(bean, "pagedFooBean");

        validator.validate(bean, errors);
        assertTrue(errors.hasFieldErrors("name"));
        assertEquals(1, errors.getErrorCount());
        assertEquals("name", ((FieldError) errors.getAllErrors().iterator().next()).getField());

        errors = new BindException(bean, "pagedFooBean");
        bean.setName("name");
        validator.validate(bean, errors);
        assertFalse(errors.hasFieldErrors("name"));
    }
View Full Code Here

        BeanValidator validator = new BeanValidator();
        validator.setErrorCodeConverter(new ModelAwareErrorCodeConverter());
        validator.setConfigurationLoader(loader);

        Person person = new Person("Uri");
        BindException errors = new BindException(person, "person");

        validator.validate(person, errors);

        assertTrue(errors.hasFieldErrors("name"));
        assertTrue(errors.hasGlobalErrors());
        assertEquals(1, errors.getFieldErrorCount("name"));
        assertEquals(1, errors.getGlobalErrorCount());
        assertEquals("Person[minLength]", errors.getGlobalError().getCode());
        assertEquals("Person.name[minLength]", errors.getFieldError("name").getCode());

    }
View Full Code Here

        validator.setErrorCodeConverter(new ModelAwareErrorCodeConverter());
        validator.setConfigurationLoader(loader);

        Person person = new Person("Uri");
        BindException errors = new BindException(person, "person");

        validator.validate(person, errors);

        assertTrue(errors.hasGlobalErrors());
        assertEquals(1, errors.getGlobalErrorCount());
        assertEquals("Person[bad]", errors.getGlobalError().getCode());
    }
View Full Code Here

TOP

Related Classes of org.springframework.validation.BindException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.