1 17 package org.apache.tools.ant.taskdefs.optional; 18 19 import org.apache.tools.ant.BuildException; 20 import org.apache.tools.ant.BuildFileTest; 21 22 30 public class XmlValidateTest extends BuildFileTest { 31 32 35 private final static String TASKDEFS_DIR = 36 "src/etc/testcases/taskdefs/optional/"; 37 38 43 public XmlValidateTest(String name) { 44 super(name); 45 } 46 47 50 public void setUp() { 51 configureProject(TASKDEFS_DIR + "xmlvalidate.xml"); 52 } 53 54 57 public void tearDown() {} 58 59 62 public void testValidate() throws Exception { 63 executeTarget("testValidate"); 64 } 65 66 69 public void testDeepValidate() throws Exception { 70 executeTarget("testDeepValidate"); 71 } 72 73 76 public void testXmlCatalog() { 77 executeTarget("xmlcatalog"); 78 } 79 80 83 public void testXmlCatalogViaRefid() { 84 executeTarget("xmlcatalogViaRefid"); 85 } 86 87 91 public void testXmlCatalogFiles() { 92 executeTarget("xmlcatalogfiles-override"); 93 } 94 95 100 public void testXmlCatalogPath() { 101 executeTarget("xmlcatalogpath-override"); 102 } 103 104 107 public void testXmlCatalogNested() { 108 executeTarget("xmlcatalognested"); 109 } 110 111 114 public void testXmlSchemaGood() throws BuildException { 115 try { 116 executeTarget("testSchemaGood"); 117 } catch (BuildException e) { 118 if (e 119 .getMessage() 120 .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema") 121 || e.getMessage().endsWith( 122 " doesn't support feature http://apache.org/xml/features/validation/schema")) { 123 System.err.println(" skipped, parser doesn't support schema"); 124 } else { 125 throw e; 126 } 127 } 128 } 129 132 public void testXmlSchemaBad() { 133 try { 134 executeTarget("testSchemaBad"); 135 fail("Should throw BuildException because 'Bad Schema Validation'"); 136 137 expectBuildExceptionContaining( 138 "testSchemaBad", 139 "Bad Schema Validation", 140 "not a valid XML document"); 141 } catch (BuildException e) { 142 if (e 143 .getMessage() 144 .endsWith(" doesn't recognize feature http://apache.org/xml/features/validation/schema") 145 || e.getMessage().endsWith( 146 " doesn't support feature http://apache.org/xml/features/validation/schema")) { 147 System.err.println(" skipped, parser doesn't support schema"); 148 } else { 149 assertTrue( 150 e.getMessage().indexOf("not a valid XML document") > -1); 151 } 152 } 153 } 154 155 161 public void testIso2022Jp() { 162 executeTarget("testIso2022Jp"); 163 } 164 165 172 public void testUtf8() { 173 expectBuildException("testUtf8", "invalid characters in file"); 174 } 175 176 178 public void testPropertySchemaForValidXML() { 179 executeTarget("testProperty.validXML"); 180 } 181 182 public void testPropertySchemaForInvalidXML() { 183 expectBuildException( 184 "testProperty.invalidXML", 185 "XML file does not satisfy schema."); 186 } 187 188 } 189 | Popular Tags |