use of org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator 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()));
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator 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);
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method testIncludeDirectiveXML.
public void testIncludeDirectiveXML() throws Exception {
String contents = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<jsp:root xmlns:jsp=\"http://java.sun.com/JSP/Page\" version=\"2.0\">\n" + "<jsp:directive.include file=\"missing.jspf\"/>\n";
runNegativeTest("/" + getName() + "/test.jsp", contents, new JSPBatchValidator(), "Fragment \"missing.jspf\" was not found at expected path /testIncludeDirectiveXML/missing.jspf");
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method testIncludeAction.
public void testIncludeAction() throws Exception {
String contents = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\n" + "<jsp:root xmlns:jsp=\"http://java.sun.com/JSP/Page\" version=\"2.0\">\n" + "<jsp:include page=\"missing.jspf\"/>\n";
runNegativeTest("/" + getName() + "/test.jsp", contents, new JSPBatchValidator(), "Fragment \"missing.jspf\" was not found at expected path /testIncludeAction/missing.jspf");
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPBatchValidator in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method testIncludeDirective2.
public void testIncludeDirective2() throws Exception {
String contents = "<%@include file=\"missing.jspf\"%>\n";
runNegativeTest("/" + getName() + "/test.jsp", contents, new JSPBatchValidator(), "Fragment \"missing.jspf\" was not found at expected path /testIncludeDirective2/missing.jspf");
}
Aggregations