use of org.eclipse.wst.validation.ValidationResult in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method runNegativeTest.
/**
* The purpose of a validator is to generate messages. Let us make sure the expected messages are generated.
* @param filePath
* @param content
* @param validator
* @param expectedProblemMessages
* @throws Exception
*/
protected void runNegativeTest(String filePath, String content, AbstractValidator validator, String expectedProblemMessages) throws Exception {
IPath path = new Path(filePath);
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(path.segment(0));
if (!project.exists()) {
BundleResourceUtil.createJavaWebProject(path.segment(0));
}
ResourcesPlugin.getWorkspace().checkpoint(true);
IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(path);
file.create(new ByteArrayInputStream(content.getBytes("utf8")), true, null);
ValidationResult result = validator.validate(file, IResourceDelta.ADDED, new ValidationState(), new NullProgressMonitor());
assertEquals(expectedProblemMessages, sortMessages(result.getReporter(new NullProgressMonitor()).getMessages()));
}
Aggregations