1 23 24 package org.enhydra.xml.xmlc.xml; 25 import java.io.File ; 26 import java.lang.reflect.Method ; 27 28 import junit.framework.Test; 29 30 import org.enhydra.xml.driver.TestException; 31 import org.enhydra.xml.xmlc.XMLObject; 32 import org.enhydra.xml.xmlc.driver.ExecXmlc; 33 import org.w3c.dom.DocumentType ; 34 35 38 public class MiscTests extends XmlTestCaseBase { 39 40 41 public static Test suite() { 42 return createSuite(MiscTests.class, null); 43 } 44 45 46 public MiscTests(Method method) { 47 super(method); 48 } 49 50 54 public void test1() { 55 XmlBasicTest test 56 = new XmlBasicTest(this, getInputFile("xcatalog/index.wml"), null); 57 test.setCompileShouldFail(); 58 test.basicTest(); 59 } 60 61 64 public void test2() { 65 XmlBasicTest test 66 = new XmlBasicTest(this, getInputFile("xcatalog/index.wml"), null); 67 test.addBoth(ExecXmlc.OPT_XCATALOG, 68 getInputFile("xcatalog/wml.xcat")); 69 test.basicTest(); 70 } 71 72 75 private void disable_test3() { 76 XmlBasicTest test 78 = new XmlBasicTest(this, getInputFile("file:input/xml-examples/6-1.xml"), 79 getInputFile("xml-examples/document.dtd")); 80 test.basicTest(); 81 } 82 83 86 private void disable_test4() { 87 XmlBasicTest test 89 = new XmlBasicTest(this, getInputFile("file:../xml/input/xml-examples/6-1.xml"), 90 getInputFile("xml-examples/document.dtd")); 91 test.basicTest(); 92 } 93 94 97 private void disable_test5() { 98 XmlBasicTest test 100 = new XmlBasicTest(this, 101 getInputFile("file:../../xmlc/xml/input/xml-examples/6-1.xml"), 102 getInputFile("../xml/input/xml-examples/document.dtd")); 103 test.basicTest(); 104 } 105 106 109 public void test6() { 110 XmlBasicTest test 111 = new XmlBasicTest(this, getInputFile("bioml/small-ssi.bioml"), 112 getInputFile("bioml/bioml.dtd")); 113 test.basicTest(); 114 } 115 116 119 public void test7() { 120 XmlBasicTest test 121 = new XmlBasicTest(this, getInputFile("bioml/small-ssi.bioml"), 122 getInputFile("bioml/bioml.dtd")); 123 test.addBoth(ExecXmlc.OPT_SSI); 124 test.basicTest(); 125 } 126 127 130 public void test8() { 131 XmlBasicTest test 132 = new XmlBasicTest(this, getInputFile("bioml/error-ssi.bioml"), 133 getInputFile("bioml/bioml.dtd")); 134 test.setCompileShouldFail(); 135 test.addBoth(ExecXmlc.OPT_SSI); 136 test.basicTest(); 137 } 138 139 142 public void test9() { 143 XmlBasicTest test 144 = new XmlBasicTest(this, getInputFile("bioml/space-preserve.bioml"), 145 getInputFile("bioml/bioml.dtd")); 146 test.basicTest(); 147 } 148 149 156 public void test10() throws TestException { 157 ExecXmlc execXmlc = new ExecXmlc(this); 159 execXmlc.addOpt(ExecXmlc.OPT_CLASS, getTestClass()); 160 execXmlc.addOpt(ExecXmlc.OPT_DEST_DIR, getClassRoot()); 161 execXmlc.addClassPath(getClassRoot()); 162 execXmlc.setSrcFile(getInputFile("regression/Error.xml")); 163 if (getParams().getReloading()) { 164 execXmlc.addOpt(ExecXmlc.OPT_FOR_RECOMP); 165 } 166 if (true) { 167 execXmlc.addOpt(ExecXmlc.OPT_SOURCE_OUT, 169 getGenSourceDir().getPath()); 170 execXmlc.addOpt(ExecXmlc.OPT_KEEP); 171 execXmlc.addOpt(ExecXmlc.OPT_DUMP); 172 } 173 174 File outFile = getResultFile("compile.out"); 175 File expectFile = getExpectedFile("compile.out"); 176 execXmlc.compile(outFile); 177 getDiffer().diff(expectFile, outFile); 178 179 XMLObject doc = loadTestDocument(getTestClass()); 181 182 String docTypeSystemId = "AirSent.dtd"; 184 DocumentType docType = doc.getDoctype(); 185 if (docType == null) { 186 throw new TestException("no document type node"); 187 } else if (!docType.getSystemId().equals(docTypeSystemId)) { 188 throw new TestException("Incorrect document type system id: expected \"" 189 + docTypeSystemId + "\", got \"" 190 + docType.getSystemId() + "\""); 191 } 192 193 try { 195 Method setText = doc.getClass().getMethod("setTextErrorMessage", 196 new Class []{String .class}); 197 setText.invoke(doc, new Object []{"game over, man"}); 198 } catch (Exception except) { 199 throw new TestException(except); 200 } 201 } 202 } 203 | Popular Tags |