Search in sources :

Example 1 with JSPActionValidator

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);
}
Also used : Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPActionValidator(org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator)

Example 2 with JSPActionValidator

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);
}
Also used : Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPActionValidator(org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator)

Example 3 with JSPActionValidator

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());
}
Also used : Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) List(java.util.List) JSPActionValidator(org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator)

Example 4 with JSPActionValidator

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);
}
Also used : Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPActionValidator(org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator)

Aggregations

Path (org.eclipse.core.runtime.Path)4 JSPActionValidator (org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator)4 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)4 List (java.util.List)1