[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/scannersTests BodyScannerTest.java,1.13,1.14 Bu
Brought to you by:
derrickoswald
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests In directory sc8-pr-cvs1:/tmp/cvs-serv2828/tests/scannersTests Modified Files: BodyScannerTest.java BulletListScannerTest.java CompositeTagScannerTest.java FormScannerTest.java LabelScannerTest.java LinkScannerTest.java MetaTagScannerTest.java StyleScannerTest.java TableScannerTest.java TitleScannerTest.java Log Message: Updated tests to correspond to new behaviour. Mostly due to changes in order and case of tag contents. Of the forty odd remaining failing tests, the majority comprise altered functionality that needs to be resolved. Index: BodyScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/BodyScannerTest.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** BodyScannerTest.java 22 Sep 2003 02:40:09 -0000 1.13 --- BodyScannerTest.java 6 Oct 2003 01:43:28 -0000 1.14 *************** *** 53,62 **** BodyTag bodyTag = (BodyTag) node[4]; assertEquals("Body","This is a body tag",bodyTag.getBody()); ! assertEquals("Body","<BODY>This is a body tag</BODY>",bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } public void testBodywithJsp() throws ParserException { ! createParser("<html><head><title>Test 1</title></head><body><%=BodyValue%></body></html>"); parser.registerScanners(); BodyScanner bodyScanner = new BodyScanner("-b"); --- 53,63 ---- BodyTag bodyTag = (BodyTag) node[4]; assertEquals("Body","This is a body tag",bodyTag.getBody()); ! assertEquals("Body","<body>This is a body tag</body>",bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } public void testBodywithJsp() throws ParserException { ! String body = "<body><%=BodyValue%></body>"; ! createParser("<html><head><title>Test 1</title></head>" + body + "</html>"); parser.registerScanners(); BodyScanner bodyScanner = new BodyScanner("-b"); *************** *** 66,75 **** // check the body node BodyTag bodyTag = (BodyTag) node[4]; ! assertStringEquals("Body","<BODY><%=BodyValue%></BODY>",bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } public void testBodyMixed() throws ParserException { ! createParser("<html><head><title>Test 1</title></head><body>before jsp<%=BodyValue%>after jsp</body></html>"); parser.registerScanners(); BodyScanner bodyScanner = new BodyScanner("-b"); --- 67,77 ---- // check the body node BodyTag bodyTag = (BodyTag) node[4]; ! assertStringEquals("Body",body,bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } public void testBodyMixed() throws ParserException { ! String body = "<body>before jsp<%=BodyValue%>after jsp</body>"; ! createParser("<html><head><title>Test 1</title></head>" + body + "</html>"); parser.registerScanners(); BodyScanner bodyScanner = new BodyScanner("-b"); *************** *** 79,88 **** // check the body node BodyTag bodyTag = (BodyTag) node[4]; ! assertEquals("Body","<BODY>before jsp<%=BodyValue%>after jsp</BODY>",bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } public void testBodyEnding() throws ParserException { ! createParser("<html><body>before jsp<%=BodyValue%>after jsp</html>"); parser.registerScanners(); BodyScanner bodyScanner = new BodyScanner("-b"); --- 81,91 ---- // check the body node BodyTag bodyTag = (BodyTag) node[4]; ! assertEquals("Body",body,bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } public void testBodyEnding() throws ParserException { ! String body = "<body>before jsp<%=BodyValue%>after jsp"; ! createParser("<html>" + body + "</html>"); parser.registerScanners(); BodyScanner bodyScanner = new BodyScanner("-b"); *************** *** 92,96 **** // check the body node BodyTag bodyTag = (BodyTag) node[1]; ! assertEquals("Body","<BODY>before jsp<%=BodyValue%>after jsp</BODY>",bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } --- 95,99 ---- // check the body node BodyTag bodyTag = (BodyTag) node[1]; ! assertEquals("Body",body + "</body>",bodyTag.toHtml()); assertEquals("Body Scanner",bodyScanner,bodyTag.getThisScanner()); } Index: BulletListScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/BulletListScannerTest.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** BulletListScannerTest.java 22 Sep 2003 02:40:09 -0000 1.9 --- BulletListScannerTest.java 6 Oct 2003 01:43:28 -0000 1.10 *************** *** 87,91 **** assertStringEquals( "expected text", ! "Energy supply\r\n" + " (Campbell) ", firstNodeInFirstBullet.toPlainTextString() --- 87,91 ---- assertStringEquals( "expected text", ! "Energy supply\n" + " (Campbell) ", firstNodeInFirstBullet.toPlainTextString() Index: CompositeTagScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/CompositeTagScannerTest.java,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** CompositeTagScannerTest.java 28 Sep 2003 15:33:59 -0000 1.40 --- CompositeTagScannerTest.java 6 Oct 2003 01:43:28 -0000 1.41 *************** *** 72,115 **** public void testEmptyCompositeTag() throws ParserException { ! createParser( ! "<Custom/>" ! ); CustomTag customTag = parseCustomTag(1); assertEquals("child count",0,customTag.getChildCount()); assertTrue("custom tag should be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertStringEquals("html","<CUSTOM/>",customTag.toHtml()); } public void testEmptyCompositeTagAnotherStyle() throws ParserException { ! createParser( ! "<Custom></Custom>" ! ); CustomTag customTag = parseCustomTag(1); assertEquals("child count",0,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertEquals("html","<CUSTOM></CUSTOM>",customTag.toHtml()); } public void testCompositeTagWithOneTextChild() throws ParserException { ! createParser( "<Custom>" + "Hello" + ! "</Custom>" ! ); CustomTag customTag = parseCustomTag(1); assertEquals("child count",1,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); Node child = customTag.childAt(0); --- 72,113 ---- public void testEmptyCompositeTag() throws ParserException { ! String html = "<Custom/>"; ! createParser(html); CustomTag customTag = parseCustomTag(1); assertEquals("child count",0,customTag.getChildCount()); assertTrue("custom tag should be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",9,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); ! assertStringEquals("html",html,customTag.toHtml()); } public void testEmptyCompositeTagAnotherStyle() throws ParserException { ! String html = "<Custom></Custom>"; ! createParser(html); CustomTag customTag = parseCustomTag(1); assertEquals("child count",0,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); ! assertEquals("html",html,customTag.toHtml()); } public void testCompositeTagWithOneTextChild() throws ParserException { ! String html = "<Custom>" + "Hello" + ! "</Custom>"; ! createParser(html); CustomTag customTag = parseCustomTag(1); assertEquals("child count",1,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); Node child = customTag.childAt(0); *************** *** 119,125 **** public void testCompositeTagWithTagChild() throws ParserException { createParser( "<Custom>" + ! "<Hello>" + "</Custom>" ); --- 117,124 ---- public void testCompositeTagWithTagChild() throws ParserException { + String childtag = "<Hello>"; createParser( "<Custom>" + ! childtag + "</Custom>" ); *************** *** 128,144 **** assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); assertEquals("custom tag starting loc",0,customTag.elementBegin()); ! assertEquals("custom tag ending loc",23,customTag.elementEnd()); Node child = customTag.childAt(0); assertType("child",Tag.class,child); ! assertStringEquals("child html","<HELLO>",child.toHtml()); } public void testCompositeTagWithAnotherTagChild() throws ParserException { createParser( "<Custom>" + ! "<Another/>" + "</Custom>" ); --- 127,144 ---- assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); assertEquals("custom tag starting loc",0,customTag.elementBegin()); ! assertEquals("custom tag ending loc",24,customTag.elementEnd()); Node child = customTag.childAt(0); assertType("child",Tag.class,child); ! assertStringEquals("child html",childtag,child.toHtml()); } public void testCompositeTagWithAnotherTagChild() throws ParserException { + String childtag = "<Another/>"; createParser( "<Custom>" + ! childtag + "</Custom>" ); *************** *** 148,154 **** assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); assertEquals("custom tag starting loc",0,customTag.elementBegin()); ! assertEquals("custom tag ending loc",26,customTag.elementEnd()); Node child = customTag.childAt(0); --- 148,154 ---- assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); assertEquals("custom tag starting loc",0,customTag.elementBegin()); ! assertEquals("custom tag ending loc",27,customTag.elementEnd()); Node child = customTag.childAt(0); *************** *** 156,163 **** AnotherTag tag = (AnotherTag)child; assertEquals("another tag start pos",8,tag.elementBegin()); ! assertEquals("another tag ending pos",17,tag.elementEnd()); assertEquals("custom end tag start pos",18,customTag.getEndTag().elementBegin()); ! assertStringEquals("child html","<ANOTHER/>",child.toHtml()); } --- 156,163 ---- AnotherTag tag = (AnotherTag)child; assertEquals("another tag start pos",8,tag.elementBegin()); ! assertEquals("another tag ending pos",18,tag.elementEnd()); assertEquals("custom end tag start pos",18,customTag.getEndTag().elementBegin()); ! assertStringEquals("child html",childtag,child.toHtml()); } *************** *** 251,308 **** public void testErroneousCompositeTag() throws ParserException { ! createParser("<custom>"); CustomTag customTag = parseCustomTag(1); assertEquals("child count",0,customTag.getChildCount()); ! assertFalse("custom tag should be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertStringEquals("html","<CUSTOM></CUSTOM>",customTag.toHtml()); } public void testErroneousCompositeTagWithChildren() throws ParserException { ! createParser( ! "<custom>" + ! "<firstChild>" + ! "<secondChild>" ! ); CustomTag customTag = parseCustomTag(1); assertEquals("child count",2,customTag.getChildCount()); ! assertFalse("custom tag should be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertStringEquals("html","<CUSTOM><FIRSTCHILD><SECONDCHILD></CUSTOM>",customTag.toHtml()); } public void testErroneousCompositeTagWithChildrenAndLineBreak() throws ParserException { ! createParser( ! "<custom>" + ! "<firstChild>\n" + ! "<secondChild>" ! ); CustomTag customTag = parseCustomTag(1); ! assertEquals("child count",2,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",2,customTag.tagData.getEndLine()); ! assertStringEquals( ! "html", ! "<CUSTOM><FIRSTCHILD>\r\n" + ! "<SECONDCHILD>" + ! "</CUSTOM>", ! customTag.toHtml() ); } public void testTwoConsecutiveErroneousCompositeTags() throws ParserException { ! createParser( ! "<custom>something" + ! "<custom></endtag>" ! ); parser.addScanner(new CustomScanner(false)); parseAndAssertNodeCount(2); --- 251,297 ---- public void testErroneousCompositeTag() throws ParserException { ! String html = "<custom>"; ! createParser(html); CustomTag customTag = parseCustomTag(1); assertEquals("child count",0,customTag.getChildCount()); ! assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); ! assertStringEquals("html",html + "</custom>",customTag.toHtml()); } public void testErroneousCompositeTagWithChildren() throws ParserException { ! String html = "<custom>" + "<firstChild>" + "<secondChild>"; ! createParser(html); CustomTag customTag = parseCustomTag(1); assertEquals("child count",2,customTag.getChildCount()); ! assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); ! assertStringEquals("html",html + "</custom>",customTag.toHtml()); } public void testErroneousCompositeTagWithChildrenAndLineBreak() throws ParserException { ! String html = "<custom>" + "<firstChild>" + "\n" + "<secondChild>"; ! createParser(html); CustomTag customTag = parseCustomTag(1); ! assertEquals("child count",3,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertStringEquals("html", html + "</custom>", customTag.toHtml() ); } public void testTwoConsecutiveErroneousCompositeTags() throws ParserException { ! String tag1 = "<custom>something"; ! String tag2 = "<custom></endtag>"; ! createParser(tag1 + tag2); parser.addScanner(new CustomScanner(false)); parseAndAssertNodeCount(2); *************** *** 311,336 **** assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); ! assertEquals("ending loc of custom tag",25,customTag.elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertStringEquals( ! "first custom tag", ! "<CUSTOM>something</CUSTOM>", ! customTag.toHtml() ! ); customTag = (CustomTag)node[1]; ! assertStringEquals( ! "second custom tag", ! "<CUSTOM></ENDTAG></CUSTOM>", ! customTag.toHtml() ! ); } public void testCompositeTagWithErroneousAnotherTagAndLineBreak() throws ParserException { createParser( ! "<another>" + ! "<custom>\n" + ! "</custom>" ); parser.addScanner(new AnotherScanner()); --- 300,318 ---- assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("ending loc of custom tag",17,customTag.elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); ! assertStringEquals("1st custom tag", tag1 + "</custom>", customTag.toHtml()); customTag = (CustomTag)node[1]; ! assertStringEquals("2nd custom tag", tag2 + "</custom>", customTag.toHtml()); } public void testCompositeTagWithErroneousAnotherTagAndLineBreak() throws ParserException { + String another = "<another>"; + String custom = "<custom>\n</custom>"; createParser( ! another + ! custom ); parser.addScanner(new AnotherScanner()); *************** *** 341,352 **** CustomTag customTag = (CustomTag)node[1]; ! assertEquals("child count",0,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",9,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",16,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",2,customTag.tagData.getEndLine()); ! assertStringEquals("another tag html","<ANOTHER></ANOTHER>",anotherTag.toHtml()); ! assertStringEquals("custom tag html","<CUSTOM>\r\n</CUSTOM>",customTag.toHtml()); } --- 323,334 ---- CustomTag customTag = (CustomTag)node[1]; ! assertEquals("child count",1,customTag.getChildCount()); assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",9,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",17,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertStringEquals("another tag html",another,anotherTag.toHtml()); ! assertStringEquals("custom tag html",custom,customTag.toHtml()); } *************** *** 362,371 **** assertFalse("custom tag should be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); ! assertEquals("another tag ending loc",26,anotherTag.elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); ! assertStringEquals("html","<CUSTOM><ANOTHER></ANOTHER></CUSTOM>",customTag.toHtml()); } --- 344,353 ---- assertFalse("custom tag should be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); ! assertEquals("another tag ending loc",17,anotherTag.elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); ! assertStringEquals("html","<custom><another></another></custom>",customTag.toHtml()); } *************** *** 384,390 **** assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",1,customTag.tagData.getStartLine()); ! assertEquals("ending line position",1,customTag.tagData.getEndLine()); AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); assertEquals("anotherTag child count",1,anotherTag.getChildCount()); --- 366,372 ---- assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); ! assertEquals("starting line position",0,customTag.tagData.getStartLine()); ! assertEquals("ending line position",0,customTag.tagData.getEndLine()); AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); assertEquals("anotherTag child count",1,anotherTag.getChildCount()); *************** *** 393,397 **** assertStringEquals( "first custom tag html", ! "<CUSTOM><ANOTHER>something</ANOTHER></CUSTOM>", customTag.toHtml() ); --- 375,379 ---- assertStringEquals( "first custom tag html", ! "<custom><another>something</another></custom>", customTag.toHtml() ); *************** *** 399,403 **** assertStringEquals( "second custom tag html", ! "<CUSTOM><ANOTHER>else</ANOTHER></CUSTOM>", customTag.toHtml() ); --- 381,385 ---- assertStringEquals( "second custom tag html", ! "<custom><another>else</another></custom>", customTag.toHtml() ); *************** *** 415,424 **** assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",7,customTag.getStartTag().elementEnd()); AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); ! assertEquals("anotherTag child count",1,anotherTag.getChildCount()); ! assertEquals("anotherTag end loc",9,anotherTag.elementEnd()); ! assertEquals("custom end tag begin loc",10,customTag.getEndTag().elementBegin()); ! assertEquals("custom end tag end loc",8,customTag.getEndTag().elementEnd()); } --- 397,406 ---- assertFalse("custom tag should not be xml end tag",customTag.isEmptyXmlTag()); assertEquals("starting loc",0,customTag.getStartTag().elementBegin()); ! assertEquals("ending loc",8,customTag.getStartTag().elementEnd()); AnotherTag anotherTag = (AnotherTag)customTag.childAt(0); ! assertEquals("anotherTag child count",2,anotherTag.getChildCount()); ! assertEquals("anotherTag end loc",27,anotherTag.elementEnd()); ! assertEquals("custom end tag begin loc",27,customTag.getEndTag().elementBegin()); ! assertEquals("custom end tag end loc",36,customTag.getEndTag().elementEnd()); } Index: FormScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/FormScannerTest.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** FormScannerTest.java 5 Oct 2003 13:49:54 -0000 1.34 --- FormScannerTest.java 6 Oct 2003 01:43:28 -0000 1.35 *************** *** 61,81 **** "</FORM>"; ! public static final String EXPECTED_FORM_HTML_FORMLINE="<FORM ACTION=\"http://www.google.com/test/do_login.php\" NAME=\"login_form\" ONSUBMIT=\"return CheckData()\" METHOD=\""+FormTag.POST+"\">\r\n"; ! public static final String EXPECTED_FORM_HTML_REST_OF_FORM= ! "<TR><TD ALIGN=\"center\"> </TD></TR>\r\n"+ ! "<TR><TD ALIGN=\"center\"><FONT FACE=\"Arial, verdana\" SIZE=\"2\"><B>User Name</B></FONT></TD></TR>\r\n"+ ! "<TR><TD ALIGN=\"center\"><INPUT NAME=\"name\" SIZE=\"20\" TYPE=\"text\"></TD></TR>\r\n"+ ! "<TR><TD ALIGN=\"center\"><FONT FACE=\"Arial, verdana\" SIZE=\"2\"><B>Password</B></FONT></TD></TR>\r\n"+ ! "<TR><TD ALIGN=\"center\"><INPUT NAME=\"passwd\" SIZE=\"20\" TYPE=\"password\"></TD></TR>\r\n"+ ! "<TR><TD ALIGN=\"center\"> </TD></TR>\r\n"+ ! "<TR><TD ALIGN=\"center\"><INPUT VALUE=\"Login\" NAME=\"submit\" TYPE=\"submit\"></TD></TR>\r\n"+ ! "<TR><TD ALIGN=\"center\"> </TD></TR>\r\n"+ ! "<TEXTAREA TABINDEX=\"5\" ROWS=\"15\" COLS=\"55\" CLASS=\"composef\" NAME=\"Description\" WRAP=\"virtual\">Contents of TextArea</TEXTAREA>\r\n"+ ! // "<TEXTAREA TABINDEX=\"5\" ROWS=\"15\" COLS=\"55\" CLASS=\"composef\" NAME=\"AnotherDescription\" WRAP=\"virtual\">\r\n"+ ! "<INPUT NAME=\"password\" SIZE=\"20\" TYPE=\"hidden\">\r\n"+ ! "<INPUT TYPE=\"submit\">\r\n"+ ! "</FORM>"; ! public static final String EXPECTED_FORM_HTML = EXPECTED_FORM_HTML_FORMLINE+EXPECTED_FORM_HTML_REST_OF_FORM; ! public FormScannerTest(String name) { super(name); --- 61,81 ---- "</FORM>"; ! // public static final String EXPECTED_FORM_HTML_FORMLINE="<FORM ACTION=\"http://www.google.com/test/do_login.php\" NAME=\"login_form\" ONSUBMIT=\"return CheckData()\" METHOD=\""+FormTag.POST+"\">\r\n"; ! // public static final String EXPECTED_FORM_HTML_REST_OF_FORM= ! // "<TR><TD ALIGN=\"center\"> </TD></TR>\r\n"+ ! // "<TR><TD ALIGN=\"center\"><FONT FACE=\"Arial, verdana\" SIZE=\"2\"><B>User Name</B></FONT></TD></TR>\r\n"+ ! // "<TR><TD ALIGN=\"center\"><INPUT NAME=\"name\" SIZE=\"20\" TYPE=\"text\"></TD></TR>\r\n"+ ! // "<TR><TD ALIGN=\"center\"><FONT FACE=\"Arial, verdana\" SIZE=\"2\"><B>Password</B></FONT></TD></TR>\r\n"+ ! // "<TR><TD ALIGN=\"center\"><INPUT NAME=\"passwd\" SIZE=\"20\" TYPE=\"password\"></TD></TR>\r\n"+ ! // "<TR><TD ALIGN=\"center\"> </TD></TR>\r\n"+ ! // "<TR><TD ALIGN=\"center\"><INPUT VALUE=\"Login\" NAME=\"submit\" TYPE=\"submit\"></TD></TR>\r\n"+ ! // "<TR><TD ALIGN=\"center\"> </TD></TR>\r\n"+ ! // "<TEXTAREA TABINDEX=\"5\" ROWS=\"15\" COLS=\"55\" CLASS=\"composef\" NAME=\"Description\" WRAP=\"virtual\">Contents of TextArea</TEXTAREA>\r\n"+ ! //// "<TEXTAREA TABINDEX=\"5\" ROWS=\"15\" COLS=\"55\" CLASS=\"composef\" NAME=\"AnotherDescription\" WRAP=\"virtual\">\r\n"+ ! // "<INPUT NAME=\"password\" SIZE=\"20\" TYPE=\"hidden\">\r\n"+ ! // "<INPUT TYPE=\"submit\">\r\n"+ ! // "</FORM>"; ! // public static final String EXPECTED_FORM_HTML = EXPECTED_FORM_HTML_FORMLINE+EXPECTED_FORM_HTML_REST_OF_FORM; ! // public FormScannerTest(String name) { super(name); *************** *** 129,133 **** assertNull("Should have been null",formTag.getTextAreaTag("junk")); ! assertStringEquals("toHTML",EXPECTED_FORM_HTML,formTag.toHtml()); } --- 129,137 ---- 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()); } *************** *** 313,317 **** for (NodeIterator e = parser.elements(); e.hasMoreNodes();) nodes[i++] = e.nextNode(); ! assertEquals ("Expected nodes", 39, i); } } --- 317,321 ---- for (NodeIterator e = parser.elements(); e.hasMoreNodes();) nodes[i++] = e.nextNode(); ! assertEquals ("Expected nodes", 40, i); } } Index: LabelScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/LabelScannerTest.java,v retrieving revision 1.37 retrieving revision 1.38 diff -C2 -d -r1.37 -r1.38 *** LabelScannerTest.java 5 Oct 2003 13:49:54 -0000 1.37 --- LabelScannerTest.java 6 Oct 2003 01:43:28 -0000 1.38 *************** *** 59,63 **** public void testLabelWithJspTag() throws ParserException { ! createParser("<label><%=labelValue%></label>"); parser.registerScanners(); LabelScanner labelScanner = new LabelScanner("-l"); --- 59,64 ---- public void testLabelWithJspTag() throws ParserException { ! String label = "<label><%=labelValue%></label>"; ! createParser(label); parser.registerScanners(); LabelScanner labelScanner = new LabelScanner("-l"); *************** *** 67,71 **** // check the title node LabelTag labelTag = (LabelTag) node[0]; ! assertStringEquals("Label","<LABEL><%=labelValue%></LABEL>",labelTag.toHtml()); assertEquals("Label Scanner",labelScanner,labelTag.getThisScanner()); } --- 68,72 ---- // check the title node LabelTag labelTag = (LabelTag) node[0]; ! assertStringEquals("Label",label,labelTag.toHtml()); assertEquals("Label Scanner",labelScanner,labelTag.getThisScanner()); } *************** *** 86,90 **** public void testLabelWithManyCompositeTags() throws ParserException { ! createParser("<label><span>Jane <b> Doe </b> Smith</span></label>"); parser.registerScanners(); LabelScanner labelScanner = new LabelScanner("-l"); --- 87,93 ---- public void testLabelWithManyCompositeTags() throws ParserException { ! String guts = "<span>Jane <b> Doe </b> Smith</span>"; ! String html = "<label>" + guts + "</label>"; ! createParser(html); parser.registerScanners(); LabelScanner labelScanner = new LabelScanner("-l"); *************** *** 93,99 **** assertTrue(node[0] instanceof LabelTag); LabelTag labelTag = (LabelTag) node[0]; ! assertEquals("Label value","<SPAN>Jane <B> Doe </B> Smith</SPAN>",labelTag.getChildrenHTML()); assertEquals("Label value","Jane Doe Smith",labelTag.getLabel()); ! assertStringEquals("Label","<LABEL><SPAN>Jane <B> Doe </B> Smith</SPAN></LABEL>",labelTag.toHtml()); assertEquals("Label Scanner",labelScanner,labelTag.getThisScanner()); } --- 96,102 ---- assertTrue(node[0] instanceof LabelTag); LabelTag labelTag = (LabelTag) node[0]; ! assertEquals("Label value",guts,labelTag.getChildrenHTML()); assertEquals("Label value","Jane Doe Smith",labelTag.getLabel()); ! assertStringEquals("Label",html,labelTag.toHtml()); assertEquals("Label Scanner",labelScanner,labelTag.getThisScanner()); } *************** *** 170,182 **** assertStringEquals("HTML String","<LABEL>Yahoo!</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[4]; ! assertStringEquals("HTML String","<LABEL>\r\nHotmail</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[5]; assertStringEquals("HTML String","<LABEL VALUE=\"ICQ Messenger\"></LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[6]; ! assertStringEquals("HTML String","<LABEL>Mailcity\r\n</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[7]; ! assertStringEquals("HTML String","<LABEL>\r\nIndiatimes\r\n</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[8]; ! assertStringEquals("HTML String","<LABEL>\r\nRediff\r\n</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[9]; assertStringEquals("HTML String","<LABEL>Cricinfo</LABEL>",LabelTag.toHtml()); --- 173,185 ---- assertStringEquals("HTML String","<LABEL>Yahoo!</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[4]; ! assertStringEquals("HTML String","<LABEL>\nHotmail</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[5]; assertStringEquals("HTML String","<LABEL VALUE=\"ICQ Messenger\"></LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[6]; ! assertStringEquals("HTML String","<LABEL>Mailcity\n</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[7]; ! assertStringEquals("HTML String","<LABEL>\nIndiatimes\n</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[8]; ! assertStringEquals("HTML String","<LABEL>\nRediff\n</LABEL>",LabelTag.toHtml()); LabelTag = (LabelTag) node[9]; assertStringEquals("HTML String","<LABEL>Cricinfo</LABEL>",LabelTag.toHtml()); Index: LinkScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/LinkScannerTest.java,v retrieving revision 1.39 retrieving revision 1.40 diff -C2 -d -r1.39 -r1.40 *** LinkScannerTest.java 5 Oct 2003 13:49:54 -0000 1.39 --- LinkScannerTest.java 6 Oct 2003 01:43:28 -0000 1.40 *************** *** 29,32 **** --- 29,33 ---- package org.htmlparser.tests.scannersTests; + import java.util.Vector; import org.htmlparser.AbstractNode; *************** *** 34,37 **** --- 35,39 ---- import org.htmlparser.Parser; import org.htmlparser.StringNode; + import org.htmlparser.lexer.nodes.Attribute; import org.htmlparser.scanners.LinkScanner; import org.htmlparser.tags.ImageTag; *************** *** 69,81 **** ); parser.registerScanners(); ! parseAndAssertNodeCount(5); // 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 HTMLStringNode",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); ! } --- 71,85 ---- ); parser.registerScanners(); ! parseAndAssertNodeCount(6); // 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); ! assertTrue("Fifth node should be a link",node[4] instanceof LinkTag); ! assertTrue("Sixth node should be a Tag",node[5] instanceof Tag); } *************** *** 89,96 **** */ public void testErroneousLinkBugFromYahoo2() throws ParserException { createParser( "<td>" + ! "<a href=s/8741>" + ! "<img src=\"http://us.i1.yimg.com/us.yimg.com/i/i16/mov_popc.gif\" height=16 width=16 border=0>" + "</td>" + "<td nowrap> \n"+ --- 93,101 ---- */ public void testErroneousLinkBugFromYahoo2() throws ParserException { + String link = "<a href=s/8741>" + + "<img src=\"http://us.i1.yimg.com/us.yimg.com/i/i16/mov_popc.gif\" height=16 width=16 border=0>"; createParser( "<td>" + ! link + "</td>" + "<td nowrap> \n"+ *************** *** 106,110 **** assertStringEquals("Link Text","",linkTag.getLinkText()); // Verify the reconstruction html ! assertStringEquals("toHTML","<A HREF=\"s/8741\"><IMG BORDER=\"0\" WIDTH=\"16\" SRC=\"http://us.i1.yimg.com/us.yimg.com/i/i16/mov_popc.gif\" HEIGHT=\"16\"></A>",linkTag.toHtml()); } --- 111,115 ---- assertStringEquals("Link Text","",linkTag.getLinkText()); // Verify the reconstruction html ! assertStringEquals("toHTML",link + "</a>",linkTag.toHtml()); } *************** *** 118,122 **** */ public void testErroneousLinkBugFromYahoo() throws ParserException { ! createParser( "<a href=s/8741>" + "<img src=\"http://us.i1.yimg.com/us.yimg.com/i/i16/mov_popc.gif\" " + --- 123,127 ---- */ public void testErroneousLinkBugFromYahoo() throws ParserException { ! String link = "<a href=s/8741>" + "<img src=\"http://us.i1.yimg.com/us.yimg.com/i/i16/mov_popc.gif\" " + *************** *** 124,128 **** "width=16 " + "border=0>" + ! "This is a test\n"+ "<a href=s/7509>" + "<b>Yahoo! Movies</b>" + --- 129,135 ---- "width=16 " + "border=0>" + ! "This is a test\n"; ! createParser( ! link + "<a href=s/7509>" + "<b>Yahoo! Movies</b>" + *************** *** 133,146 **** parser.registerScanners(); parseAndAssertNodeCount(2); ! // The first node should be a Tag ! assertTrue("First node should be a HTMLLinkTag",node[0] instanceof LinkTag); ! // The second node should be a HTMLStringNode ! assertTrue("Second node should be a HTMLLinkTag",node[1] instanceof LinkTag); LinkTag linkTag = (LinkTag)node[0]; assertEquals("Link","http://www.yahoo.com/s/8741",linkTag.getLink()); // Verify the link data ! assertEquals("Link Text","This is a test\r\n",linkTag.getLinkText()); // Verify the reconstruction html ! assertStringEquals("toHTML()","<A HREF=\"s/8741\"><IMG BORDER=\"0\" WIDTH=\"16\" SRC=\"http://us.i1.yimg.com/us.yimg.com/i/i16/mov_popc.gif\" HEIGHT=\"16\">This is a test\r\n</A>",linkTag.toHtml()); } --- 140,151 ---- parser.registerScanners(); parseAndAssertNodeCount(2); ! assertTrue("First node should be a LinkTag",node[0] instanceof LinkTag); ! assertTrue("Second node should be a LinkTag",node[1] instanceof LinkTag); LinkTag linkTag = (LinkTag)node[0]; assertEquals("Link","http://www.yahoo.com/s/8741",linkTag.getLink()); // Verify the link data ! assertEquals("Link Text","This is a test\n",linkTag.getLinkText()); // Verify the reconstruction html ! assertStringEquals("toHTML()",link + "</a>",linkTag.toHtml()); } *************** *** 157,166 **** public void testExtractLinkInvertedCommasBug() throws ParserException { ! fail ("not implemented"); ! // String tagContents = "a href=r/anorth/top.html"; ! // Tag tag = new Tag(new TagData(0,0,tagContents,"")); ! // String url = "c:\\cvs\\html\\binaries\\yahoo.htm"; ! // LinkScanner scanner = new LinkScanner("-l"); ! // assertEquals("Extracted Link","r/anorth/top.html",scanner.extractLink(tag,url)); } --- 162,173 ---- public void testExtractLinkInvertedCommasBug() throws ParserException { ! String link = "r/anorth/top.html"; ! Vector attributes = new Vector (); ! attributes.addElement (new Attribute ("A")); ! attributes.addElement (new Attribute ("HREF", link, (char)0)); ! Tag tag = new Tag(null, 0, 0, attributes); ! String url = "c:\\cvs\\html\\binaries\\yahoo.htm"; ! LinkScanner scanner = new LinkScanner(); ! assertEquals("Extracted Link","r/anorth/top.html",scanner.extractLink(tag,url)); } *************** *** 280,301 **** } - public void testReplaceFaultyTagWithEndTag() throws ParserException { - fail ("not implemented"); - // String currentLine = "<p>Site Comments?<br><a href=\"mailto:sa...@ne...?subject=Site Comments\">Mail Us<a></p>"; - // Tag tag = new Tag(new TagData(85,87,"a",currentLine)); - // LinkScanner linkScanner = new LinkScanner(); - // String newLine = linkScanner.replaceFaultyTagWithEndTag(tag,currentLine); - // assertEquals("Expected replacement","<p>Site Comments?<br><a href=\"mailto:sa...@ne...?subject=Site Comments\">Mail Us</A></p>",newLine); - } - - public void testInsertEndTagBeforeTag() throws ParserException { - fail ("not implemented"); - // String currentLine = "<a href=s/7509><b>Yahoo! Movies</b></a>"; - // Tag tag = new Tag(new TagData(0,14,"a href=s/7509",currentLine)); - // LinkScanner linkScanner = new LinkScanner(); - // String newLine = linkScanner.insertEndTagBeforeNode(tag,currentLine); - // assertEquals("Expected insertion","</A><a href=s/7509><b>Yahoo! Movies</b></a>",newLine); - } - /** * A bug in the freshmeat page - really bad html --- 287,290 ---- *************** *** 318,322 **** tag = (Tag)node[2]; assertTrue("Node 2 should be an end tag",tag.isEndTag ()); ! assertEquals("End Tag Contents","a",tag.getText()); } --- 307,311 ---- tag = (Tag)node[2]; assertTrue("Node 2 should be an end tag",tag.isEndTag ()); ! assertEquals("End Tag Contents","/a",tag.getText()); } *************** *** 380,388 **** Tag tag = (Tag)containedNodes[3]; assertTrue("Fourth contained node should be an EndTag",tag.isEndTag ()); ! assertEquals("Fourth Tag contents","b",tag.getText()); assertTrue("Fifth contained node should be a Tag",containedNodes[4] instanceof Tag); tag = (Tag)containedNodes[4]; assertTrue("Fifth contained node should be an EndTag",tag.isEndTag ()); ! assertEquals("Fifth Tag contents","font",tag.getText()); } --- 369,377 ---- Tag tag = (Tag)containedNodes[3]; assertTrue("Fourth contained node should be an EndTag",tag.isEndTag ()); ! assertEquals("Fourth Tag contents","/b",tag.getText()); assertTrue("Fifth contained node should be a Tag",containedNodes[4] instanceof Tag); tag = (Tag)containedNodes[4]; assertTrue("Fifth contained node should be an EndTag",tag.isEndTag ()); ! assertEquals("Fifth Tag contents","/font",tag.getText()); } *************** *** 399,404 **** parser.registerScanners(); parseAndAssertNodeCount(11); ! assertTrue("Node 4 should be a link tag",node[6] instanceof LinkTag); ! LinkTag linkTag = (LinkTag)node[6]; assertEquals("Resolved Link","http://www.abc.com/home.cfm",linkTag.getLink()); assertEquals("Resolved Link Text","Home",linkTag.getLinkText()); --- 388,393 ---- parser.registerScanners(); parseAndAssertNodeCount(11); ! assertTrue("Node 9 should be a link tag",node[8] instanceof LinkTag); ! LinkTag linkTag = (LinkTag)node[8]; assertEquals("Resolved Link","http://www.abc.com/home.cfm",linkTag.getLink()); assertEquals("Resolved Link Text","Home",linkTag.getLinkText()); Index: MetaTagScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/MetaTagScannerTest.java,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** MetaTagScannerTest.java 5 Oct 2003 13:49:54 -0000 1.30 --- MetaTagScannerTest.java 6 Oct 2003 01:43:28 -0000 1.31 *************** *** 42,45 **** --- 42,48 ---- public void testScan() throws ParserException { + String description = "\"description\""; + String content = "\"Protecting the internet community through technology, not legislation. SpamCop eliminates spam. Automatically file spam reports with the network administrators who can stop spam at the source. Subscribe, and filter your email through powerful statistical analysis before it reaches your inbox.\""; + String tag = "<META name=" + description + " content=" + content + ">"; createParser( "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\">\n"+ *************** *** 47,90 **** "<head><title>SpamCop - Welcome to SpamCop\n"+ "</title>\n"+ ! "<META name=\"description\" content=\"Protecting the internet community through technology, not legislation. SpamCop eliminates spam. Automatically file spam reports with the network administrators who can stop spam at the source. Subscribe, and filter your email through powerful statistical analysis before it reaches your inbox.\">\n"+ "<META name=\"keywords\" content=\"SpamCop spam cop email filter abuse header headers parse parser utility script net net-abuse filter mail program system trace traceroute dns\">\n"+ "<META name=\"language\" content=\"en\">\n"+ "<META name=\"owner\" content=\"se...@ad...\">\n"+ ! "<META HTTP-EQUIV=\"content-type\" CONTENT=\"text/html; charset=ISO-8859-1\">","http://www.google.com/test/index.html"); MetaTagScanner scanner = new MetaTagScanner("-t"); parser.addScanner(scanner); parseAndAssertNodeCount(18); ! assertTrue("Node 7 should be End Tag",node[7] instanceof Tag && ((Tag)node[7]).isEndTag ()); ! assertTrue("Node 9 should be META Tag",node[9] instanceof MetaTag); MetaTag metaTag; metaTag = (MetaTag) node[9]; ! assertEquals("Meta Tag 9 Name","description",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 9 Contents","Protecting the internet community through technology, not legislation. SpamCop eliminates spam. Automatically file spam reports with the network administrators who can stop spam at the source. Subscribe, and filter your email through powerful statistical analysis before it reaches your inbox.",metaTag.getMetaContent()); ! assertTrue("Node 11 should be META Tag",node[11] instanceof MetaTag); ! assertTrue("Node 13 should be META Tag",node[13] instanceof MetaTag); ! assertTrue("Node 15 should be META Tag",node[15] instanceof MetaTag); ! assertTrue("Node 17 should be META Tag",node[17] instanceof MetaTag); metaTag = (MetaTag) node[11]; ! assertEquals("Meta Tag 11 Name","keywords",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 11 Contents","SpamCop spam cop email filter abuse header headers parse parser utility script net net-abuse filter mail program system trace traceroute dns",metaTag.getMetaContent()); ! assertNull("Meta Tag 11 Http-Equiv",metaTag.getHttpEquiv()); metaTag = (MetaTag) node[13]; ! assertEquals("Meta Tag 13 Name","language",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 13 Contents","en",metaTag.getMetaContent()); ! assertNull("Meta Tag 13 Http-Equiv",metaTag.getHttpEquiv()); metaTag = (MetaTag) node[15]; ! assertEquals("Meta Tag 15 Name","owner",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 15 Contents","se...@ad...",metaTag.getMetaContent()); ! assertNull("Meta Tag 15 Http-Equiv",metaTag.getHttpEquiv()); metaTag = (MetaTag) node[17]; ! assertNull("Meta Tag 17 Name",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 17 Contents","text/html; charset=ISO-8859-1",metaTag.getMetaContent()); ! assertEquals("Meta Tag 17 Http-Equiv","content-type",metaTag.getHttpEquiv()); assertEquals("This Scanner",scanner,metaTag.getThisScanner()); --- 50,93 ---- "<head><title>SpamCop - Welcome to SpamCop\n"+ "</title>\n"+ ! tag + "\n"+ "<META name=\"keywords\" content=\"SpamCop spam cop email filter abuse header headers parse parser utility script net net-abuse filter mail program system trace traceroute dns\">\n"+ "<META name=\"language\" content=\"en\">\n"+ "<META name=\"owner\" content=\"se...@ad...\">\n"+ ! "<META HTTP-EQUIV=\"content-type\" CONTENT=\"text/html; charset=ISO-8859-1\">"); MetaTagScanner scanner = new MetaTagScanner("-t"); parser.addScanner(scanner); parseAndAssertNodeCount(18); ! assertTrue("Node 8 should be End Tag",node[7] instanceof Tag && ((Tag)node[7]).isEndTag ()); ! assertTrue("Node 10 should be META Tag",node[9] instanceof MetaTag); MetaTag metaTag; metaTag = (MetaTag) node[9]; ! assertEquals("Meta Tag 10 Name",description,metaTag.getMetaTagName()); ! assertEquals("Meta Tag 10 Contents",content,metaTag.getMetaContent()); ! assertTrue("Node 12 should be META Tag",node[11] instanceof MetaTag); ! assertTrue("Node 14 should be META Tag",node[13] instanceof MetaTag); ! assertTrue("Node 16 should be META Tag",node[15] instanceof MetaTag); ! assertTrue("Node 18 should be META Tag",node[17] instanceof MetaTag); metaTag = (MetaTag) node[11]; ! assertEquals("Meta Tag 12 Name","\"keywords\"",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 12 Contents","\"SpamCop spam cop email filter abuse header headers parse parser utility script net net-abuse filter mail program system trace traceroute dns\"",metaTag.getMetaContent()); ! assertNull("Meta Tag 12 Http-Equiv",metaTag.getHttpEquiv()); metaTag = (MetaTag) node[13]; ! assertEquals("Meta Tag 14 Name","\"language\"",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 14 Contents","\"en\"",metaTag.getMetaContent()); ! assertNull("Meta Tag 14 Http-Equiv",metaTag.getHttpEquiv()); metaTag = (MetaTag) node[15]; ! assertEquals("Meta Tag 16 Name","\"owner\"",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 16 Contents","\"se...@ad...\"",metaTag.getMetaContent()); ! assertNull("Meta Tag 16 Http-Equiv",metaTag.getHttpEquiv()); metaTag = (MetaTag) node[17]; ! assertNull("Meta Tag 18 Name",metaTag.getMetaTagName()); ! assertEquals("Meta Tag 18 Contents","\"text/html; charset=ISO-8859-1\"",metaTag.getMetaContent()); ! assertEquals("Meta Tag 18 Http-Equiv","\"content-type\"",metaTag.getHttpEquiv()); assertEquals("This Scanner",scanner,metaTag.getThisScanner()); *************** *** 92,97 **** public void testScanTagsInMeta() throws ParserException { createParser( ! "<META NAME=\"Description\" CONTENT=\"Ethnoburb </I>versus Chinatown: Two Types of Urban Ethnic Communities in Los Angeles\">", "http://www.google.com/test/index.html" ); --- 95,102 ---- public void testScanTagsInMeta() throws ParserException { + String description = "\"Description\""; + String content = "\"Ethnoburb </I>versus Chinatown: Two Types of Urban Ethnic Communities in Los Angeles\""; createParser( ! "<META NAME=" + description + "CONTENT=" + content + ">", "http://www.google.com/test/index.html" ); *************** *** 101,106 **** assertTrue("Node should be meta tag",node[0] instanceof MetaTag); MetaTag metaTag = (MetaTag)node[0]; ! assertEquals("Meta Tag Name","Description",metaTag.getMetaTagName()); ! assertEquals("Content","Ethnoburb </I>versus Chinatown: Two Types of Urban Ethnic Communities in Los Angeles",metaTag.getMetaContent()); } --- 106,111 ---- assertTrue("Node should be meta tag",node[0] instanceof MetaTag); MetaTag metaTag = (MetaTag)node[0]; ! assertEquals("Meta Tag Name",description,metaTag.getMetaTagName()); ! assertEquals("Content",content,metaTag.getMetaContent()); } *************** *** 110,119 **** */ public void testMetaTagBug() throws ParserException { createParser( "<html>" + "<head>" + ! "<meta http-equiv=\"content-type\"" + ! " content=\"text/html;" + ! " charset=windows-1252\">" + "</head>" + "</html>" --- 115,125 ---- */ public void testMetaTagBug() throws ParserException { + String equiv = "\"content-type\""; + String content = "\"text/html; charset=windows-1252\""; createParser( "<html>" + "<head>" + ! "<meta http-equiv=" + equiv + ! " content=" + content + ">" + "</head>" + "</html>" *************** *** 124,129 **** MetaTag metaTag = (MetaTag)node[2]; ! assertStringEquals("http-equiv","content-type",metaTag.getHttpEquiv()); ! assertStringEquals("content","text/html; charset=windows-1252",metaTag.getMetaContent()); } --- 130,135 ---- MetaTag metaTag = (MetaTag)node[2]; ! assertStringEquals("http-equiv",equiv,metaTag.getHttpEquiv()); ! assertStringEquals("content",content,metaTag.getMetaContent()); } *************** *** 133,141 **** */ public void testMetaTagWithOpenTagSymbol() throws ParserException { createParser( "<html>" + "<head>" + "<title>Parser Test 2</title>" + ! "<meta name=\"foo\" content=\"a<b\">" + "</head>" + "<body>" + --- 139,148 ---- */ public void testMetaTagWithOpenTagSymbol() throws ParserException { + String content = "\"a<b\""; createParser( "<html>" + "<head>" + "<title>Parser Test 2</title>" + ! "<meta name=\"foo\" content=" + content + ">" + "</head>" + "<body>" + *************** *** 151,155 **** assertStringEquals( "meta content", ! "a<b", metaTag.getMetaContent() ); --- 158,162 ---- assertStringEquals( "meta content", ! content, metaTag.getMetaContent() ); Index: StyleScannerTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/scannersTests/StyleScannerTest.java,v retrieving revision 1.28 retrieving revision 1.29 diff -C2 -d -r1.28 -r1.29 *** StyleScannerTest.java 22 Sep 2003 02:40:11 -0000 1.28 --- StyleScannerTest.java 6 Oct 2003 01:43:28 -0000 1.29 *************** *** 47,61 **** } ! public void testScan() { createParser("<STYLE TYPE=\"text/css\"><!--\n\n"+ "</STYLE>","http://www.yle.fi/"); parser.addScanner(new StyleScanner("-s")); ! try { ! parseAndAssertNodeCount(1); ! assertTrue("Should've thrown exception",false); ! } ! catch (ParserException e) { ! ! } } --- 47,56 ---- } ! p... [truncated message content] |