*/
public void testSupplementaryValidatorInvoked() throws Exception {
Element root = document.getRootElement();
final Element shipto = getChild(root, "shipto");
final BooleanObject firstBO = new BooleanObject();
firstBO.setValue(false);
// create a validator.
DOMSupplementaryValidator firstSupplementartyValidator
= new DOMSupplementaryValidator() {
// javadoc inherited
public void validate(Element element,
ErrorReporter errorReporter) {
firstBO.setValue(true);
// check that it is the correct element
assertEquals("Elment should be the 'shipto' element",
shipto,
element);
}
};
final BooleanObject secondBO = new BooleanObject();
secondBO.setValue(false);
// create another validator.
DOMSupplementaryValidator secondSupplementartyValidator
= new DOMSupplementaryValidator() {
// javadoc inherited
public void validate(Element element,
ErrorReporter errorReporter) {
secondBO.setValue(true);
// check that it is the correct element
assertEquals("Elment should be the 'shipto' element",
shipto,
element);
}
};
// create the validator. Do not expect an standard errors
validator = createValidator(new TestErrorReporter(
new ExpectedError[] {}));
// register the fist suplementary validator
validator.addSupplementaryValidator(shipto.getNamespaceURI(),
shipto.getName(),
firstSupplementartyValidator);
// register the second suplementary validator
validator.addSupplementaryValidator(shipto.getNamespaceURI(),
shipto.getName(),
secondSupplementartyValidator);
// validate the root element.
validator.validate(root);
// check that the first supplementary validator was invoked
assertTrue("The first supplementary validator was not invoked",
firstBO.getValue());
// check that the second supplementary validator was invoked
assertTrue("The second supplementary validator was not invoked",
secondBO.getValue());
}