use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class HTMLValidator method validate.
public ValidationResult validate(IResource resource, int kind, ValidationState state, IProgressMonitor monitor) {
if (resource.getType() != IResource.FILE)
return null;
ValidationResult result = new ValidationResult();
IReporter reporter = result.getReporter(monitor);
validateFile(null, reporter, (IFile) resource, result);
return result;
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class JSPHTMLValidatorTest method testJSPinAttributes.
/**
* Tests jsp expression in html attributes in jsp file
*
* @throws Exception
*/
public void testJSPinAttributes() throws Exception {
JSPContentValidator validator = new JSPContentValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/usejspinattribute.jsp";
helper.setURI(filePath);
validator.validate(helper, reporter);
assertTrue("jsp in attributes are errors when they should not be (in .jsp)", reporter.getMessages().isEmpty());
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class JSPJavaTranslatorCustomTagTest method test_310085.
/**
* Tests jsp translation when custom tag used
* https://bugs.eclipse.org/bugs/show_bug.cgi?id=310085
*
* @throws Exception
*/
public void test_310085() throws Exception {
// $NON-NLS-1$
String projectName = "bug_310085";
// Create new project
IProject project = BundleResourceUtil.createJavaWebProject(projectName);
assertTrue(project.exists());
// $NON-NLS-1$ //$NON-NLS-2$
BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + projectName, "/" + projectName);
// $NON-NLS-1$
IFile file = project.getFile("WebContent/test310085.jsp");
assertTrue(file.exists());
JSPValidator validator = new JSPJavaValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
helper.setURI(file.getFullPath().toString());
validator.validate(helper, reporter);
String strings = "";
for (int i = 0; i < reporter.getMessages().size(); i++) {
strings = strings + ((IMessage) reporter.getMessages().get(i)).getText() + "\n";
}
assertTrue("Found JSP Java problem(s) for custom tag: " + strings, reporter.getMessages().isEmpty());
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class JSPActionValidatorTest method testAttributesCorrect.
/**
* Tests if missing required attributes are detected
*
* @throws Exception
*/
public void testAttributesCorrect() throws Exception {
JSPActionValidator validator = new JSPActionValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/worksfine.jsp";
assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
helper.setURI(filePath);
validator.validate(helper, reporter);
StringBuffer error = new StringBuffer("jsp action validator found errors when it should not have");
List messages = reporter.getMessages();
for (int i = 0; i < messages.size(); i++) {
error.append('\n');
error.append(((IMessage) messages.get(i)).getText());
}
assertTrue(error.toString(), reporter.getMessages().isEmpty());
}
use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.
the class JSPActionValidatorTest method testMissingRequiredAttribute.
/**
* Tests if missing required attributes are detected
*
* @throws Exception
*/
public void testMissingRequiredAttribute() throws Exception {
JSPActionValidator validator = new JSPActionValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/norequiredattribute.jsp";
assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
helper.setURI(filePath);
validator.validate(helper, reporter);
boolean foundError = errorMessageFound(reporter, NLS.bind(JSPCoreMessages.JSPDirectiveValidator_5, REQUIRED_ATTR_NAME), 11);
if (foundError)
foundError = errorMessageFound(reporter, NLS.bind(JSPCoreMessages.JSPDirectiveValidator_5, REQUIRED_ATTR_NAME), 12);
assertTrue("jsp action validator did not detect missing required attributes", foundError);
}
Aggregations