use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method testBug265710Expression.
public void testBug265710Expression() throws Exception {
JSPDirectiveValidator validator = new JSPDirectiveValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/bug265710expression.jsp";
assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
helper.setURI(filePath);
validator.validate(helper, reporter);
if (reporter.getMessages().size() > 0) {
Iterator it = reporter.getMessages().iterator();
while (it.hasNext()) {
IMessage message = (IMessage) it.next();
if (message.getLineNumber() == 14 && message.getSeverity() == IMessage.HIGH_SEVERITY) {
fail("JSP Directive Validator flagged a JSP expression in the import directive");
}
}
}
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method testIncludeDirective.
public void testIncludeDirective() throws Exception {
JSPDirectiveValidator validator = new JSPDirectiveValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/testinclude.jsp";
assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
helper.setURI(filePath);
validator.validate(helper, reporter);
boolean foundMissingInclude = false;
boolean foundIncludeWithError = false;
if (reporter.getMessages().size() > 0) {
Iterator it = reporter.getMessages().iterator();
boolean foundError = false;
while (it.hasNext() && !foundError) {
IMessage message = (IMessage) it.next();
if (message.getLineNumber() == 11)
foundIncludeWithError = true;
else if (message.getLineNumber() == 12) {
String expectedMsg = NLS.bind(JSPCoreMessages.JSPDirectiveValidator_4, new String[] { FRAGMENT_NAME, "/" + PROJECT_NAME + "/WebContent/" + FRAGMENT_NAME });
if (!expectedMsg.equals(message.getText()))
fail("Error found on line 12, but was not a missing fragment error.");
foundMissingInclude = true;
break;
}
}
}
assertFalse("JSP Directive Validator reported an error for a fragment that should be locatable.", foundIncludeWithError);
assertTrue("JSP Directive Validator did not report the missing fragment.", foundMissingInclude);
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method testBug265710El.
public void testBug265710El() throws Exception {
JSPDirectiveValidator validator = new JSPDirectiveValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/" + PROJECT_NAME + "/WebContent/bug265710el.jsp";
assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
helper.setURI(filePath);
validator.validate(helper, reporter);
if (reporter.getMessages().size() > 0) {
Iterator it = reporter.getMessages().iterator();
while (it.hasNext()) {
IMessage message = (IMessage) it.next();
if (message.getLineNumber() == 11 && message.getSeverity() == IMessage.HIGH_SEVERITY) {
fail("JSP Directive Validator flagged JSP EL in the import directive");
}
}
}
}
use of org.eclipse.jst.jsp.core.internal.validation.JSPDirectiveValidator in project webtools.sourceediting by eclipse.
the class JSPDirectiveValidatorTest method testIncludeMappedURL.
public void testIncludeMappedURL() throws Exception {
IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject("delos");
if (!project.exists()) {
BundleResourceUtil.createSimpleProject("delos", null, new String[] { JavaCore.NATURE_ID });
BundleResourceUtil.copyBundleEntriesIntoWorkspace("/testfiles/delos", "/delos");
}
assertTrue("project could not be created", project.exists());
JSPDirectiveValidator validator = new JSPDirectiveValidator();
IReporter reporter = new ReporterForTest();
ValidationContextForTest helper = new ValidationContextForTest();
String filePath = "/delos/WebContent/1.jsp";
assertTrue("unable to find file: " + filePath, ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(filePath)).exists());
helper.setURI(filePath);
validator.validate(helper, reporter);
assertTrue("problems were found in JSP file", reporter.getMessages().isEmpty());
try {
project.delete(true, null);
} catch (CoreException e) {
// failure to clean up shouldn't fail the test
}
}
Aggregations