Package org.springmodules.validation.bean

Examples of org.springmodules.validation.bean.BeanValidator.validate()


        person.setPassword("pa");
        person.setConfirmPassword("pa1");

        BindException errors = new BindException(person, "person");
        BeanValidator validator = new BeanValidator(loader);
        validator.validate(person, errors);

        assertEquals(1, errors.getGlobalErrorCount());

    }
}
View Full Code Here


        AnnotationBeanValidationConfigurationLoader loader = new AnnotationBeanValidationConfigurationLoader();
        BeanValidator validator = new BeanValidator(loader);

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

        validator.validate(person, errors);

        assertTrue(errors.hasGlobalErrors());
        assertEquals(2, errors.getGlobalErrorCount());
        assertTrue(errors.hasFieldErrors());
        assertTrue(errors.hasFieldErrors("firstName"));
View Full Code Here

        AnnotationBeanValidationConfigurationLoader loader = new AnnotationBeanValidationConfigurationLoader();
        BeanValidator validator = new BeanValidator(loader);

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

        validator.validate(person, errors);

        assertTrue(errors.hasGlobalErrors());
        assertEquals(3, errors.getGlobalErrorCount());
        assertTrue(errors.hasFieldErrors());
        assertTrue(errors.hasFieldErrors("firstName"));
View Full Code Here

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

        setContext("ctx1");

        validator.validate(person, errors);

        assertTrue(errors.hasGlobalErrors());
        assertEquals(2, errors.getGlobalErrorCount());
        assertTrue(errors.hasFieldErrors());
        assertTrue(errors.hasFieldErrors("firstName"));
View Full Code Here

        clearContext();

        setContext("ctx2");

        errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertFalse(errors.hasGlobalErrors());
        assertTrue(errors.hasFieldErrors());
        assertFalse(errors.hasFieldErrors("firstName"));
        assertFalse(errors.hasFieldErrors("lastName"));
View Full Code Here

        TeztBean1 bean = new TeztBean1();
        BindException errors = new BindException(bean, "bean");

        try {
            validator.validate(bean, errors);
            fail("Expecting an UnsupportedOperationException for the validator was not deployed within an application context");
        } catch (UnsupportedOperationException uso) {
            // expected
        }
    }
View Full Code Here

        TeztBean2 bean = new TeztBean2();
        BindException errors = new BindException(bean, "bean");

        try {
            validator.validate(bean, errors);
            fail("Expecting an UnsupportedOperationException for the validator was not deployed within an application context");
        } catch (UnsupportedOperationException uso) {
            // expected
        }
    }
View Full Code Here

        loader.setHandlerRegistry(registry);
        BeanValidator validator = new BeanValidator(loader);

        BindException errors = new BindException(entity, "entity");

        validator.validate(entity, errors);

        assertTrue(errors.hasFieldErrors());
        assertTrue(errors.hasFieldErrors("name"));
        assertTrue(errors.hasFieldErrors("text"));
        assertTrue(errors.hasFieldErrors("oneToOne"));
View Full Code Here

        person.setPassword("pa");
        person.setConfirmPassword("pa1");

        BindException errors = new BindException(person, "person");
        BeanValidator validator = new BeanValidator(loader);
        validator.validate(person, errors);

        assertEquals(2, errors.getGlobalErrorCount());
        assertEquals(1, errors.getFieldErrorCount("smallInteger"));
        assertEquals(1, errors.getFieldErrorCount("lastName"));
        assertEquals("Person.lastName[validateLastNameIsLongerThanTen()]", errors.getFieldError("lastName").getCode());
View Full Code Here

        person.setConfirmPassword("pa1");

        ValidationContextUtils.setContext("ctx1");

        BindException errors = new BindException(person, "person");
        validator.validate(person, errors);

        assertEquals(1, errors.getGlobalErrorCount());
        assertFalse(errors.hasFieldErrors("smallInteger"));
        assertEquals(1, errors.getFieldErrorCount("lastName"));
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.