[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/lexerTests AttributeTests.java,1.13,1.14 KitTes
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2004-05-24 16:19:15
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19028/src/org/htmlparser/tests/lexerTests Modified Files: AttributeTests.java KitTest.java LexerTests.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: AttributeTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests/AttributeTests.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** AttributeTests.java 14 Mar 2004 15:42:37 -0000 1.13 --- AttributeTests.java 24 May 2004 16:18:31 -0000 1.14 *************** *** 31,36 **** import org.htmlparser.Node; import org.htmlparser.PrototypicalNodeFactory; - import org.htmlparser.lexer.nodes.Attribute; import org.htmlparser.lexer.nodes.PageAttribute; import org.htmlparser.tags.ImageTag; --- 31,36 ---- import org.htmlparser.Node; + import org.htmlparser.Attribute; import org.htmlparser.PrototypicalNodeFactory; import org.htmlparser.lexer.nodes.PageAttribute; import org.htmlparser.tags.ImageTag; Index: LexerTests.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests/LexerTests.java,v retrieving revision 1.20 retrieving revision 1.21 diff -C2 -d -r1.20 -r1.21 *** LexerTests.java 24 May 2004 00:38:18 -0000 1.20 --- LexerTests.java 24 May 2004 16:18:31 -0000 1.21 *************** *** 33,41 **** import org.htmlparser.Node; import org.htmlparser.Parser; import org.htmlparser.lexer.Lexer; - import org.htmlparser.RemarkNode; - import org.htmlparser.StringNode; - import org.htmlparser.lexer.nodes.TagNode; - import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.NodeIterator; --- 33,40 ---- import org.htmlparser.Node; import org.htmlparser.Parser; + import org.htmlparser.Remark; + import org.htmlparser.Tag; + import org.htmlparser.Text; import org.htmlparser.lexer.Lexer; import org.htmlparser.tests.ParserTestCase; import org.htmlparser.util.NodeIterator; *************** *** 66,75 **** String reference; Lexer lexer; ! StringNode node; reference = "Hello world"; lexer = new Lexer (reference); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", reference, node.getText ()); } --- 65,74 ---- String reference; Lexer lexer; ! Text node; reference = "Hello world"; lexer = new Lexer (reference); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", reference, node.getText ()); } *************** *** 81,90 **** String reference; Lexer lexer; ! StringNode node; reference = "Hello\nworld"; lexer = new Lexer (reference); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", reference, node.getText ()); } --- 80,89 ---- String reference; Lexer lexer; ! Text node; reference = "Hello\nworld"; lexer = new Lexer (reference); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", reference, node.getText ()); } *************** *** 96,109 **** String reference; Lexer lexer; ! StringNode node; reference = "Hello\r\nworld"; lexer = new Lexer (reference); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", reference, node.getText ()); reference = "Hello\rworld"; lexer = new Lexer (reference); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", reference, node.getText ()); } --- 95,108 ---- String reference; Lexer lexer; ! Text node; reference = "Hello\r\nworld"; lexer = new Lexer (reference); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", reference, node.getText ()); reference = "Hello\rworld"; lexer = new Lexer (reference); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", reference, node.getText ()); } *************** *** 115,132 **** String reference; Lexer lexer; ! StringNode node; reference = "Hello world\n"; lexer = new Lexer (reference); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", reference, node.getText ()); reference = "Hello world\r"; lexer = new Lexer (reference); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", reference, node.getText ()); reference = "Hello world\r\n"; lexer = new Lexer (reference); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", reference, node.getText ()); } --- 114,131 ---- String reference; Lexer lexer; ! Text node; reference = "Hello world\n"; lexer = new Lexer (reference); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", reference, node.getText ()); reference = "Hello world\r"; lexer = new Lexer (reference); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", reference, node.getText ()); reference = "Hello world\r\n"; lexer = new Lexer (reference); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", reference, node.getText ()); } *************** *** 152,156 **** }; Lexer lexer; ! StringNode node; for (int i = 0; i < references.length; i++) --- 151,155 ---- }; Lexer lexer; ! Text node; for (int i = 0; i < references.length; i++) *************** *** 159,164 **** { lexer = new Lexer (references[i] + suffixes[j]); ! node = (StringNode)lexer.nextNode (); ! assertEquals ("StringNode contents wrong", references[i], node.getText ()); } } --- 158,163 ---- { lexer = new Lexer (references[i] + suffixes[j]); ! node = (Text)lexer.nextNode (); ! assertEquals ("Text contents wrong", references[i], node.getText ()); } } *************** *** 173,181 **** String suffix; Lexer lexer; ! TagNode node; reference = "<head>"; lexer = new Lexer (reference); ! node = (TagNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); --- 172,180 ---- String suffix; Lexer lexer; ! Node node; reference = "<head>"; lexer = new Lexer (reference); ! node = lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); *************** *** 183,189 **** suffix = "<body>"; lexer = new Lexer (reference + suffix); ! node = (TagNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); ! node = (TagNode)lexer.nextNode (); assertEquals ("Tag contents wrong", suffix, node.toHtml ()); } --- 182,188 ---- suffix = "<body>"; lexer = new Lexer (reference + suffix); ! node = lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); ! node = lexer.nextNode (); assertEquals ("Tag contents wrong", suffix, node.toHtml ()); } *************** *** 196,204 **** String reference; Lexer lexer; ! TagNode node; reference = "<head lang='en_US' dir=ltr\nprofile=\"http://htmlparser.sourceforge.org/dictionary.html\">"; lexer = new Lexer (reference); ! node = (TagNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); } --- 195,203 ---- String reference; Lexer lexer; ! Node node; reference = "<head lang='en_US' dir=ltr\nprofile=\"http://htmlparser.sourceforge.org/dictionary.html\">"; lexer = new Lexer (reference); ! node = lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); } *************** *** 207,230 **** * Test operation with comments. */ ! public void testRemarkNode () throws ParserException { String reference; Lexer lexer; ! RemarkNode node; String suffix; reference = "<!-- This is a comment -->"; lexer = new Lexer (reference); ! node = (RemarkNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a comment -- >"; lexer = new Lexer (reference); ! node = (RemarkNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a\nmultiline comment -->"; lexer = new Lexer (reference); ! node = (RemarkNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); --- 206,229 ---- * Test operation with comments. */ ! public void testRemark () throws ParserException { String reference; Lexer lexer; ! Remark node; String suffix; reference = "<!-- This is a comment -->"; lexer = new Lexer (reference); ! node = (Remark)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a comment -- >"; lexer = new Lexer (reference); ! node = (Remark)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a\nmultiline comment -->"; lexer = new Lexer (reference); ! node = (Remark)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); *************** *** 232,246 **** reference = "<!-- This is a comment -->"; lexer = new Lexer (reference + suffix); ! node = (RemarkNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a comment -- >"; lexer = new Lexer (reference + suffix); ! node = (RemarkNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a\nmultiline comment -->"; lexer = new Lexer (reference + suffix); ! node = (RemarkNode)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); } --- 231,245 ---- reference = "<!-- This is a comment -->"; lexer = new Lexer (reference + suffix); ! node = (Remark)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a comment -- >"; lexer = new Lexer (reference + suffix); ! node = (Remark)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); reference = "<!-- This is a\nmultiline comment -->"; lexer = new Lexer (reference + suffix); ! node = (Remark)lexer.nextNode (); assertEquals ("Tag contents wrong", reference, node.toHtml ()); } Index: KitTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/lexerTests/KitTest.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** KitTest.java 14 Jan 2004 02:53:47 -0000 1.6 --- KitTest.java 24 May 2004 16:18:31 -0000 1.7 *************** *** 37,46 **** import javax.swing.text.html.HTMLEditorKit.Parser; import javax.swing.text.html.HTMLEditorKit.ParserCallback; import org.htmlparser.Node; import org.htmlparser.lexer.Cursor; import org.htmlparser.lexer.Lexer; - import org.htmlparser.AbstractNode; - import org.htmlparser.lexer.nodes.Attribute; - import org.htmlparser.lexer.nodes.TagNode; import org.htmlparser.util.ParserException; import org.htmlparser.util.Translate; --- 37,47 ---- import javax.swing.text.html.HTMLEditorKit.Parser; import javax.swing.text.html.HTMLEditorKit.ParserCallback; + + import org.htmlparser.Attribute; import org.htmlparser.Node; + import org.htmlparser.Tag; + import org.htmlparser.nodes.AbstractNode; import org.htmlparser.lexer.Cursor; import org.htmlparser.lexer.Lexer; import org.htmlparser.util.ParserException; import org.htmlparser.util.Translate; *************** *** 266,272 **** { node = (Node)mNodes.elementAt (i); ! if (node instanceof TagNode) { ! ours = ((Attribute)(((TagNode)node).getAttributesEx ().elementAt (0))).getName (); if (match (theirs, ours)) { --- 267,273 ---- { node = (Node)mNodes.elementAt (i); ! if (node instanceof Tag) { ! ours = ((Attribute)(((Tag)node).getAttributesEx ().elementAt (0))).getName (); if (match (theirs, ours)) { *************** *** 331,337 **** { node = (Node)mNodes.elementAt (i); ! if (node instanceof TagNode) { ! ours = ((Attribute)(((TagNode)node).getAttributesEx ().elementAt (0))).getName ().substring (1); if (match (theirs, ours)) { --- 332,338 ---- { node = (Node)mNodes.elementAt (i); ! if (node instanceof Tag) { ! ours = ((Attribute)(((Tag)node).getAttributesEx ().elementAt (0))).getName ().substring (1); if (match (theirs, ours)) { *************** *** 397,403 **** { node = (Node)mNodes.elementAt (i); ! if (node instanceof TagNode) { ! ours = ((Attribute)(((TagNode)node).getAttributesEx ().elementAt (0))).getName (); if (match (theirs, ours)) { --- 398,404 ---- { node = (Node)mNodes.elementAt (i); ! if (node instanceof Tag) { ! ours = ((Attribute)(((Tag)node).getAttributesEx ().elementAt (0))).getName (); if (match (theirs, ours)) { *************** *** 604,607 **** --- 605,615 ---- * * $Log$ + * Revision 1.7 2004/05/24 16:18:31 derrickoswald + * 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. + * * Revision 1.6 2004/01/14 02:53:47 derrickoswald * *** empty log message *** |