use of org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator in project webtools.sourceediting by eclipse.
the class JSPActionValidatorTest method testUknownAttribute.
/**
* Tests if unknown attributes are detected
*
* @throws Exception
*/
public void testUknownAttribute() throws Exception {
JSPActionValidator validator = new JSPActionValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/undefinedattribute.jsp";
assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
helper.setURI(filePath);
validator.validate(helper, reporter);
boolean foundError1 = errorMessageFound(reporter, NLS.bind(JSPCoreMessages.JSPDirectiveValidator_6, UNDEFINED_ATTR_IDONT), 4);
if (foundError1)
foundError1 = errorMessageFound(reporter, NLS.bind(JSPCoreMessages.JSPDirectiveValidator_6, UNDEFINED_ATTR_IDONT), 12);
if (foundError1)
foundError1 = errorMessageFound(reporter, NLS.bind(JSPCoreMessages.JSPDirectiveValidator_6, UNDEFINED_ATTR_IDONT), 13);
assertTrue("jsp action validator did not detect undefined attributes", foundError1);
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator in project webtools.sourceediting by eclipse.
the class JSPActionValidatorTest method testNonEmptyInlineTag.
/**
* Tests if non-empty inline tags are flagged as warnings
*
* @throws Exception
*/
public void testNonEmptyInlineTag() throws Exception {
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=203254
JSPActionValidator validator = new JSPActionValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/nonemptyinlinetag.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.JSPActionValidator_0, NONEMPTY_INLINE_TAG_NAME), 10);
assertTrue("jsp action validator had problems detecting an error with content in an inline tag", foundError);
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator 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.jst.jsp.core.internal.validation.JSPActionValidator 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