Search in sources :

Example 41 with IReporter

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

the class JSPDirectiveValidatorTest method testIncludeDirective.

public void testIncludeDirective() throws Exception {
    JSPDirectiveValidator validator = new JSPDirectiveValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/WebContent/testinclude.jsp";
    assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
    helper.setURI(filePath);
    validator.validate(helper, reporter);
    boolean foundMissingInclude = false;
    boolean foundIncludeWithError = false;
    if (reporter.getMessages().size() > 0) {
        Iterator it = reporter.getMessages().iterator();
        boolean foundError = false;
        while (it.hasNext() && !foundError) {
            IMessage message = (IMessage) it.next();
            if (message.getLineNumber() == 11)
                foundIncludeWithError = true;
            else if (message.getLineNumber() == 12) {
                String expectedMsg = NLS.bind(JSPCoreMessages.JSPDirectiveValidator_4, new String[] { FRAGMENT_NAME, "/" + PROJECT_NAME + "/WebContent/" + FRAGMENT_NAME });
                if (!expectedMsg.equals(message.getText()))
                    fail("Error found on line 12, but was not a missing fragment error.");
                foundMissingInclude = true;
                break;
            }
        }
    }
    assertFalse("JSP Directive Validator reported an error for a fragment that should be locatable.", foundIncludeWithError);
    assertTrue("JSP Directive Validator did not report the missing fragment.", foundMissingInclude);
}
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)

Example 42 with IReporter

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

the class JSPDirectiveValidatorTest method testBug265710El.

public void testBug265710El() throws Exception {
    JSPDirectiveValidator validator = new JSPDirectiveValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/WebContent/bug265710el.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() == 11 && message.getSeverity() == IMessage.HIGH_SEVERITY) {
                fail("JSP Directive Validator flagged JSP EL 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)

Example 43 with IReporter

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

the class JSPDirectiveValidatorTest method testIncludeMappedURL.

public void testIncludeMappedURL() throws Exception {
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("delos");
    if (!project.exists()) {
        BundleResourceUtil.createSimpleProject("delos", null, new String[] { JavaCore.NATURE_ID });
        BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/delos", "/delos");
    }
    assertTrue("project could not be created", project.exists());
    JSPDirectiveValidator validator = new JSPDirectiveValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/delos/WebContent/1.jsp";
    assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
    helper.setURI(filePath);
    validator.validate(helper, reporter);
    assertTrue("problems were found in JSP file", reporter.getMessages().isEmpty());
    try {
        project.delete(true, null);
    } catch (CoreException e) {
    // failure to clean up shouldn't fail the test
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) CoreException(org.eclipse.core.runtime.CoreException) JSPDirectiveValidator(org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator) IProject(org.eclipse.core.resources.IProject)

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