Search in sources :

Example 1 with JSPDirectiveValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator 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)

Example 2 with JSPDirectiveValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator 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 3 with JSPDirectiveValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator 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 4 with JSPDirectiveValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator 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

IPath (org.eclipse.core.runtime.IPath)4 Path (org.eclipse.core.runtime.Path)4 JSPDirectiveValidator (org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator)4 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)4 Iterator (java.util.Iterator)3 IMessage (org.eclipse.wst.validation.internal.provisional.core.IMessage)3 IProject (org.eclipse.core.resources.IProject)1 CoreException (org.eclipse.core.runtime.CoreException)1