public void testBeanValidationNotAddedTwice() {
// See ticket #11045
BeanFieldGroup<BeanToValidate> fieldGroup = new BeanFieldGroup<BeanToValidate>(
BeanToValidate.class);
BeanToValidate beanToValidate = new BeanToValidate();
beanToValidate.setFirstname("a");
fieldGroup.setItemDataSource(beanToValidate);
Field<?> nameField = fieldGroup.buildAndBind("firstname");
Assert.assertEquals(1, nameField.getValidators().size());
try {
nameField.validate();
} catch (InvalidValueException e) {
// NOTE: causes are empty if only one validation fails
Assert.assertEquals(0, e.getCauses().length);
}
// Create new, identical bean to cause duplicate validator unless #11045
// is fixed
beanToValidate = new BeanToValidate();
beanToValidate.setFirstname("a");
fieldGroup.setItemDataSource(beanToValidate);
Assert.assertEquals(1, nameField.getValidators().size());
try {