Search in sources :

Example 6 with WorkbenchContext

use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.

the class TestDelegatingSourceValidatorForXSL method testXSLFunctionsWithParms.

@Test
public void testXSLFunctionsWithParms() throws Exception {
    String fileName = "bug290286.xsl";
    WorkbenchContext context = setupFile(getxslTestFilesProjectName(), fileName);
    TestReporter reporter = new TestReporter();
    sourceValidator.validate(context, reporter);
    assertFalse("Errors reported with XSLT 2.0 with Functions: " + fileName + ".", reporter.isMessageReported());
}
Also used : WorkbenchContext(org.eclipse.wst.validation.internal.operations.WorkbenchContext) Test(org.junit.Test) AbstractXSLUITest(org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)

Example 7 with WorkbenchContext

use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.

the class TestDelegatingSourceValidatorForXML method testValidateAgainstDTD.

/**
 * Regression test for Bug 276337
 */
public void testValidateAgainstDTD() throws Exception {
    String projectName = "TestValidateAgainstDTD";
    IProject project = ProjectUtil.createProject(projectName, XMLUITestsPlugin.getDefault().getStateLocation().append(getName()), null);
    IFile testFile = null;
    try {
        // get test file
        ProjectUtil.copyBundleEntriesIntoWorkspace("testresources/TestValidateAgainstDTD", projectName);
        testFile = project.getFile("simple.xml");
        assertTrue("Test file " + testFile + " does not exist", testFile.exists());
        // set up for validator
        WorkbenchContext context = new WorkbenchContext();
        List fileList = new ArrayList();
        fileList.add(testFile.getFullPath().toPortableString());
        context.setValidationFileURIs(fileList);
        // validate file, there should be one error
        TestReporter reporter = new TestReporter();
        sourceValidator.validate(context, reporter);
        assertFalse("There should be an error message reported for not conforming to the DTD " + testFile, !reporter.isMessageReported());
    } catch (ValidationException e) {
        fail("Could not validate test file " + testFile + ": " + e.getMessage());
    }
    project.delete(true, null);
}
Also used : IFile(org.eclipse.core.resources.IFile) ValidationException(org.eclipse.wst.validation.internal.core.ValidationException) WorkbenchContext(org.eclipse.wst.validation.internal.operations.WorkbenchContext) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) IProject(org.eclipse.core.resources.IProject)

Example 8 with WorkbenchContext

use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.

the class TestDelegatingSourceValidatorForXML method testNon8BitChars.

/**
 * Test that files that contain non-8bit chars are validated
 * correctly. i.e. Do not produce incorrect validation messages.
 */
public void testNon8BitChars() {
    String projName = "Project";
    String fileName1 = "international-instance.xml";
    String fileName2 = "international.xsd";
    IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject(projName);
    if (!project.isAccessible()) {
        IProjectDescription description = ResourcesPlugin.getWorkspace().newProjectDescription(projName);
        try {
            project.create(description, new NullProgressMonitor());
            project.open(new NullProgressMonitor());
        } catch (CoreException e) {
            e.printStackTrace();
        }
    }
    IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(projName + "/" + fileName1));
    if (file != null && !file.exists()) {
        try {
            file.create(FileLocator.openStream(XMLUITestsPlugin.getDefault().getBundle(), new Path("/testresources/Non8BitChars/international-instance.xml"), false), true, new NullProgressMonitor());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    file = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(projName + "/" + fileName2));
    if (file != null && !file.exists()) {
        try {
            file.create(FileLocator.openStream(XMLUITestsPlugin.getDefault().getBundle(), new Path("/testresources/Non8BitChars/international.xsd"), false), true, new NullProgressMonitor());
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    WorkbenchContext context = new WorkbenchContext();
    List fileList = new ArrayList();
    fileList.add("/" + projName + "/" + fileName1);
    context.setValidationFileURIs(fileList);
    TestReporter reporter = new TestReporter();
    try {
        sourceValidator.validate(context, reporter);
    } catch (ValidationException e) {
        e.printStackTrace();
    }
    assertFalse("Messages were reported on valid file 1.", reporter.isMessageReported());
    WorkbenchContext context2 = new WorkbenchContext();
    List fileList2 = new ArrayList();
    fileList2.add("/" + projName + "/" + fileName2);
    context2.setValidationFileURIs(fileList2);
    TestReporter reporter2 = new TestReporter();
    try {
        sourceValidator.validate(context2, reporter2);
    } catch (ValidationException e) {
        e.printStackTrace();
    }
    assertFalse("Messages were reported on valid file 2.", reporter2.isMessageReported());
}
Also used : Path(org.eclipse.core.runtime.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IFile(org.eclipse.core.resources.IFile) ValidationException(org.eclipse.wst.validation.internal.core.ValidationException) ArrayList(java.util.ArrayList) IProject(org.eclipse.core.resources.IProject) ValidationException(org.eclipse.wst.validation.internal.core.ValidationException) CoreException(org.eclipse.core.runtime.CoreException) CoreException(org.eclipse.core.runtime.CoreException) IProjectDescription(org.eclipse.core.resources.IProjectDescription) WorkbenchContext(org.eclipse.wst.validation.internal.operations.WorkbenchContext) ArrayList(java.util.ArrayList) List(java.util.List)

Example 9 with WorkbenchContext

use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.

the class TestDelegatingSourceValidatorForXSL method testXSLT2_2Passes.

@Test
public void testXSLT2_2Passes() throws Exception {
    String fileName1 = "ChangeRequestsByStatus.xsl";
    WorkbenchContext context = setupFile(getxslTestFilesProjectName(), fileName1);
    TestReporter reporter = new TestReporter();
    sourceValidator.validate(context, reporter);
    assertFalse("Messages were reported on file with valid XSLT 2.0", reporter.isMessageReported());
}
Also used : WorkbenchContext(org.eclipse.wst.validation.internal.operations.WorkbenchContext) Test(org.junit.Test) AbstractXSLUITest(org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)

Example 10 with WorkbenchContext

use of org.eclipse.wst.validation.internal.operations.WorkbenchContext in project webtools.sourceediting by eclipse.

the class TestDelegatingSourceValidatorForXSL method testXSLT2XPathPasses.

@Test
public void testXSLT2XPathPasses() throws Exception {
    String fileName1 = "ChangeRequestsByResponsibility.xsl";
    WorkbenchContext context = setupFile(getxslTestFilesProjectName(), fileName1);
    TestReporter reporter = new TestReporter();
    sourceValidator.validate(context, reporter);
    assertFalse("Messages were reported on file with valid XPath 2.0", reporter.isMessageReported());
}
Also used : WorkbenchContext(org.eclipse.wst.validation.internal.operations.WorkbenchContext) Test(org.junit.Test) AbstractXSLUITest(org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)

Aggregations

WorkbenchContext (org.eclipse.wst.validation.internal.operations.WorkbenchContext)14 ArrayList (java.util.ArrayList)8 List (java.util.List)8 IFile (org.eclipse.core.resources.IFile)7 AbstractXSLUITest (org.eclipse.wst.xsl.ui.tests.AbstractXSLUITest)6 Test (org.junit.Test)6 IStructuredModel (org.eclipse.wst.sse.core.internal.provisional.IStructuredModel)5 IProject (org.eclipse.core.resources.IProject)4 IStructuredDocument (org.eclipse.wst.sse.core.internal.provisional.text.IStructuredDocument)4 ValidationException (org.eclipse.wst.validation.internal.core.ValidationException)4 Path (org.eclipse.core.runtime.Path)2 PrintWriter (java.io.PrintWriter)1 StringWriter (java.io.StringWriter)1 IProjectDescription (org.eclipse.core.resources.IProjectDescription)1 CoreException (org.eclipse.core.runtime.CoreException)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 JSPContentSourceValidator (org.eclipse.jst.jsp.ui.internal.validation.JSPContentSourceValidator)1