use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.
the class TestDelegatingSourceValidatorForXSL method testDelegatingSourceValidatorNPEwithNoAttributeValue.
@Test
public void testDelegatingSourceValidatorNPEwithNoAttributeValue() throws Exception {
WorkbenchContext context = setupFile(getxslTestFilesProjectName(), "bug272760.xsl");
TestReporter reporter = new TestReporter();
try {
sourceValidator.validate(context, reporter);
} catch (ValidationException e) {
} catch (NullPointerException e) {
StringWriter out = new StringWriter();
e.printStackTrace(new PrintWriter(out));
fail(out.toString());
}
}
use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.
the class TestDelegatingSourceValidatorForXSL method testValidXSLT.
@Test
public void testValidXSLT() throws Exception {
String fileName1 = "ListAllChangeRequests.xsl";
WorkbenchContext context = setupFile(getxslTestFilesProjectName(), fileName1);
TestReporter reporter = new TestReporter();
sourceValidator.validate(context, reporter);
assertFalse("Messages were reported on " + fileName1 + ".", reporter.isMessageReported());
}
use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.
the class TestHTMLValidator method performExternalValidatorTest.
private void performExternalValidatorTest(IFile testFile, boolean errorExpected) throws IOException, CoreException {
IStructuredModel model = null;
try {
assertTrue("Test file " + testFile + " does not exist", testFile.exists());
// get the document
model = StructuredModelManager.getModelManager().getModelForEdit(testFile);
// set up for fValidator
WorkbenchContext context = new WorkbenchContext();
List fileList = new ArrayList();
fileList.add(testFile.getFullPath().toPortableString());
context.setValidationFileURIs(fileList);
// validate clean file
TestReporter reporter = new TestReporter();
fValidator.validate(context, reporter);
if (errorExpected) {
assertTrue("There should be validation errors on " + testFile, reporter.isMessageReported());
} else {
assertFalse("There should be no validation errors on " + testFile, reporter.isMessageReported());
}
} finally {
if (model != null) {
model.releaseFromEdit();
}
}
}
use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.
the class TestDelegatingSourceValidatorForXML method testRemoveAndAddBackCommentEndTag.
/**
* Regression test for Bug 285285
*
* @see org.eclipse.wst.xml.ui.internal.validation.TestDelegatingSourceValidatorForXML#testRemoveAndAddBackCommentEndTag
* @see org.eclipse.wst.html.ui.tests.validation.TestHTMLValidator#testRemoveAndAddBackCommentEndTag
* @see org.eclipse.jst.jsp.ui.tests.validation.JSPHTMLValidatorTest#testRemoveAndAddBackCommentEndTag
*/
public void testRemoveAndAddBackCommentEndTag() throws Exception {
String projectName = "RemoveAndAddBackCommentEndTag";
IProject project = ProjectUtil.createProject(projectName, XMLUITestsPlugin.getDefault().getStateLocation().append(getName()), null);
IFile testFile = null;
IStructuredModel model = null;
try {
// get test file
ProjectUtil.copyBundleEntriesIntoWorkspace("testresources/RemoveAndAddBackCommentEndTag", projectName);
testFile = project.getFile("Test1.xml");
assertTrue("Test file " + testFile + " does not exist", testFile.exists());
// get the document
model = StructuredModelManager.getModelManager().getModelForEdit(testFile);
IStructuredDocument document = model.getStructuredDocument();
// set up for validator
WorkbenchContext context = new WorkbenchContext();
List fileList = new ArrayList();
fileList.add(testFile.getFullPath().toPortableString());
context.setValidationFileURIs(fileList);
// validate clean file
TestReporter reporter = new TestReporter();
sourceValidator.validate(context, reporter);
assertFalse("There should be no validation errors on " + testFile, reporter.isMessageReported());
// need to dynamically find where the --> is because
// its different on unix vs windows because of line endings
String contents = document.get();
int endCommentIndex = contents.indexOf("-->");
// remove -->
document.replace(endCommentIndex, 3, "");
// validate file with error
reporter = new TestReporter();
sourceValidator.validate(context, reporter);
assertTrue("There should be validation errors on " + testFile, reporter.isMessageReported());
// replace -->
document.replace(endCommentIndex, 0, "-->");
// validate clean file
reporter = new TestReporter();
sourceValidator.validate(context, reporter);
assertFalse("There should be no validation errors on " + testFile, reporter.isMessageReported());
} catch (ValidationException e) {
fail("Could not validate test file " + testFile + ": " + e.getMessage());
} finally {
if (model != null) {
model.releaseFromEdit();
}
}
project.delete(true, null);
}
Aggregations