Search in sources :

Example 1 with ReporterForTest

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

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

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

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

use of org.eclipse.jst.jsp.core.tests.validation.ReporterForTest 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)5 IProject (org.eclipse.core.resources.IProject)5 JSPJavaValidator (org.eclipse.jst.jsp.core.internal.validation.JSPJavaValidator)5 ReporterForTest (org.eclipse.jst.jsp.core.tests.validation.ReporterForTest)5 ValidationContextForTest (org.eclipse.jst.jsp.core.tests.validation.ValidationContextForTest)5 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)5 JSPValidator (org.eclipse.jst.jsp.core.internal.validation.JSPValidator)3 IOException (java.io.IOException)1 CoreException (org.eclipse.core.runtime.CoreException)1 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)1 Path (org.eclipse.core.runtime.Path)1