[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/tagTests BulletListTagTest.java,1.2,1.3 Composi
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2004-05-24 16:19:17
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19028/src/org/htmlparser/tests/tagTests Modified Files: BulletListTagTest.java CompositeTagTest.java FormTagTest.java ImageTagTest.java LinkTagTest.java OptionTagTest.java StyleTagTest.java TagTest.java Log Message: Part three of a multiphase refactoring. The three node types are now fronted by interfaces (program to the interface paradigm) with concrete implementations in the new htmlparser.nodes package. Classes from the lexer.nodes package are moved to this package, and obvious references to the concrete classes that got broken by this have been changed to use the interfaces where possible. Index: StyleTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/StyleTagTest.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** StyleTagTest.java 29 Feb 2004 14:16:27 -0000 1.36 --- StyleTagTest.java 24 May 2004 16:18:33 -0000 1.37 *************** *** 28,32 **** import org.htmlparser.Parser; ! import org.htmlparser.StringNode; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; --- 28,32 ---- import org.htmlparser.Parser; ! import org.htmlparser.Text; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; *************** *** 150,154 **** "</style>"; StyleTag tag; ! StringNode string; createParser (html); --- 150,154 ---- "</style>"; StyleTag tag; ! Text string; createParser (html); *************** *** 157,162 **** tag = (StyleTag)node[0]; assertTrue ("STYLE tag should have one child", 1 == tag.getChildCount ()); ! assertTrue ("Child should be a StringNode", tag.getChild (0) instanceof StringNode); ! string = (StringNode)tag.getChild (0); assertStringEquals ("Style text incorrect", style, string.toHtml ()); } --- 157,162 ---- tag = (StyleTag)node[0]; assertTrue ("STYLE tag should have one child", 1 == tag.getChildCount ()); ! assertTrue ("Child should be a StringNode", tag.getChild (0) instanceof Text); ! string = (Text)tag.getChild (0); assertStringEquals ("Style text incorrect", style, string.toHtml ()); } Index: FormTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/FormTagTest.java,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** FormTagTest.java 2 Jan 2004 16:24:57 -0000 1.43 --- FormTagTest.java 24 May 2004 16:18:33 -0000 1.44 *************** *** 27,36 **** package org.htmlparser.tests.tagTests; - import org.htmlparser.AbstractNode; import org.htmlparser.Node; import org.htmlparser.Parser; - import org.htmlparser.StringNode; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.RemarkNode; import org.htmlparser.filters.NodeClassFilter; import org.htmlparser.tags.BodyTag; --- 27,35 ---- package org.htmlparser.tests.tagTests; import org.htmlparser.Node; import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.Remark; ! import org.htmlparser.Text; import org.htmlparser.filters.NodeClassFilter; import org.htmlparser.tags.BodyTag; *************** *** 223,227 **** assertTrue("Should be a HTMLFormTag",node[0] instanceof FormTag); NodeList remarkNodes = new NodeList (); ! NodeClassFilter filter = new NodeClassFilter (RemarkNode.class); for (NodeIterator e = ((FormTag)node[0]).children (); e.hasMoreNodes ();) e.nextNode ().collectInto (remarkNodes, filter); --- 222,226 ---- assertTrue("Should be a HTMLFormTag",node[0] instanceof FormTag); NodeList remarkNodes = new NodeList (); ! NodeClassFilter filter = new NodeClassFilter (Remark.class); for (NodeIterator e = ((FormTag)node[0]).children (); e.hasMoreNodes ();) e.nextNode ().collectInto (remarkNodes, filter); *************** *** 242,251 **** assertTrue("Should be a HTMLFormTag",node[0] instanceof FormTag); FormTag formTag = (FormTag)node[0]; ! RemarkNode [] remarkNode = new RemarkNode[10]; int i = 0; for (NodeIterator e=formTag.children();e.hasMoreNodes();) { Node formNode = (Node)e.nextNode(); ! if (formNode instanceof RemarkNode) { ! remarkNode[i++] = (RemarkNode)formNode; } } --- 241,250 ---- assertTrue("Should be a HTMLFormTag",node[0] instanceof FormTag); FormTag formTag = (FormTag)node[0]; ! Remark [] remarkNode = new Remark[10]; int i = 0; for (NodeIterator e=formTag.children();e.hasMoreNodes();) { Node formNode = (Node)e.nextNode(); ! if (formNode instanceof Remark) { ! remarkNode[i++] = (Remark)formNode; } } *************** *** 324,328 **** parser.setNodeFactory (factory); i = 0; ! nodes = new AbstractNode[50]; for (NodeIterator e = parser.elements(); e.hasMoreNodes();) nodes[i++] = e.nextNode(); --- 323,327 ---- parser.setNodeFactory (factory); i = 0; ! nodes = new Node[50]; for (NodeIterator e = parser.elements(); e.hasMoreNodes();) nodes[i++] = e.nextNode(); *************** *** 377,382 **** assertEquals("Number of nodes found",1,nodes.length); ! assertType("search result node",StringNode.class,nodes[0]); ! StringNode stringNode = (StringNode)nodes[0]; assertEquals("Expected contents of string node","User Name",stringNode.getText()); } --- 376,381 ---- assertEquals("Number of nodes found",1,nodes.length); ! assertType("search result node",Text.class,nodes[0]); ! Text stringNode = (Text)nodes[0]; assertEquals("Expected contents of string node","User Name",stringNode.getText()); } Index: LinkTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/LinkTagTest.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** LinkTagTest.java 14 Jan 2004 02:53:47 -0000 1.46 --- LinkTagTest.java 24 May 2004 16:18:33 -0000 1.47 *************** *** 27,36 **** package org.htmlparser.tests.tagTests; - import org.htmlparser.AbstractNode; import org.htmlparser.Node; - import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.StringNode; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; --- 27,34 ---- package org.htmlparser.tests.tagTests; import org.htmlparser.Node; import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.Text; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; *************** *** 391,398 **** // The first node should be a Tag assertTrue("First node should be a Tag",node[0] instanceof Tag); ! // The second node should be a HTMLStringNode ! assertTrue("Second node should be a StringNode",node[1] instanceof StringNode); ! StringNode stringNode = (StringNode)node[1]; ! assertEquals("Text of the StringNode","Site Comments?",stringNode.getText()); assertTrue("Third node should be a tag",node[2] instanceof Tag); assertTrue("Fourth node should be a link",node[3] instanceof LinkTag); --- 389,396 ---- // The first node should be a Tag assertTrue("First node should be a Tag",node[0] instanceof Tag); ! // The second node should be a Text ! assertTrue("Second node should be a Text",node[1] instanceof Text); ! Text stringNode = (Text)node[1]; ! assertEquals("Text of the Text","Site Comments?",stringNode.getText()); assertTrue("Third node should be a tag",node[2] instanceof Tag); assertTrue("Fourth node should be a link",node[3] instanceof LinkTag); *************** *** 510,515 **** assertStringEquals("Link URL of link tag",exp,linkTag.getLink()); assertEquals("Link Text of link tag"," Journalism 3.0",linkTag.getLinkText()); ! assertTrue("Eight node should be a string node",node[7] instanceof StringNode); ! StringNode stringNode = (StringNode)node[7]; assertEquals("String node contents"," by Rajesh Jain",stringNode.getText()); } --- 508,513 ---- assertStringEquals("Link URL of link tag",exp,linkTag.getLink()); assertEquals("Link Text of link tag"," Journalism 3.0",linkTag.getLinkText()); ! assertTrue("Eight node should be a string node",node[7] instanceof Text); ! Text stringNode = (Text)node[7]; assertEquals("String node contents"," by Rajesh Jain",stringNode.getText()); } *************** *** 556,560 **** LinkTag linkTag = (LinkTag)node[0]; // Get the link data and cross-check ! Node [] dataNode= new AbstractNode[10]; int i = 0; for (SimpleNodeIterator e = linkTag.children();e.hasMoreNodes();) --- 554,558 ---- LinkTag linkTag = (LinkTag)node[0]; // Get the link data and cross-check ! Node [] dataNode= new Node[10]; int i = 0; for (SimpleNodeIterator e = linkTag.children();e.hasMoreNodes();) *************** *** 564,573 **** assertEquals("Number of data nodes",new Integer(2),new Integer(i)); assertTrue("First data node should be an Image Node",dataNode[0] instanceof ImageTag); ! assertTrue("Second data node shouls be a String Node",dataNode[1] instanceof StringNode); // Check the contents of each data node ImageTag imageTag = (ImageTag)dataNode[0]; assertEquals("Image URL","http://www.yahoo.com/abcd.jpg",imageTag.getImageURL()); ! StringNode stringNode = (StringNode)dataNode[1]; assertEquals("String Contents","Hello World",stringNode.getText()); } --- 562,571 ---- assertEquals("Number of data nodes",new Integer(2),new Integer(i)); assertTrue("First data node should be an Image Node",dataNode[0] instanceof ImageTag); ! assertTrue("Second data node shouls be a String Node",dataNode[1] instanceof Text); // Check the contents of each data node ImageTag imageTag = (ImageTag)dataNode[0]; assertEquals("Image URL","http://www.yahoo.com/abcd.jpg",imageTag.getImageURL()); ! Text stringNode = (Text)dataNode[1]; assertEquals("String Contents","Hello World",stringNode.getText()); } *************** *** 588,594 **** assertEquals("Tag Contents",html,tag.toHtml()); assertEquals("Node 0 should have one child", 1, tag.getChildren ().size ()); ! assertTrue("The child should be a string node", tag.getChildren ().elementAt (0) instanceof StringNode); ! StringNode stringNode = (StringNode)tag.getChildren ().elementAt (0); ! assertEquals("StringNode Contents","Revision",stringNode.getText()); } --- 586,592 ---- assertEquals("Tag Contents",html,tag.toHtml()); assertEquals("Node 0 should have one child", 1, tag.getChildren ().size ()); ! assertTrue("The child should be a string node", tag.getChildren ().elementAt (0) instanceof Text); ! Text stringNode = (Text)tag.getChildren ().elementAt (0); ! assertEquals("Text Contents","Revision",stringNode.getText()); } *************** *** 628,632 **** assertEquals("Link URL","http://transfer.go.com/cgi/atransfer.pl?goto=http://www.signs.movies.com&name=114332&srvc=nws&context=283&guid=4AD5723D-C802-4310-A388-0B24E1A79689",linkTag.getLink()); assertEquals("Link Text","",linkTag.getLinkText()); ! Node [] containedNodes = new AbstractNode[10]; int i=0; for (SimpleNodeIterator e = linkTag.children();e.hasMoreNodes();) { --- 626,630 ---- assertEquals("Link URL","http://transfer.go.com/cgi/atransfer.pl?goto=http://www.signs.movies.com&name=114332&srvc=nws&context=283&guid=4AD5723D-C802-4310-A388-0B24E1A79689",linkTag.getLink()); assertEquals("Link Text","",linkTag.getLinkText()); ! Node [] containedNodes = new Node[10]; int i=0; for (SimpleNodeIterator e = linkTag.children();e.hasMoreNodes();) { *************** *** 776,780 **** // Get the image tag from the link ! Node insideNodes [] = new AbstractNode[10]; int j =0 ; for (SimpleNodeIterator e = linkTag.children();e.hasMoreNodes();) { --- 774,778 ---- // Get the image tag from the link ! Node insideNodes [] = new Node[10]; int j =0 ; for (SimpleNodeIterator e = linkTag.children();e.hasMoreNodes();) { Index: OptionTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/OptionTagTest.java,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** OptionTagTest.java 2 Jan 2004 16:24:57 -0000 1.41 --- OptionTagTest.java 24 May 2004 16:18:33 -0000 1.42 *************** *** 27,31 **** package org.htmlparser.tests.tagTests; ! import org.htmlparser.StringNode; import org.htmlparser.tags.OptionTag; import org.htmlparser.tests.ParserTestCase; --- 27,31 ---- package org.htmlparser.tests.tagTests; ! import org.htmlparser.Text; import org.htmlparser.tags.OptionTag; import org.htmlparser.tests.ParserTestCase; *************** *** 156,160 **** for (int j = 0; j < 10; j++) { ! if (node[j] instanceof StringNode) continue; assertTrue("Node " + j + " should be Option Tag",node[j] instanceof OptionTag); --- 156,160 ---- for (int j = 0; j < 10; j++) { ! if (node[j] instanceof Text) continue; assertTrue("Node " + j + " should be Option Tag",node[j] instanceof OptionTag); Index: ImageTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/ImageTagTest.java,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** ImageTagTest.java 14 Jan 2004 02:53:47 -0000 1.42 --- ImageTagTest.java 24 May 2004 16:18:33 -0000 1.43 *************** *** 27,31 **** package org.htmlparser.tests.tagTests; - import org.htmlparser.AbstractNode; import org.htmlparser.Node; import org.htmlparser.Parser; --- 27,30 ---- *************** *** 288,292 **** createParser("<small><a href=s/5926>Air</a>, <a href=s/5927>Hotel</a>, <a href=s/5928>Vacations</a>, <a href=s/5929>Cruises</a></small></td><td align=center><a href=\"http://rd.yahoo.com/M=218794.2020165.3500581.220161/D=yahoo_top/S=2716149:NP/A=1041273/?http://adfarm.mediaplex.com/ad/ck/990-1736-1039-211\" target=\"_top\"><img width=230 height=33 src=\"http://us.a1.yimg.com/us.yimg.com/a/co/columbiahouse/4for49Freesh_230x33_redx2.gif\" alt=\"\" border=0></a></td><td nowrap align=center width=215>Find your match on<br><a href=s/2734><b>Yahoo! Personals</b></a></td></tr><tr><td colspan=3 align=center><input size=30 name=p>\n"+ "<input type=submit value=Search> <a href=r/so>advanced search</a></td></tr></table><table border=0 cellspacing=0 cellpadding=3 width=640><tr><td nowrap align=center><table border=0 cellspacing=0 cellpadding=0><tr><td><a href=s/5948><img src=\"http://us.i1.yimg.com/us.yimg.com/i/ligans/klgs/eet.gif\" width=20 height=20 border=0></a></td><td> <a href=s/1048><b>Yahooligans!</b></a> - <a href=s/5282>Eet & Ern</a>, <a href=s/5283>Games</a>, <a href=s/5284>Science</a>, <a href=s/5285>Sports</a>, <a href=s/5286>Movies</a>, <a href=s/1048>more</a> </td><td><a href=s/5948><img src=\"http://us.i1.yimg.com/us.yimg.com/i/ligans/klgs/ern.gif\" width=20 height=20 border=0></a></td></tr></table></td></tr><tr><td nowrap align=center><small><b>Shop</b> \n","http://www.yahoo.com"); ! Node [] node = new AbstractNode[10]; parser.setNodeFactory (new PrototypicalNodeFactory (new ImageTag ())); int i = 0; --- 287,291 ---- createParser("<small><a href=s/5926>Air</a>, <a href=s/5927>Hotel</a>, <a href=s/5928>Vacations</a>, <a href=s/5929>Cruises</a></small></td><td align=center><a href=\"http://rd.yahoo.com/M=218794.2020165.3500581.220161/D=yahoo_top/S=2716149:NP/A=1041273/?http://adfarm.mediaplex.com/ad/ck/990-1736-1039-211\" target=\"_top\"><img width=230 height=33 src=\"http://us.a1.yimg.com/us.yimg.com/a/co/columbiahouse/4for49Freesh_230x33_redx2.gif\" alt=\"\" border=0></a></td><td nowrap align=center width=215>Find your match on<br><a href=s/2734><b>Yahoo! Personals</b></a></td></tr><tr><td colspan=3 align=center><input size=30 name=p>\n"+ "<input type=submit value=Search> <a href=r/so>advanced search</a></td></tr></table><table border=0 cellspacing=0 cellpadding=3 width=640><tr><td nowrap align=center><table border=0 cellspacing=0 cellpadding=0><tr><td><a href=s/5948><img src=\"http://us.i1.yimg.com/us.yimg.com/i/ligans/klgs/eet.gif\" width=20 height=20 border=0></a></td><td> <a href=s/1048><b>Yahooligans!</b></a> - <a href=s/5282>Eet & Ern</a>, <a href=s/5283>Games</a>, <a href=s/5284>Science</a>, <a href=s/5285>Sports</a>, <a href=s/5286>Movies</a>, <a href=s/1048>more</a> </td><td><a href=s/5948><img src=\"http://us.i1.yimg.com/us.yimg.com/i/ligans/klgs/ern.gif\" width=20 height=20 border=0></a></td></tr></table></td></tr><tr><td nowrap align=center><small><b>Shop</b> \n","http://www.yahoo.com"); ! Node [] node = new Node[10]; parser.setNodeFactory (new PrototypicalNodeFactory (new ImageTag ())); int i = 0; Index: BulletListTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/BulletListTagTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BulletListTagTest.java 24 Jan 2004 23:58:06 -0000 1.2 --- BulletListTagTest.java 24 May 2004 16:18:33 -0000 1.3 *************** *** 29,33 **** import org.htmlparser.Node; import org.htmlparser.tests.ParserTestCase; ! import org.htmlparser.StringNode; import org.htmlparser.tags.Bullet; import org.htmlparser.tags.BulletList; --- 29,33 ---- import org.htmlparser.Node; import org.htmlparser.tests.ParserTestCase; ! import org.htmlparser.Text; import org.htmlparser.tags.Bullet; import org.htmlparser.tags.BulletList; *************** *** 80,84 **** assertType( "first child in bullet", ! StringNode.class, firstNodeInFirstBullet ); --- 80,84 ---- assertType( "first child in bullet", ! Text.class, firstNodeInFirstBullet ); Index: CompositeTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/CompositeTagTest.java,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** CompositeTagTest.java 2 Jan 2004 16:24:57 -0000 1.16 --- CompositeTagTest.java 24 May 2004 16:18:33 -0000 1.17 *************** *** 28,32 **** import org.htmlparser.Node; ! import org.htmlparser.StringNode; import org.htmlparser.tags.CompositeTag; import org.htmlparser.tags.TableColumn; --- 28,32 ---- import org.htmlparser.Node; ! import org.htmlparser.Text; import org.htmlparser.tags.CompositeTag; import org.htmlparser.tags.TableColumn; *************** *** 62,66 **** parseAndAssertNodeCount(1); TableTag tableTag = (TableTag)node[0]; ! StringNode [] stringNode = tableTag.digupStringNode("Hello World"); --- 62,66 ---- parseAndAssertNodeCount(1); TableTag tableTag = (TableTag)node[0]; ! Text[] stringNode = tableTag.digupStringNode("Hello World"); *************** *** 93,97 **** parseAndAssertNodeCount(1); TableTag tableTag = (TableTag)node[0]; ! StringNode [] stringNode = tableTag.digupStringNode("Hello World"); --- 93,97 ---- parseAndAssertNodeCount(1); TableTag tableTag = (TableTag)node[0]; ! Text [] stringNode = tableTag.digupStringNode("Hello World"); Index: TagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/TagTest.java,v retrieving revision 1.57 retrieving revision 1.58 diff -C2 -d -r1.57 -r1.58 *** TagTest.java 9 Feb 2004 02:09:44 -0000 1.57 --- TagTest.java 24 May 2004 16:18:33 -0000 1.58 *************** *** 32,36 **** import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.StringNode; import org.htmlparser.tags.BodyTag; import org.htmlparser.tags.Div; --- 32,36 ---- import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.Text; import org.htmlparser.tags.BodyTag; import org.htmlparser.tags.Div; *************** *** 154,158 **** Tag tag; Tag etag; ! StringNode snode; Node node=null; String lin1 = "<A href=\"http://www.iki.fi/kaila\" myParameter yourParameter=\"Kaarle Kaaila\">Kaarle's homepage</A><p>Paragraph</p>"; --- 154,158 ---- Tag tag; Tag etag; ! Text snode; Node node=null; String lin1 = "<A href=\"http://www.iki.fi/kaila\" myParameter yourParameter=\"Kaarle Kaaila\">Kaarle's homepage</A><p>Paragraph</p>"; *************** *** 182,186 **** if ( en.hasMoreNodes()) { node = en.nextNode(); ! snode = (StringNode)node; assertEquals("Value of element","Kaarle's homepage",snode.getText()); } --- 182,186 ---- if ( en.hasMoreNodes()) { node = en.nextNode(); ! snode = (Text)node; assertEquals("Value of element","Kaarle's homepage",snode.getText()); } *************** *** 201,205 **** if (en.hasMoreNodes()) { node = en.nextNode(); ! snode = (StringNode)node; assertEquals("paragraph contents","Paragraph",snode.getText()); } --- 201,205 ---- if (en.hasMoreNodes()) { node = en.nextNode(); ! snode = (Text)node; assertEquals("paragraph contents","Paragraph",snode.getText()); } *************** *** 224,228 **** Tag tag; Tag etag; ! StringNode snode; Node node=null; String lin1 = "<G href=\"http://www.iki.fi/kaila\" myParameter yourParameter=\"Kaila\">Kaarle's homepage</G><p>Paragraph</p>"; --- 224,228 ---- Tag tag; Tag etag; ! Text snode; Node node=null; String lin1 = "<G href=\"http://www.iki.fi/kaila\" myParameter yourParameter=\"Kaila\">Kaarle's homepage</G><p>Paragraph</p>"; *************** *** 250,254 **** if (en.hasMoreNodes()) { node = en.nextNode(); ! snode = (StringNode)node; assertEquals("The text of the element",snode.getText(),"Kaarle's homepage"); } --- 250,254 ---- if (en.hasMoreNodes()) { node = en.nextNode(); ! snode = (Text)node; assertEquals("The text of the element",snode.getText(),"Kaarle's homepage"); } *************** *** 268,272 **** if (en.hasMoreNodes()) { node = en.nextNode(); ! snode = (StringNode)node; assertEquals("Verify the paragraph text","Paragraph", snode.getText()); } --- 268,272 ---- if (en.hasMoreNodes()) { node = en.nextNode(); ! snode = (Text)node; assertEquals("Verify the paragraph text","Paragraph", snode.getText()); } *************** *** 292,296 **** Tag tag; Tag etag; ! StringNode snode; Node node=null; String lin1 = "<A yourParameter = \"Kaarle\">Kaarle's homepage</A>"; --- 292,296 ---- Tag tag; Tag etag; ! Text snode; Node node=null; String lin1 = "<A yourParameter = \"Kaarle\">Kaarle's homepage</A>"; *************** *** 316,320 **** if ( en.hasMoreNodes()) { node = en.nextNode(); ! snode = (StringNode)node; assertEquals("Value of element","Kaarle's homepage",snode.getText()); } --- 316,320 ---- if ( en.hasMoreNodes()) { node = en.nextNode(); ! snode = (Text)node; assertEquals("Value of element","Kaarle's homepage",snode.getText()); } *************** *** 516,521 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(5); ! assertTrue("Third node should be a string node",node[2] instanceof StringNode); ! StringNode stringNode = (StringNode)node[2]; assertEquals("Third node has incorrect text","<>text",stringNode.getText()); } --- 516,521 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(5); ! assertTrue("Third node should be a string node",node[2] instanceof Text); ! Text stringNode = (Text)node[2]; assertEquals("Third node has incorrect text","<>text",stringNode.getText()); } *************** *** 529,534 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(5); ! assertTrue("Third node should be a string node",node[2] instanceof StringNode); ! StringNode stringNode = (StringNode)node[2]; assertEquals("Third node has incorrect text","text<>",stringNode.getText()); } --- 529,534 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(5); ! assertTrue("Third node should be a string node",node[2] instanceof Text); ! Text stringNode = (Text)node[2]; assertEquals("Third node has incorrect text","text<>",stringNode.getText()); } *************** *** 547,552 **** BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof StringNode); ! StringNode stringNode = (StringNode)body.getChild(0); assertEquals("Third node has incorrect text","text<>text",stringNode.getText()); } --- 547,552 ---- BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof Text); ! Text stringNode = (Text)body.getChild(0); assertEquals("Third node has incorrect text","text<>text",stringNode.getText()); } *************** *** 566,571 **** BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof StringNode); ! StringNode stringNode = (StringNode)body.getChild(0); String actual = stringNode.getText(); assertEquals("Third node has incorrect text","text\n<>text",actual); --- 566,571 ---- BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof Text); ! Text stringNode = (Text)body.getChild(0); String actual = stringNode.getText(); assertEquals("Third node has incorrect text","text\n<>text",actual); *************** *** 586,591 **** BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof StringNode); ! StringNode stringNode = (StringNode)body.getChild(0); String actual = stringNode.getText(); assertEquals("Third node has incorrect text","text<\n>text",actual); --- 586,591 ---- BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof Text); ! Text stringNode = (Text)body.getChild(0); String actual = stringNode.getText(); assertEquals("Third node has incorrect text","text<\n>text",actual); *************** *** 606,611 **** BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof StringNode); ! StringNode stringNode = (StringNode)body.getChild(0); String actual = stringNode.getText(); assertEquals("Third node has incorrect text","text<>\ntext",actual); --- 606,611 ---- BodyTag body = (BodyTag)html.getChild(0); assertTrue("BODY node should have one child",1 == body.getChildCount ()); ! assertTrue("Only node should be a string node",body.getChild(0) instanceof Text); ! Text stringNode = (Text)body.getChild(0); String actual = stringNode.getText(); assertEquals("Third node has incorrect text","text<>\ntext",actual); *************** *** 648,652 **** assertStringEquals("Expected HTML","John Doe",htmlTag.getLabel()); ! ((org.htmlparser.StringNode)((org.htmlparser.tags.CompositeTag)htmlTag).getChild(0)).setText("Jane Doe"); expectedHTML = "<LABEL ID=\"JohnDoe\">Jane Doe</LABEL>"; assertStringEquals("Expected HTML",expectedHTML,htmlTag.toHtml()); --- 648,652 ---- assertStringEquals("Expected HTML","John Doe",htmlTag.getLabel()); ! ((org.htmlparser.Text)((org.htmlparser.tags.CompositeTag)htmlTag).getChild(0)).setText("Jane Doe"); expectedHTML = "<LABEL ID=\"JohnDoe\">Jane Doe</LABEL>"; assertStringEquals("Expected HTML",expectedHTML,htmlTag.toHtml()); |