FileDocCategorySizeDatePackage
XmlValidateTest.javaAPI DocApache Ant 1.705412Wed Dec 13 06:16:20 GMT 2006org.apache.tools.ant.taskdefs.optional

XmlValidateTest

public class XmlValidateTest extends org.apache.tools.ant.BuildFileTest
Tests the XMLValidate optional task, by running targets in the test script src/etc/testcases/taskdefs/optional/xmlvalidate.xml

see
XmlValidateCatalogTest
since
Ant 1.5

Fields Summary
private static final String
TASKDEFS_DIR
where tasks run
Constructors Summary
public XmlValidateTest(String name)
Constructor

param
name testname


             
       
        super(name);
    
Methods Summary
public voidsetUp()
The JUnit setup method

        configureProject(TASKDEFS_DIR + "xmlvalidate.xml");
    
public voidtearDown()
The teardown method for JUnit

public voidtestDeepValidate()
Test indirect validation.

        executeTarget("testDeepValidate");
    
public voidtestIso2022Jp()
iso-2022-jp.xml is valid but wouldn't get recognized on systems with a different native encoding. Bug 11279

        executeTarget("testIso2022Jp");
    
public voidtestPropertySchemaForInvalidXML()

        expectBuildException(
            "testProperty.invalidXML",
            "XML file does not satisfy schema.");
    
public voidtestPropertySchemaForValidXML()

        executeTarget("testProperty.validXML");
    
public voidtestUtf8()
utf-8.xml is invalid as it contains non-UTF-8 characters, but would pass on systems with a native iso-8859-1 (or similar) encoding. Bug 11279

        expectBuildException("testUtf8", "invalid characters in file");
    
public voidtestValidate()
Basic inline 'dtd' element test.

        executeTarget("testValidate");
    
public voidtestXmlCatalog()

        executeTarget("xmlcatalog");
    
public voidtestXmlCatalogFiles()
Test that the nested dtd element is used when resolver.jar is not present. This test should pass either way.

        executeTarget("xmlcatalogfiles-override");
    
public voidtestXmlCatalogNested()
Test nested xmlcatalog definitions

        executeTarget("xmlcatalognested");
    
public voidtestXmlCatalogPath()
Test nested catalogpath. Test that the nested dtd element is used when resolver.jar is not present. This test should pass either way.

        executeTarget("xmlcatalogpath-override");
    
public voidtestXmlCatalogViaRefid()

        executeTarget("xmlcatalogViaRefid");
    
public voidtestXmlSchemaBad()
Test xml schema validation

        try {
            executeTarget("testSchemaBad");
            fail("Should throw BuildException because 'Bad Schema Validation'");

            expectBuildExceptionContaining(
                "testSchemaBad",
                "Bad Schema Validation",
                "not a valid XML document");
        } catch (BuildException e) {
            if (e
                .getMessage()
                .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
                || e.getMessage().endsWith(
                    " doesn't support feature http://apache.org/xml/features/validation/schema")) {
                System.err.println(" skipped, parser doesn't support schema");
            } else {
                assertTrue(
                    e.getMessage().indexOf("not a valid XML document") > -1);
            }
        }
    
public voidtestXmlSchemaGood()
Test xml schema validation

        try {
            executeTarget("testSchemaGood");
        } catch (BuildException e) {
            if (e
                .getMessage()
                .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema")
                || e.getMessage().endsWith(
                    " doesn't support feature http://apache.org/xml/features/validation/schema")) {
                System.err.println(" skipped, parser doesn't support schema");
            } else {
                throw e;
            }
        }