Search in sources :

Example 6 with JSPValidator

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

the class JSPJavaValidatorTest method testValidatingFragments.

/**
 * Tests if jsp fragments are validated when preference is set to true
 *
 * @throws Exception
 */
public void testValidatingFragments() throws Exception {
    JSPValidator validator = new JSPJavaValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/WebContent/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(true));
    validator.validate(helper, reporter);
    if (validate != null) {
        JSPFContentProperties.setProperty(JSPFContentProperties.VALIDATE_FRAGMENTS, file, validate);
    }
    assertTrue("jspf was not validated when it should 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) JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)

Example 7 with JSPValidator

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

the class JSPJavaTranslatorCustomTagTest method test_310085.

/**
 * Tests jsp translation when custom tag used
 * https://bugs.eclipse.org/bugs/show_bug.cgi?id=310085
 *
 * @throws Exception
 */
public void test_310085() throws Exception {
    // $NON-NLS-1$
    String projectName = "bug_310085";
    // 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/test310085.jsp");
    assertTrue(file.exists());
    JSPValidator validator = new JSPJavaValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    helper.setURI(file.getFullPath().toString());
    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 problem(s) for custom tag: " + 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)

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