Search in sources :

Example 11 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JSPJavaValidatorTest method test_530968_ExpressionInCustomTagInComment2.

public void test_530968_ExpressionInCustomTagInComment2() throws Exception {
    JSPJavaValidator validator = new JSPJavaValidator();
    ProjectUtil.createProject("bug_530968-2", null, null);
    BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/bug_530968-2", "/bug_530968-2");
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/bug_530968-2/WebContent/bug530968-2.jsp";
    helper.setURI(filePath);
    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(strings, reporter.getMessages().isEmpty());
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)

Example 12 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JSPJavaTranslatorCustomTagTest method test_326193.

/**
 * Tests jsp translation when custom tag used
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=326193
 *
 * @throws Exception
 */
public void test_326193() throws Exception {
    // $NON-NLS-1$
    String projectName = "bug_326193";
    // 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/test326193.jsp");
    assertTrue(file.exists());
    JSPValidator validator = new JSPJavaValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    helper.setURI(file.getFullPath().toOSString());
    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 error for empty end tag in xml comment in script:" + strings, reporter.getMessages().isEmpty());
}
Also used : IFile(org.eclipse.core.resources.IFile) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPValidator(org.eclipse.jst.jsp.core.internal.validation.JSPValidator) ValidationContextForTest(org.eclipse.jst.jsp.core.tests.validation.ValidationContextForTest) ReporterForTest(org.eclipse.jst.jsp.core.tests.validation.ReporterForTest) IProject(org.eclipse.core.resources.IProject) JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)

Example 13 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter 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 14 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter 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 15 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter in project webtools.sourceediting by eclipse.

the class JSPDirectiveValidatorTest method testBug265710Expression.

public void testBug265710Expression() throws Exception {
    JSPDirectiveValidator validator = new JSPDirectiveValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/WebContent/bug265710expression.jsp";
    assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
    helper.setURI(filePath);
    validator.validate(helper, reporter);
    if (reporter.getMessages().size() > 0) {
        Iterator it = reporter.getMessages().iterator();
        while (it.hasNext()) {
            IMessage message = (IMessage) it.next();
            if (message.getLineNumber() == 14 && message.getSeverity() == IMessage.HIGH_SEVERITY) {
                fail("JSP Directive Validator flagged a JSP expression in the import directive");
            }
        }
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) IMessage(org.eclipse.wst.validation.internal.provisional.core.IMessage) Iterator(java.util.Iterator) JSPDirectiveValidator(org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator)

Aggregations

IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)43 IFile (org.eclipse.core.resources.IFile)17 Path (org.eclipse.core.runtime.Path)15 List (java.util.List)11 JSPJavaValidator (org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)10 ValidationResult (org.eclipse.wst.validation.ValidationResult)9 Test (org.junit.Test)8 IProject (org.eclipse.core.resources.IProject)7 IPath (org.eclipse.core.runtime.IPath)7 JSPValidator (org.eclipse.jst.jsp.core.internal.validation.JSPValidator)7 LocalizedMessage (org.eclipse.wst.validation.internal.operations.LocalizedMessage)6 CoreException (org.eclipse.core.runtime.CoreException)5 ReporterForTest (org.eclipse.jst.jsp.core.tests.validation.ReporterForTest)5 ValidationContextForTest (org.eclipse.jst.jsp.core.tests.validation.ValidationContextForTest)5 IOException (java.io.IOException)4 JSPActionValidator (org.eclipse.jst.jsp.core.internal.validation.JSPActionValidator)4 JSPDirectiveValidator (org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator)4 IMessage (org.eclipse.wst.validation.internal.provisional.core.IMessage)4 Iterator (java.util.Iterator)3 JSPContentValidator (org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator)3