[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/tagTests BaseHrefTagTest.java,1.40,1.41 BodyTag
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2004-07-02 00:49:41
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32670/src/org/htmlparser/tests/tagTests Modified Files: BaseHrefTagTest.java BodyTagTest.java DivTagTest.java EndTagTest.java FormTagTest.java FrameSetTagTest.java HtmlTagTest.java JspTagTest.java LinkTagTest.java MetaTagTest.java ObjectCollectionTest.java SpanTagTest.java TagTest.java TitleTagTest.java Log Message: Part four of a multiphase refactoring. Most internals now use the Tag interface. This interface has been broadened to add set/get scanner and set/get endtag. Removed the org.htmlparser.tags.Tag class and moved the remaining (minor) functionality to the TagNode class. So now tags inherit directly from TagNode or CompositeTag. ** NOTE: If you have subclassed org.htmlparser.tags.Tag, use org.htmlparser.nodes.TagNode now.** Removed deprecated methods getTagBegin/getTagEnd and deleted unused classes: PeekingIterator and it's Implementation. Index: FormTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/FormTagTest.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** FormTagTest.java 24 May 2004 16:18:33 -0000 1.44 --- FormTagTest.java 2 Jul 2004 00:49:31 -0000 1.45 *************** *** 31,34 **** --- 31,35 ---- import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.Remark; + import org.htmlparser.Tag; import org.htmlparser.Text; import org.htmlparser.filters.NodeClassFilter; *************** *** 42,46 **** import org.htmlparser.tags.SelectTag; import org.htmlparser.tags.TableTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tags.TextareaTag; import org.htmlparser.tests.ParserTestCase; --- 43,46 ---- Index: TitleTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/TitleTagTest.java,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** TitleTagTest.java 2 Jan 2004 16:24:57 -0000 1.35 --- TitleTagTest.java 2 Jul 2004 00:49:31 -0000 1.36 *************** *** 28,31 **** --- 28,32 ---- import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.BaseHrefTag; import org.htmlparser.tags.HeadTag; *************** *** 33,37 **** import org.htmlparser.tags.MetaTag; import org.htmlparser.tags.StyleTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; --- 34,37 ---- Index: LinkTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/LinkTagTest.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** LinkTagTest.java 24 May 2004 16:18:33 -0000 1.47 --- LinkTagTest.java 2 Jul 2004 00:49:31 -0000 1.48 *************** *** 30,33 **** --- 30,34 ---- import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.Text; import org.htmlparser.tags.HeadTag; *************** *** 35,39 **** import org.htmlparser.tags.ImageTag; import org.htmlparser.tags.LinkTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; --- 36,39 ---- Index: ObjectCollectionTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/ObjectCollectionTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** ObjectCollectionTest.java 2 Jan 2004 16:24:57 -0000 1.20 --- ObjectCollectionTest.java 2 Jul 2004 00:49:31 -0000 1.21 *************** *** 29,36 **** import org.htmlparser.Node; import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.Div; import org.htmlparser.tags.Span; import org.htmlparser.tags.TableTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.NodeList; --- 29,36 ---- import org.htmlparser.Node; import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.Div; import org.htmlparser.tags.Span; import org.htmlparser.tags.TableTag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.NodeList; Index: BodyTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/BodyTagTest.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** BodyTagTest.java 2 Jan 2004 16:24:57 -0000 1.20 --- BodyTagTest.java 2 Jul 2004 00:49:31 -0000 1.21 *************** *** 32,38 **** import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.BodyTag; import org.htmlparser.tags.Html; - import org.htmlparser.tags.Tag; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; --- 32,38 ---- import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.BodyTag; import org.htmlparser.tags.Html; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; Index: MetaTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/MetaTagTest.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** MetaTagTest.java 2 Jan 2004 16:24:57 -0000 1.38 --- MetaTagTest.java 2 Jul 2004 00:49:31 -0000 1.39 *************** *** 28,36 **** import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; import org.htmlparser.tags.LinkTag; import org.htmlparser.tags.MetaTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; --- 28,36 ---- import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; import org.htmlparser.tags.LinkTag; import org.htmlparser.tags.MetaTag; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; Index: BaseHrefTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/BaseHrefTagTest.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** BaseHrefTagTest.java 18 Mar 2004 04:04:08 -0000 1.40 --- BaseHrefTagTest.java 2 Jul 2004 00:49:31 -0000 1.41 *************** *** 28,34 **** import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.BaseHrefTag; import org.htmlparser.tags.LinkTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; --- 28,34 ---- import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.BaseHrefTag; import org.htmlparser.tags.LinkTag; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; Index: HtmlTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/HtmlTagTest.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** HtmlTagTest.java 7 Dec 2003 23:41:43 -0000 1.1 --- HtmlTagTest.java 2 Jul 2004 00:49:31 -0000 1.2 *************** *** 29,35 **** import org.htmlparser.Node; import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.filters.NodeClassFilter; import org.htmlparser.tags.Html; - import org.htmlparser.tags.Tag; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; --- 29,35 ---- import org.htmlparser.Node; import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.filters.NodeClassFilter; import org.htmlparser.tags.Html; import org.htmlparser.tags.TitleTag; import org.htmlparser.tests.ParserTestCase; Index: EndTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/EndTagTest.java,v retrieving revision 1.38 retrieving revision 1.39 diff -C2 -d -r1.38 -r1.39 *** EndTagTest.java 2 Jan 2004 16:24:57 -0000 1.38 --- EndTagTest.java 2 Jul 2004 00:49:31 -0000 1.39 *************** *** 28,32 **** import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; --- 28,32 ---- import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; Index: DivTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/DivTagTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DivTagTest.java 24 Jan 2004 23:58:07 -0000 1.2 --- DivTagTest.java 2 Jul 2004 00:49:31 -0000 1.3 *************** *** 28,35 **** import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.Div; import org.htmlparser.tags.InputTag; import org.htmlparser.tags.TableTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; --- 28,35 ---- import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.Div; import org.htmlparser.tags.InputTag; import org.htmlparser.tags.TableTag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; Index: SpanTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/SpanTagTest.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** SpanTagTest.java 24 Jan 2004 23:58:07 -0000 1.2 --- SpanTagTest.java 2 Jul 2004 00:49:31 -0000 1.3 *************** *** 29,35 **** import org.htmlparser.Node; import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.Span; import org.htmlparser.tags.TableColumn; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; --- 29,35 ---- import org.htmlparser.Node; import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.Span; import org.htmlparser.tags.TableColumn; import org.htmlparser.tests.ParserTestCase; Index: TagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/TagTest.java,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** TagTest.java 24 May 2004 16:18:33 -0000 1.58 --- TagTest.java 2 Jul 2004 00:49:31 -0000 1.59 *************** *** 28,35 **** --- 28,37 ---- import java.util.Hashtable; + import org.htmlparser.Attribute; import org.htmlparser.Node; import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.Text; import org.htmlparser.tags.BodyTag; *************** *** 37,41 **** import org.htmlparser.tags.Html; import org.htmlparser.tags.LinkTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.NodeIterator; --- 39,42 ---- *************** *** 127,131 **** createParser(lin1); NodeIterator en = parser.elements(); - Hashtable h; try { --- 128,131 ---- *************** *** 135,140 **** tag = (Tag)node; ! h = tag.getAttributes(); ! String classValue= (String)h.get("CLASS"); assertEquals ("The class value should be ","userData",classValue); } --- 135,139 ---- tag = (Tag)node; ! String classValue= tag.getAttribute ("CLASS"); assertEquals ("The class value should be ","userData",classValue); } *************** *** 159,163 **** createParser(lin1); NodeIterator en = parser.elements(); - Hashtable h; String a,href,myValue,nice; --- 158,161 ---- *************** *** 168,176 **** tag = (Tag)node; ! h = tag.getAttributes(); ! a = (String)h.get(SpecialHashtable.TAGNAME); ! href = (String)h.get("HREF"); ! myValue = (String)h.get("MYPARAMETER"); ! nice = (String)h.get("YOURPARAMETER"); assertEquals ("Link tag (A)","A",a); assertEquals ("href value","http://www.iki.fi/kaila",href); --- 166,173 ---- tag = (Tag)node; ! a = ((Attribute)(tag.getAttributesEx ().elementAt (0))).getName (); ! href = tag.getAttribute ("HREF"); ! myValue = tag.getAttribute ("MYPARAMETER"); ! nice = tag.getAttribute ("YOURPARAMETER"); assertEquals ("Link tag (A)","A",a); assertEquals ("href value","http://www.iki.fi/kaila",href); *************** *** 229,233 **** createParser(lin1); NodeIterator en = parser.elements(); - Hashtable h; String a,href,myValue,nice; --- 226,229 ---- *************** *** 238,246 **** tag = (Tag)node; ! h = tag.getAttributes(); ! a = (String)h.get(SpecialHashtable.TAGNAME); ! href = (String)h.get("HREF"); ! myValue = (String)h.get("MYPARAMETER"); ! nice = (String)h.get("YOURPARAMETER"); assertEquals ("The tagname should be G",a,"G"); assertEquals ("Check the http address",href,"http://www.iki.fi/kaila"); --- 234,241 ---- tag = (Tag)node; ! a = ((Attribute)(tag.getAttributesEx ().elementAt (0))).getName (); ! href = tag.getAttribute ("HREF"); ! myValue = tag.getAttribute ("MYPARAMETER"); ! nice = tag.getAttribute ("YOURPARAMETER"); assertEquals ("The tagname should be G",a,"G"); assertEquals ("Check the http address",href,"http://www.iki.fi/kaila"); *************** *** 306,312 **** tag = (Tag)node; ! h = tag.getAttributes(); ! a = (String)h.get(SpecialHashtable.TAGNAME); ! nice = (String)h.get("YOURPARAMETER"); assertEquals ("Link tag (A)",a,"A"); assertEquals ("yourParameter value","Kaarle",nice); --- 301,306 ---- tag = (Tag)node; ! a = ((Attribute)(tag.getAttributesEx ().elementAt (0))).getName (); ! nice = tag.getAttribute ("YOURPARAMETER"); assertEquals ("Link tag (A)",a,"A"); assertEquals ("yourParameter value","Kaarle",nice); *************** *** 363,373 **** // an alternate interpretation: assertEquals("Second tag should be corrected","font face=\"Arial,helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"",fontTag.getText()); assertEquals("Second tag should be corrected","font face=\"Arial,\"helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"",fontTag.getText()); ! // Try to parse the parameters from this tag. ! Hashtable table = fontTag.getAttributes(); ! assertNotNull("Parameters table",table); ! assertEquals("font sans-serif parameter","sans-serif",table.get("SANS-SERIF")); // an alternate interpretation: assertEquals("font face parameter","Arial,helvetica,",table.get("FACE")); // another: assertEquals("font face parameter","Arial,\"helvetica,",table.get("FACE")); ! assertEquals("font face parameter","Arial,",table.get("FACE")); } --- 357,364 ---- // an alternate interpretation: assertEquals("Second tag should be corrected","font face=\"Arial,helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"",fontTag.getText()); assertEquals("Second tag should be corrected","font face=\"Arial,\"helvetica,\" sans-serif=\"sans-serif\" size=\"2\" color=\"#FFFFFF\"",fontTag.getText()); ! assertEquals("font sans-serif parameter","sans-serif",fontTag.getAttribute("SANS-SERIF")); // an alternate interpretation: assertEquals("font face parameter","Arial,helvetica,",table.get("FACE")); // another: assertEquals("font face parameter","Arial,\"helvetica,",table.get("FACE")); ! assertEquals("font face parameter","Arial,",fontTag.getAttribute("FACE")); } *************** *** 694,708 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! // the node should be an HTMLTag ! assertTrue("Node should be a HTMLTag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; assertEquals("Initial text should be","TABLE BORDER=0",tag.getText ()); ! ! Hashtable tempHash = tag.getAttributes (); ! tempHash.put ("BORDER","\"1\""); ! tag.setAttributes (tempHash); ! ! String s = tag.toHtml (); ! assertEquals("HTML should be","<TABLE BORDER=\"1\">", s); } } --- 685,694 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! // the node should be a Tag ! assertTrue("Node should be a Tag",node[0] instanceof Tag); Tag tag = (Tag)node[0]; assertEquals("Initial text should be","TABLE BORDER=0",tag.getText ()); ! tag.setAttribute ("BORDER","\"1\""); ! assertEquals("HTML should be","<TABLE BORDER=\"1\">", tag.toHtml ()); } } Index: FrameSetTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/FrameSetTagTest.java,v retrieving revision 1.36 retrieving revision 1.37 diff -C2 -d -r1.36 -r1.37 *** FrameSetTagTest.java 2 Jan 2004 16:24:57 -0000 1.36 --- FrameSetTagTest.java 2 Jul 2004 00:49:31 -0000 1.37 *************** *** 28,34 **** import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.FrameSetTag; import org.htmlparser.tags.FrameTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; --- 28,34 ---- import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.FrameSetTag; import org.htmlparser.tags.FrameTag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; Index: JspTagTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/tagTests/JspTagTest.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** JspTagTest.java 24 Jan 2004 17:14:47 -0000 1.44 --- JspTagTest.java 2 Jul 2004 00:49:31 -0000 1.45 *************** *** 29,34 **** import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.tags.JspTag; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; --- 29,34 ---- import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; + import org.htmlparser.Tag; import org.htmlparser.tags.JspTag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.ParserException; |