use of org.eclipse.wst.xml.core.internal.validation.XMLValidator in project webtools.sourceediting by eclipse.
the class ErrorCustomizationManagerTest method testErrorReportedOnCorrectElement.
/**
* Test that an error customizer is only called for the
* correct element.
*/
public void testErrorReportedOnCorrectElement() {
IErrorMessageCustomizer testCustomizer = new IErrorMessageCustomizer() {
public String customizeMessage(ElementInformation elementInfo, String key, Object[] arguments) {
if (elementInfo.getLocalname().equals("child1")) {
fail("An error was reported for the child1 element.");
}
return null;
}
};
ErrorCustomizationRegistry registry = ErrorCustomizationRegistry.getInstance();
registry.addErrorMessageCustomizer("http://www.example.org/simplenested", testCustomizer);
try {
String PLUGIN_ABSOLUTE_PATH = XMLValidatorTestsPlugin.getPluginLocation().toString() + "/";
String uri = "file:///" + PLUGIN_ABSOLUTE_PATH + "testresources/samples/bugfixes/CustomErrorReportedOnCorrectElement/simplenested.xml";
XMLValidator validator = new XMLValidator();
validator.validate(uri, null, new XMLValidationConfiguration());
validator.validate(uri, null, new XMLValidationConfiguration());
} catch (IOException e) {
fail("An exception occurred while running the test:" + e);
}
}
Aggregations