1 27 package org.htmlparser.tests.tagTests; 28 29 import org.htmlparser.PrototypicalNodeFactory; 30 import org.htmlparser.Tag; 31 import org.htmlparser.tests.ParserTestCase; 32 import org.htmlparser.util.ParserException; 33 34 public class EndTagTest extends ParserTestCase { 35 36 static 37 { 38 System.setProperty ("org.htmlparser.tests.tagTests.EndTagTest", "EndTagTest"); 39 } 40 41 public EndTagTest(String name) { 42 super(name); 43 } 44 45 public void testToHTML() throws ParserException { 46 createParser("<HTML></HTML>"); 47 parser.setNodeFactory (new PrototypicalNodeFactory (true)); 48 parseAndAssertNodeCount(2); 49 assertTrue("Node should be a Tag",node[1] instanceof Tag); 51 Tag endTag = (Tag)node[1]; 52 assertTrue("Node should be an end Tag",endTag.isEndTag ()); 53 assertEquals("Raw String","</HTML>",endTag.toHtml()); 54 } 55 56 public void testEndTagFind() throws ParserException { 57 String testHtml = 58 "<SCRIPT>document.write(d+\".com\")</SCRIPT><BR>"; 59 createParser(testHtml); 60 parser.setNodeFactory (new PrototypicalNodeFactory (true)); 61 int pos = testHtml.indexOf("</SCRIPT>"); 62 parseAndAssertNodeCount(4); 63 assertTrue("Node should be a Tag",node[2] instanceof Tag); 64 Tag endTag = (Tag)node[2]; 65 assertTrue("Node should be an end Tag",endTag.isEndTag ()); 66 assertEquals("endtag element begin",pos,endTag.getStartPosition ()); 67 assertEquals("endtag element end",pos+9,endTag.getEndPosition ()); 68 } 69 } 70
| Popular Tags
|