Search in sources :

Example 1 with JSPContentValidator

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

the class JSPBatchValidatorTest method testFragmentValidationPreferenceOnProject.

public void testFragmentValidationPreferenceOnProject() throws Exception {
    JSPBatchValidator validator1 = new JSPBatchValidator();
    JSPContentValidator validator2 = new JSPContentValidator();
    String filePath = "/" + PROJECT_NAME + "/WebContent/header.jspf";
    ValidationResult result = null;
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath));
    // enable workspace-wide but disable in project, no problem markers
    // expected
    workspaceScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
    projectScope.putBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, true);
    projectScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, false);
    result = validator1.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor());
    result.mergeResults(validator2.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor()));
    assertEquals("Problems found while fragment validation was disabled in project but enabled on workspace", 0, (((ReporterHelper) result.getReporter(null)).getMessages().size()));
    /*
		 * disable workspace-wide but enable in project, some problem markers
		 * expected
		 */
    workspaceScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, false);
    projectScope.putBoolean(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS, true);
    projectScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
    JSPFContentProperties.setProperty(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, file, Boolean.toString(true));
    result = validator1.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor());
    result.mergeResults(validator2.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor()));
    assertTrue("Problems not found while fragment validation was enabled for project but disabled on workspace", 0 < (((ReporterHelper) result.getReporter(null)).getMessages().size()));
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ValidationState(org.eclipse.wst.validation.ValidationState) IFile(org.eclipse.core.resources.IFile) JSPBatchValidator(org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator) JSPContentValidator(org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator) ValidationResult(org.eclipse.wst.validation.ValidationResult) ReporterHelper(org.eclipse.wst.validation.ReporterHelper)

Example 2 with JSPContentValidator

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

the class JSPHTMLValidatorTest method testJSPinAttributesHTML.

/**
 * Tests jsp expression in html attributes in html file
 *
 * @throws Exception
 */
public void testJSPinAttributesHTML() throws Exception {
    JSPContentValidator validator = new JSPContentValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/WebContent/usejspinattribute.html";
    helper.setURI(filePath);
    validator.validate(helper, reporter);
    assertTrue("jsp in attributes are not errors when they should be (in .html)", !reporter.getMessages().isEmpty());
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPContentValidator(org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator)

Example 3 with JSPContentValidator

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

the class JSPHTMLValidatorTest method testBadAttributeName.

/**
 * Tests bad attribute names in jsp file false
 *
 * @throws Exception
 */
public void testBadAttributeName() throws Exception {
    JSPContentValidator validator = new JSPContentValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/WebContent/badattributenames.jsp";
    helper.setURI(filePath);
    validator.validate(helper, reporter);
    assertTrue("bad attribute name is not error when it should be", !reporter.getMessages().isEmpty());
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPContentValidator(org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator)

Example 4 with JSPContentValidator

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

the class JSPBatchValidatorTest method testFragmentValidationPreferenceOnWorkspace.

public void testFragmentValidationPreferenceOnWorkspace() throws Exception {
    JSPBatchValidator validator1 = new JSPBatchValidator();
    JSPContentValidator validator2 = new JSPContentValidator();
    String filePath = "/" + PROJECT_NAME + "/WebContent/header.jspf";
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath));
    ValidationResult result = null;
    // disable workspace-wide, no problem markers expected
    workspaceScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, false);
    result = validator1.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor());
    result.mergeResults(validator2.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor()));
    assertEquals("Problem markers found while fragment validation was disabled", 0, (((ReporterHelper) result.getReporter(null)).getMessages().size()));
    // enable workspace-wide, some problem markers expected
    workspaceScope.putBoolean(JSPCorePreferenceNames.VALIDATE_FRAGMENTS, true);
    ValidationFramework.getDefault().validate(new IProject[] { getProject() }, true, false, new NullProgressMonitor());
    ValidationFramework.getDefault().join(new NullProgressMonitor());
    result = validator1.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor());
    result.mergeResults(validator2.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor()));
    assertTrue("Problem markers not found while fragment validation was enabled on workspace", (((ReporterHelper) result.getReporter(null)).getMessages().size()) != 0);
    // check default value is true
    workspaceScope.remove(JSPCorePreferenceNames.VALIDATE_FRAGMENTS);
    projectScope.remove(JSPCorePreferenceNames.VALIDATE_FRAGMENTS);
    projectScope.remove(JSPCorePreferenceNames.VALIDATION_USE_PROJECT_SETTINGS);
    result = validator1.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor());
    result.mergeResults(validator2.validate(file, IResourceDelta.CHANGED, new ValidationState(), new NullProgressMonitor()));
    assertTrue("Problem markers not found while fragment validation was preferences were default", (((ReporterHelper) result.getReporter(null)).getMessages().size()) != 0);
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ValidationState(org.eclipse.wst.validation.ValidationState) IFile(org.eclipse.core.resources.IFile) JSPBatchValidator(org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator) JSPContentValidator(org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator) ValidationResult(org.eclipse.wst.validation.ValidationResult) ReporterHelper(org.eclipse.wst.validation.ReporterHelper)

Example 5 with JSPContentValidator

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

the class JSPHTMLValidatorTest method testJSPinAttributes.

/**
 * Tests jsp expression in html attributes in jsp file
 *
 * @throws Exception
 */
public void testJSPinAttributes() throws Exception {
    JSPContentValidator validator = new JSPContentValidator();
    IReporter reporter = new ReporterForTest();
    ValidationContextForTest helper = new ValidationContextForTest();
    String filePath = "/" + PROJECT_NAME + "/WebContent/usejspinattribute.jsp";
    helper.setURI(filePath);
    validator.validate(helper, reporter);
    assertTrue("jsp in attributes are errors when they should not be (in .jsp)", reporter.getMessages().isEmpty());
}
Also used : IReporter(org.eclipse.wst.validation.internal.provisional.core.IReporter) JSPContentValidator(org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator)

Aggregations

JSPContentValidator (org.eclipse.jst.jsp.core.internal.validation.JSPContentValidator)5 IReporter (org.eclipse.wst.validation.internal.provisional.core.IReporter)3 IFile (org.eclipse.core.resources.IFile)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Path (org.eclipse.core.runtime.Path)2 JSPBatchValidator (org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator)2 ReporterHelper (org.eclipse.wst.validation.ReporterHelper)2 ValidationResult (org.eclipse.wst.validation.ValidationResult)2 ValidationState (org.eclipse.wst.validation.ValidationState)2