[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/scannersTests CompositeTagScannerTest.java,1.50
Brought to you by:
derrickoswald
From: <der...@us...> - 2003-11-01 21:55:47
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests In directory sc8-pr-cvs1:/tmp/cvs-serv2656/tests/scannersTests Modified Files: CompositeTagScannerTest.java FormScannerTest.java Log Message: Create nodes by cloning from a list of prototypes in the Parser (NodeFactory). So now, the startTag() is the CompositeTag, and the CompositeTagScanner just adds children. This is an intermediate code drop on the way to integrating the scanners with the tags; the scanners no longer create the tags (but they still create the prototypical ones). Index: CompositeTagScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/CompositeTagScannerTest.java,v retrieving revision 1.50 retrieving revision 1.51 diff -C2 -d -r1.50 -r1.51 *** CompositeTagScannerTest.java 1 Nov 2003 04:03:21 -0000 1.50 --- CompositeTagScannerTest.java 1 Nov 2003 21:55:43 -0000 1.51 *************** *** 30,33 **** --- 30,34 ---- import java.util.Vector; + import org.htmlparser.AbstractNode; import org.htmlparser.Node; import org.htmlparser.StringNode; *************** *** 135,139 **** assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); assertEquals("custom tag starting loc",0,customTag.getStartPosition ()); ! assertEquals("custom tag ending loc",24,customTag.getEndPosition ()); Node child = customTag.childAt(0); --- 136,140 ---- assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); assertEquals("custom tag starting loc",0,customTag.getStartPosition ()); ! assertEquals("custom tag ending loc",24,customTag.getEndTag ().getEndPosition ()); Node child = customTag.childAt(0); *************** *** 156,160 **** assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); assertEquals("custom tag starting loc",0,customTag.getStartPosition ()); ! assertEquals("custom tag ending loc",27,customTag.getEndPosition ()); Node child = customTag.childAt(0); --- 157,161 ---- assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); assertEquals("custom tag starting loc",0,customTag.getStartPosition ()); ! assertEquals("custom tag ending loc",27,customTag.getEndTag ().getEndPosition ()); Node child = customTag.childAt(0); *************** *** 291,295 **** assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); assertEquals("starting line position",0,customTag.getStartingLineNumber()); ! assertEquals("ending line position",1,customTag.getEndingLineNumber()); assertStringEquals("html", html + "</custom>", customTag.toHtml() ); --- 292,296 ---- assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); assertEquals("starting line position",0,customTag.getStartingLineNumber()); ! assertEquals("ending line position",1,customTag.getEndTag ().getEndingLineNumber()); assertStringEquals("html", html + "</custom>", customTag.toHtml() ); *************** *** 307,313 **** assertEquals("starting loc",0,customTag.getStartTag().getStartPosition ()); assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); ! assertEquals("ending loc of custom tag",17,customTag.getEndPosition ()); assertEquals("starting line position",0,customTag.getStartingLineNumber()); ! assertEquals("ending line position",0,customTag.getEndingLineNumber()); assertStringEquals("1st custom tag", tag1 + "</custom>", customTag.toHtml()); customTag = (CustomTag)node[1]; --- 308,314 ---- assertEquals("starting loc",0,customTag.getStartTag().getStartPosition ()); assertEquals("ending loc",8,customTag.getStartTag().getEndPosition ()); ! assertEquals("ending loc of custom tag",17,customTag.getEndTag ().getEndPosition ()); assertEquals("starting line position",0,customTag.getStartingLineNumber()); ! assertEquals("ending line position",0,customTag.getEndTag ().getEndingLineNumber()); assertStringEquals("1st custom tag", tag1 + "</custom>", customTag.toHtml()); customTag = (CustomTag)node[1]; *************** *** 334,338 **** assertEquals("ending loc",17,customTag.getStartTag().getEndPosition ()); assertEquals("starting line position",0,customTag.getStartingLineNumber()); ! assertEquals("ending line position",1,customTag.getEndingLineNumber()); assertStringEquals("another tag html",another + "</another>",anotherTag.toHtml()); assertStringEquals("custom tag html",custom,customTag.toHtml()); --- 335,339 ---- assertEquals("ending loc",17,customTag.getStartTag().getEndPosition ()); assertEquals("starting line position",0,customTag.getStartingLineNumber()); ! assertEquals("ending line position",1,customTag.getEndTag ().getEndingLineNumber()); assertStringEquals("another tag html",another + "</another>",anotherTag.toHtml()); assertStringEquals("custom tag html",custom,customTag.toHtml()); *************** *** 406,410 **** AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); assertEquals("anotherTag child count",2,anotherTag.getChildCount()); ! assertEquals("anotherTag end loc",27,anotherTag.getEndPosition ()); assertEquals("custom end tag begin loc",27,customTag.getEndTag().getStartPosition ()); assertEquals("custom end tag end loc",36,customTag.getEndTag().getEndPosition ()); --- 407,411 ---- AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); assertEquals("anotherTag child count",2,anotherTag.getChildCount()); ! assertEquals("anotherTag end loc",27,anotherTag.getEndTag ().getEndPosition ()); assertEquals("custom end tag begin loc",27,customTag.getEndTag().getStartPosition ()); assertEquals("custom end tag end loc",36,customTag.getEndTag().getEndPosition ()); *************** *** 498,510 **** createParser("<Custom/>","http://www.yahoo.com"); ! parser.addScanner(new CustomScanner() { ! public Tag createTag(Page page, int start, int end, Vector attributes, Tag startTag, Tag endTag, NodeList children) throws ParserException ! { ! url = page.getUrl (); ! return (super.createTag (page, start, end, attributes, startTag, endTag, children)); ! } ! }); parseAndAssertNodeCount(1); ! assertStringEquals("url","http://www.yahoo.com",url); } --- 499,516 ---- createParser("<Custom/>","http://www.yahoo.com"); ! parser.addScanner(new CustomScanner() ! // { ! // public Tag createTag(Page page, int start, int end, Vector attributes, Tag startTag, Tag endTag, NodeList children) throws ParserException ! // { ! // if (null != page) ! // url = page.getUrl (); ! // else ! // url = null; ! // return (super.createTag (page, start, end, attributes, startTag, endTag, children)); ! // } ! // } ! ); parseAndAssertNodeCount(1); ! assertStringEquals("url","http://www.yahoo.com",((AbstractNode)node[0]).getPage ().getUrl ()); } *************** *** 565,569 **** } ! public Tag createTag(Page page, int start, int end, Vector attributes, Tag startTag, Tag endTag, NodeList children) throws ParserException { CustomTag ret; --- 571,575 ---- } ! public Tag createTag (Page page, int start, int end, Vector attributes, Tag startTag, Tag endTag, NodeList children) throws ParserException { CustomTag ret; *************** *** 596,600 **** } ! public Tag createTag(Page page, int start, int end, Vector attributes, Tag startTag, Tag endTag, NodeList children) throws ParserException { AnotherTag ret; --- 602,606 ---- } ! public Tag createTag (Page page, int start, int end, Vector attributes, Tag startTag, Tag endTag, NodeList children) throws ParserException { AnotherTag ret; Index: FormScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/FormScannerTest.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** FormScannerTest.java 27 Oct 2003 02:18:05 -0000 1.39 --- FormScannerTest.java 1 Nov 2003 21:55:43 -0000 1.40 *************** *** 125,133 **** assertNull("Should have been null",formTag.getTextAreaTag("junk")); ! String expected = ! FORM_HTML.substring (0, FORM_HTML.indexOf ("\"do_login.php\"")) ! + "\"http://www.google.com/test/do_login.php\"" ! + FORM_HTML.substring (FORM_HTML.indexOf ("\"do_login.php\"") + 14); ! assertStringEquals("toHTML",expected,formTag.toHtml()); } --- 125,129 ---- assertNull("Should have been null",formTag.getTextAreaTag("junk")); ! assertStringEquals("toHTML",FORM_HTML,formTag.toHtml()); } |