Search in sources :

Example 1 with JSPValidator

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

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

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

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

the class JSPJavaTranslatorCoreTest method test_126377.

/**
 * Tests jsp translation when jsp is within html comments. See
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=126377
 *
 * @throws Exception
 */
public void test_126377() throws Exception {
    String projectName = "bug_126377";
    // Create new project
    IProject project = BundleResourceUtil.createJavaWebProject(projectName);
    assertTrue(project.exists());
    BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/" + projectName, "/" + projectName);
    IFile file = project.getFile("WebContent/test126377_noerror.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 problems within html comments when there should be none: " + strings, reporter.getMessages().isEmpty());
    file = project.getFile("WebContent/test126377_error.jsp");
    assertTrue(file.exists());
    helper.setURI(file.getFullPath().toOSString());
    validator.validate(helper, reporter);
    int errors = reporter.getMessages().size();
    assertTrue("found " + errors + " jsp java errors within html comments when there should be 3", (errors == 3));
}
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 5 with JSPValidator

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

the class JSPJavaValidatorTest method testNoValidatingFragments.

/**
 * Tests if jsp fragments are not validated when preference is set to
 * false
 *
 * @throws Exception
 */
public void testNoValidatingFragments() throws Exception {
    JSPValidator validator = new JSPValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/ihaveerrors.jspf";
    helper.setURI(filePath);
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath));
    String validate = JSPFContentProperties.getProperty(JSPFContentProperties.VALIDATE_FRAGMENTS, file, false);
    JSPFContentProperties.setProperty(JSPFContentProperties.VALIDATE_FRAGMENTS, file, Boolean.toString(false));
    validator.validate(helper, reporter);
    if (validate != null) {
        JSPFContentProperties.setProperty(JSPFContentProperties.VALIDATE_FRAGMENTS, file, validate);
    }
    assertTrue("jspf was validated when it should not have been", reporter.getMessages().isEmpty());
}
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)

Aggregations

IFile (org.eclipse.core.resources.IFile)7 JSPValidator (org.eclipse.jst.jsp.core.internal.validation.JSPValidator)7 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)7 JSPJavaValidator (org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)6 Path (org.eclipse.core.runtime.Path)4 IProject (org.eclipse.core.resources.IProject)3 ReporterForTest (org.eclipse.jst.jsp.core.tests.validation.ReporterForTest)3 ValidationContextForTest (org.eclipse.jst.jsp.core.tests.validation.ValidationContextForTest)3