Search in sources :

Example 26 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter 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 27 with IReporter

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

the class JSPJavaValidatorTest method test_530968_ExpressionInCustomTagInComment1.

public void test_530968_ExpressionInCustomTagInComment1() 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");
    }
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/bug_530968/WebContent/bug530968.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) IProject(org.eclipse.core.resources.IProject) JSPJavaValidator(org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)

Example 28 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter 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)

Example 29 with IReporter

use of org.eclipse.wst.validation.internal.provisional.core.IReporter 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 30 with IReporter

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

the class JSONSyntaxValidatorHelperTest method noErrorsWithObject.

@Test
public void noErrorsWithObject() throws Exception {
    IReporter reporter = validate("{}");
    List messages = reporter.getMessages();
    Assert.assertEquals(0, messages.size());
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) List(java.util.List) Test(org.junit.Test)

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