1 19 20 package org.netbeans.modules.xml.dtd.grammar; 21 22 import java.io.*; 23 import java.net.*; 24 import java.util.*; 25 import org.xml.sax.*; 26 import org.xml.sax.ext.*; 27 import org.xml.sax.helpers.*; 28 import org.openide.xml.*; 29 import org.openide.util.Lookup; 30 import org.netbeans.modules.xml.core.tree.ModuleEntityResolver; 31 import junit.framework.*; 32 33 41 public class DTDParserTest extends TestCase { 42 43 public DTDParserTest(java.lang.String testName) { 44 super(testName); 45 } 46 47 public void testParse() { 48 49 try { 50 DTDParser parser = new DTDParser(); 51 InputSource in = new InputSource(); 52 URL url = getClass().getResource("email.xml"); 53 in.setSystemId(url.toExternalForm()); 54 in.setByteStream(url.openConnection().getInputStream()); 55 DTDGrammar dtd = parser.parse(in); 56 57 assertTrue("Missing entity!", dtd.entities.contains("testExternalEntity")); 58 assertTrue("Missing notation!", dtd.notations.contains("testNotation")); 59 assertTrue("Missing element!", dtd.elementDecls.keySet().contains("testANYElement")); 60 assertTrue("Missing attribute!", dtd.attrDecls.keySet().contains("subject")); 61 62 Set all = (Set) dtd.elementDecls.get("testANYElement"); 64 assertTrue("ANY must contain all declared!", all.containsAll(dtd.elementDecls.keySet())); 65 66 assertTrue("EMPTY must be empty!", ((Set)dtd.elementDecls.get("attachment")).isEmpty()); 68 69 assertTrue("#PCDATA must be empty!", ((Set)dtd.elementDecls.get("name")).isEmpty()); 71 72 } catch (Exception ex) { 73 ex.printStackTrace(); 75 fail(ex.toString()); 76 } 77 78 } 79 80 } 81 | Popular Tags |