public void testConditionBean_WhenDeployedInApplicationContext() throws Exception {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("appCtxt.xml", getClass());
DefaultXmlBeanValidationConfigurationLoader loader = createLoader("TestBean2.vld.xml", context);
BeanValidator validator = new BeanValidator(loader);
TestBean bean = new TestBean();
BindException errors = new BindException(bean, "bean");
validator.validate(bean, errors);
assertTrue(errors.hasErrors());
assertTrue(errors.hasFieldErrors("name"));
assertEquals("TestBean.name[test.bean.condition]", errors.getFieldError("name").getCode());
bean = new TestBean("name");
errors = new BindException(bean, "bean");
validator.validate(bean, errors);
assertFalse(errors.hasErrors());
}