[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/tagTests TagTest.java,1.44,1.45
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-10-02 23:49:05
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests In directory sc8-pr-cvs1:/tmp/cvs-serv28867/tests/tagTests Modified Files: TagTest.java Log Message: Moved SpecialHashTable to util. Fixed some attribute bugs and some test cases. Index: TagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/TagTest.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** TagTest.java 28 Sep 2003 15:33:59 -0000 1.44 --- TagTest.java 2 Oct 2003 23:48:53 -0000 1.45 *************** *** 40,43 **** --- 40,44 ---- import org.htmlparser.util.NodeIterator; import org.htmlparser.util.ParserException; + import org.htmlparser.util.SpecialHashtable; public class TagTest extends ParserTestCase *************** *** 54,63 **** */ public void testBodyTagBug1() throws ParserException { ! createParser("<BODY aLink=#ff0000 bgColor=#ffffff link=#0000cc onload=setfocus() text=#000000\nvLink=#551a8b>"); parseAndAssertNodeCount(1); // The node should be an Tag assertTrue("Node should be a Tag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; ! assertEquals("Contents of the tag","BODY aLink=#ff0000 bgColor=#ffffff link=#0000cc onload=setfocus() text=#000000\r\nvLink=#551a8b",tag.getText()); } --- 55,67 ---- */ public void testBodyTagBug1() throws ParserException { ! String body = "BODY aLink=#ff0000 bgColor=#ffffff link=#0000cc " ! + "onload=setfocus() text=#000000\nvLink=#551a8b"; ! createParser("<" + body + ">"); parseAndAssertNodeCount(1); // The node should be an Tag assertTrue("Node should be a Tag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; ! String text = tag.getText(); ! assertEquals("Contents of the tag",body,text); } *************** *** 71,79 **** */ public void testLargeTagBug() throws ParserException { ! createParser( ! "<MYTAG abcd\n"+ "efgh\n"+ "ijkl\n"+ ! "mnop>" ); parseAndAssertNodeCount(1); --- 75,84 ---- */ public void testLargeTagBug() throws ParserException { ! String mytag = "MYTAG abcd\n"+ "efgh\n"+ "ijkl\n"+ ! "mnop"; ! createParser( ! "<" + mytag + ">" ); parseAndAssertNodeCount(1); *************** *** 81,85 **** assertTrue("Node should be a Tag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; ! assertEquals("Contents of the tag","MYTAG abcd\r\nefgh\r\nijkl\r\nmnop",tag.getText()); --- 86,90 ---- assertTrue("Node should be a Tag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; ! assertEquals("Contents of the tag",mytag,tag.getText()); *************** *** 152,156 **** tag = (Tag)node; h = tag.getAttributes(); ! a = (String)h.get(Tag.TAGNAME); href = (String)h.get("HREF"); myValue = (String)h.get("MYPARAMETER"); --- 157,161 ---- tag = (Tag)node; h = tag.getAttributes(); ! a = (String)h.get(SpecialHashtable.TAGNAME); href = (String)h.get("HREF"); myValue = (String)h.get("MYPARAMETER"); *************** *** 222,226 **** tag = (Tag)node; h = tag.getAttributes(); ! a = (String)h.get(Tag.TAGNAME); href = (String)h.get("HREF"); myValue = (String)h.get("MYPARAMETER"); --- 227,231 ---- tag = (Tag)node; h = tag.getAttributes(); ! a = (String)h.get(SpecialHashtable.TAGNAME); href = (String)h.get("HREF"); myValue = (String)h.get("MYPARAMETER"); *************** *** 290,294 **** tag = (Tag)node; h = tag.getAttributes(); ! a = (String)h.get(Tag.TAGNAME); nice = (String)h.get("YOURPARAMETER"); assertEquals ("Link tag (A)",a,"A"); --- 295,299 ---- tag = (Tag)node; h = tag.getAttributes(); ! a = (String)h.get(SpecialHashtable.TAGNAME); nice = (String)h.get("YOURPARAMETER"); assertEquals ("Link tag (A)",a,"A"); *************** *** 354,376 **** public void testToHTML() throws ParserException { ! String testHTML = new String( ! "<MYTAG abcd\n"+ "efgh\n"+ "ijkl\n"+ ! "mnop>\n"+ "<TITLE>Hello</TITLE>\n"+ ! "<A HREF=\"Hello.html\">Hey</A>" ! ); createParser(testHTML); ! parseAndAssertNodeCount(7); // The node should be an Tag assertTrue("1st Node should be a Tag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; ! assertStringEquals("toHTML()","<MYTAG EFGH ABCD MNOP IJKL>",tag.toHtml()); ! assertTrue("2nd Node should be a Tag",node[1] instanceof Tag); ! assertTrue("5th Node should be a Tag",node[4] instanceof Tag); ! tag = (Tag)node[1]; assertEquals("Raw String of the tag","<TITLE>",tag.toHtml()); ! tag = (Tag)node[4]; assertEquals("Raw String of the tag","<A HREF=\"Hello.html\">",tag.toHtml()); } --- 359,381 ---- public void testToHTML() throws ParserException { ! String tag1 = "<MYTAG abcd\n"+ "efgh\n"+ "ijkl\n"+ ! "mnop>"; ! String testHTML = tag1 + ! "\n"+ "<TITLE>Hello</TITLE>\n"+ ! "<A HREF=\"Hello.html\">Hey</A>"; createParser(testHTML); ! parseAndAssertNodeCount(9); // The node should be an Tag assertTrue("1st Node should be a Tag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; ! assertStringEquals("toHTML()",tag1,tag.toHtml()); ! assertTrue("3rd Node should be a Tag",node[2] instanceof Tag); ! assertTrue("5th Node should be a Tag",node[6] instanceof Tag); ! tag = (Tag)node[2]; assertEquals("Raw String of the tag","<TITLE>",tag.toHtml()); ! tag = (Tag)node[6]; assertEquals("Raw String of the tag","<A HREF=\"Hello.html\">",tag.toHtml()); } *************** *** 676,680 **** Hashtable tempHash = tag.getAttributes (); ! tempHash.put ("BORDER","1"); tag.setAttributes (tempHash); --- 681,685 ---- Hashtable tempHash = tag.getAttributes (); ! tempHash.put ("BORDER","\"1\""); tag.setAttributes (tempHash); |