1 23 24 package org.enhydra.xml.xmlc.html; 25 import java.io.File ; 26 import java.lang.reflect.Method ; 27 28 import junit.framework.Test; 29 30 import org.enhydra.xml.driver.TestError; 31 import org.enhydra.xml.driver.TestFileOps; 32 import org.enhydra.xml.xmlc.XMLObject; 33 import org.enhydra.xml.xmlc.driver.ExecXmlc; 34 35 38 public class MiscOptionsTests extends HtmlTestCaseBase { 39 40 public static Test suite() { 41 return createSuite(MiscOptionsTests.class, null); 42 } 43 44 45 public MiscOptionsTests(Method method) { 46 super(method); 47 } 48 49 53 private abstract class OptTest { 54 protected ExecXmlc fExecXmlc; 55 56 57 protected OptTest() { 58 fExecXmlc = new ExecXmlc(MiscOptionsTests.this); 59 fExecXmlc.addOpt(ExecXmlc.OPT_DEST_DIR, 60 getClassRoot().getPath()); 61 } 62 63 64 protected void addClass() { 65 fExecXmlc.addOpt(ExecXmlc.OPT_CLASS, getTestClass()); 66 } 67 68 69 protected void setTestPage1() { 70 fExecXmlc.setSrcFile(getInputFile("testPage1.html")); 71 } 72 73 74 protected void compile() { 75 fExecXmlc.compile(getResultFile(COMPILE_OUTPUT_EXT)); 76 getDiffer().diff(getExpectedFile(COMPILE_OUTPUT_EXT), 77 getResultFile(COMPILE_OUTPUT_EXT)); 78 } 79 80 84 public void basicTest() { 85 addClass(); 86 setTestPage1(); 87 compile(); 88 } 89 90 91 public abstract void run(); 92 } 93 94 97 public void test1() { 98 HtmlBasicTest test = createTest("proptags1.html"); 99 test.addOptionFile(getInputFile("proptags1.xmlc")); 100 test.basicTest(); 101 } 102 103 106 public void test2() { 107 new OptTest() { 108 public void run() { 109 File genSrcFile = getGenSrcFile(); 111 removeFile(genSrcFile); 112 File genClassFile = getGenClassFile(); 113 removeFile(genClassFile); 114 115 fExecXmlc.addOpt(ExecXmlc.OPT_SOURCE_OUT, 116 getGenSourceDir().getPath()); 117 fExecXmlc.addOpt(ExecXmlc.OPT_KEEP); 118 basicTest(); 119 verifyExists(genSrcFile); 120 verifyExists(genClassFile); 121 } 122 }.run(); 123 } 124 125 128 public void test3() { 129 new OptTest() { 130 public void run() { 131 File genClassFile = new File (getClassRoot(), 133 "testPage1.class"); 134 removeFile(genClassFile); 135 setTestPage1(); 136 compile(); 137 verifyExists(genClassFile); 138 } 139 }.run(); 140 } 141 142 145 public void test4() { 146 HtmlBasicTest test = createTest("testPage1.html"); 147 test.addCyberStudioTags(); 148 test.addOptionFile(getInputFile("test-11.1a.xmlc")); 149 test.addOptionFile(getInputFile("test-11.1b.xmlc")); 150 test.basicTest(); 151 } 152 153 156 public void test5() { 157 HtmlBasicTest test = createLutrisIndexTest(); 158 test.addCyberStudioTags(); 159 test.addBoth("-html:old-class-constants"); 160 test.addBoth("-html:old-name-constants"); 161 test.addOptionFile(getInputFile("lutris-index1.xmlc")); 162 test.basicTest(); 163 } 164 165 168 public void test6() { 169 new OptTest() { 170 public void run() { 171 fExecXmlc.addOpt(ExecXmlc.OPT_JAVAC_FLAG, "-nowarn"); 172 basicTest(); 173 } 174 }.run(); 175 } 176 177 180 public void test7() { 181 if (!fParams.getUsingJikes()) { 183 new OptTest() { 184 public void run() { 185 fExecXmlc.addOpt(ExecXmlc.OPT_JAVAC_OPT); 186 fExecXmlc.addOpt("-encoding", "US-ASCII"); 187 basicTest(); 188 } 189 }.run(); 190 } 191 } 192 193 196 public void test8() { 197 new OptTest() { 198 public void run() { 199 fExecXmlc.setDomOpt(ExecXmlc.OPT_DOM, getParams().getDom()); 200 basicTest(); 201 XMLObject doc = loadTestDocument(getTestClass()); 202 dumpVerifyDom(doc, DOC_DOM_DUMP_EXT); 203 } 204 }.run(); 205 } 206 207 210 public void test9() { 211 new OptTest() { 212 public void run() { 213 if (getParams().getDom().equals(ExecXmlc.XERCES_DOM)) { 214 fExecXmlc.setDomOpt(ExecXmlc.OPT_DOM_FACTORY, 215 ExecXmlc.XERCES_HTML_DOM_FACTORY); 216 } else if (getParams().getDom().equals(ExecXmlc.LAZY_DOM)) { 217 fExecXmlc.setDomOpt(ExecXmlc.OPT_DOM_FACTORY, 218 ExecXmlc.LAZY_HTML_DOM_FACTORY); 219 } else { 220 throw new TestError("bug in test: unknown DOM: \"" 221 + getParams().getDom() + "\""); 222 } 223 basicTest(); 224 XMLObject doc = loadTestDocument(getTestClass()); 225 dumpVerifyDom(doc, DOC_DOM_DUMP_EXT); 226 } 227 }.run(); 228 } 229 230 234 public void test10() { 235 new OptTest() { 236 public void run() { 237 fExecXmlc.addOpt(ExecXmlc.OPT_NO_COMPILE); 238 fExecXmlc.addOpt(ExecXmlc.OPT_VERBOSE); 239 basicTest(); 240 } 241 }.run(); 242 } 243 244 247 public void test11() { 248 HtmlBasicTest test = createLutrisIndexTest(); 249 test.addBoth(ExecXmlc.OPT_CREATE_GET_TAG_METHODS); 250 test.basicTest(); 251 } 252 253 256 public void test12() { 257 HtmlBasicTest test = createTest("testPage1.html"); 258 test.addBoth(ExecXmlc.OPT_CREATE_GET_TAG_METHODS); 259 test.addBoth(ExecXmlc.OPT_METHODS); 260 test.basicTest(); 261 } 262 263 266 public void test13() { 267 HtmlBasicTest test = createLutrisIndexTest(); 268 test.addBoth(ExecXmlc.OPT_WARNINGS, "false"); 269 test.basicTest(); 270 } 271 272 275 public void test14() { 276 new OptTest() { 277 public void run() { 278 File docOut = getResultFile("docout.html"); 279 TestFileOps.ensureFileDir(docOut); 280 fExecXmlc.addOpt(ExecXmlc.OPT_DOC_OUT, docOut.getPath()); 281 fExecXmlc.addOpt(ExecXmlc.OPT_NO_COMPILE); 282 setTestPage1(); 283 compile(); 284 parseVerifyDom(docOut); 285 } 286 }.run(); 287 } 288 289 292 public void test16() { 293 HtmlBasicTest test = createTest("FrameSet.html"); 294 test.addBoth("-html:frameset"); 295 test.basicTest(); 296 } 297 298 } 299 | Popular Tags |