Search in sources :

Example 1 with JSPJavaValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator in project webtools.sourceediting by eclipse.

the class JSPJavaTranslatorCoreTest method test_530968_ExpressionInCustomTagInComment.

public void test_530968_ExpressionInCustomTagInComment() throws Exception {
    JSPJavaValidator validator = new JSPJavaValidator();
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("bug_530968");
    if (!project.exists()) {
        ProjectUtil.createProject("bug_530968", null, null);
        BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/bug_530968", "/bug_530968");
    }
    String filePath = "/bug_530968/WebContent/bug530968.jsp";
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath));
    assertTrue(file.exists());
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    helper.setURI(filePath);
    validator.validate(helper, reporter);
    String messageText = reporter.getMessages().isEmpty() ? "no error found" : ((Message) reporter.getMessages().get(0)).getText();
    assertTrue(messageText, reporter.getMessages().isEmpty());
}
Also used : Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) 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 2 with JSPJavaValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator in project webtools.sourceediting by eclipse.

the class JSPJavaTranslatorCoreTest method test_150794.

public void test_150794() throws Exception {
    String testName = "bug_150794";
    // Create new project
    IProject project = BundleResourceUtil.createJavaWebProject(testName);
    assertTrue(project.exists());
    BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + testName, "/" + testName);
    IFile main = project.getFile("/WebContent/escapedQuotes.jsp");
    assertTrue("sample test file does not exist", main.isAccessible());
    JSPJavaValidator validator = new JSPJavaValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    helper.setURI(main.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("Unexpected problems found: " + strings, reporter.getMessages().isEmpty());
    // clean up if we got to the end
    try {
        project.delete(true, true, null);
    } catch (Exception e) {
    // not a failure condition
    }
}
Also used : IFile(org.eclipse.core.resources.IFile) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) ValidationContextForTest(org.eclipse.jst.jsp.core.tests.validation.ValidationContextForTest) ReporterForTest(org.eclipse.jst.jsp.core.tests.validation.ReporterForTest) IProject(org.eclipse.core.resources.IProject) CoreException(org.eclipse.core.runtime.CoreException) OperationCanceledException(org.eclipse.core.runtime.OperationCanceledException) IOException(java.io.IOException) JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)

Example 3 with JSPJavaValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator in project webtools.sourceediting by eclipse.

the class JSPBatchValidatorTest method testELConditional.

public void testELConditional() throws Exception {
    if (!ResourcesPlugin.getWorkspace().getRoot().getProject("testIterationTags").exists()) {
        BundleResourceUtil.createSimpleProject("testIterationTags", null, new String[] { JavaCore.NATURE_ID });
        BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + PROJECT_NAME, "/" + PROJECT_NAME);
    }
    assertTrue("project could not be created", ResourcesPlugin.getWorkspace().getRoot().getProject("testIterationTags").exists());
    JSPValidator validator = new JSPJavaValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath1 = "/testIterationTags/WebContent/default.jspx";
    IFile file1 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath1));
    assertTrue(file1.exists());
    helper.setURIs(new String[] { filePath1 });
    validator.validate(helper, reporter);
    assertTrue("expected jsp errors were not found in both files: " + reporter.getMessages().size(), reporter.getMessages().size() == 0);
}
Also used : Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) IFile(org.eclipse.core.resources.IFile) JSPValidator(org.eclipse.jst.jsp.core.internal.validation.JSPValidator) JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)

Example 4 with JSPJavaValidator

use of org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator in project webtools.sourceediting by eclipse.

the class JSPBatchValidatorTest method testValidating2Files.

/**
 * Tests validating 2 jsp files. See
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=214441
 *
 * @throws Exception
 */
public void testValidating2Files() throws Exception {
    JSPValidator validator = new JSPJavaValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath1 = "/" + PROJECT_NAME + "/WebContent/ihaveerrors.jsp";
    IFile file1 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath1));
    assertTrue(file1.exists());
    String filePath2 = "/" + PROJECT_NAME + "/WebContent/ihaveerrors2.jsp";
    IFile file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath1));
    assertTrue(file2.exists());
    helper.setURIs(new String[] { filePath1, filePath2 });
    validator.validate(helper, reporter);
    assertTrue("expected jsp errors were not found in both files: " + reporter.getMessages().size(), reporter.getMessages().size() >= 2);
}
Also used : Path(org.eclipse.core.runtime.Path) IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) IFile(org.eclipse.core.resources.IFile) JSPValidator(org.eclipse.jst.jsp.core.internal.validation.JSPValidator) JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)

Example 5 with JSPJavaValidator

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

Aggregations

JSPJavaValidator (org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)10 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)10 IFile (org.eclipse.core.resources.IFile)8 IProject (org.eclipse.core.resources.IProject)6 JSPValidator (org.eclipse.jst.jsp.core.internal.validation.JSPValidator)6 ReporterForTest (org.eclipse.jst.jsp.core.tests.validation.ReporterForTest)5 ValidationContextForTest (org.eclipse.jst.jsp.core.tests.validation.ValidationContextForTest)5 Path (org.eclipse.core.runtime.Path)4 IOException (java.io.IOException)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1