[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/parserHelperTests AttributeParserTest.java,1.24
Brought to you by:
derrickoswald
|
From: <der...@us...> - 2003-05-11 20:42:33
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/parserHelperTests
In directory sc8-pr-cvs1:/tmp/cvs-serv22446/org/htmlparser/tests/parserHelperTests
Modified Files:
AttributeParserTest.java TagParserTest.java
Log Message:
Moved pending bugs to the 'feature request' tracker,
and made the failing unit tests execution conditional on the Parser version being >= 1.4.
Index: AttributeParserTest.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/parserHelperTests/AttributeParserTest.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** AttributeParserTest.java 5 May 2003 03:12:24 -0000 1.24
--- AttributeParserTest.java 11 May 2003 20:42:30 -0000 1.25
***************
*** 31,34 ****
--- 31,35 ----
import java.util.Hashtable;
+ import org.htmlparser.Parser;
import org.htmlparser.parserHelper.AttributeParser;
import org.htmlparser.tags.Tag;
***************
*** 131,150 ****
}
- /**
- * attributes are not parsed correctly, when they contain
- * scriptlets.
- * Submitted by Cory Seefurth
- */
- public void testJspWithinAttributes() {
- getParameterTableFor(
- "a href=\"<%=Application(\"sURL\")%>/literature/index.htm"
- );
- assertStringEquals(
- "href",
- "<%=Application(\"sURL\")%>/literature/index.htm",
- (String)table.get("HREF")
- );
- }
-
public void testQuestionMarksInAttributes() {
getParameterTableFor(
--- 132,135 ----
***************
*** 178,190 ****
/**
! * Case of script in attributes.
*/
! public void testScriptedTag () {
! getParameterTableFor("body onLoad=defaultStatus=''");
! String name = (String)table.get(Tag.TAGNAME);
! assertNotNull ("No Tag.TAGNAME", name);
! assertStringEquals("tag name parsed incorrectly", "BODY", name);
! String value = (String)table.get ("ONLOAD");
! assertStringEquals ("parameter parsed incorrectly", "defaultStatus=''", value);
}
}
--- 163,208 ----
/**
! * Test attributes when they contain scriptlets.
! * Submitted by Cory Seefurth
! * See also feature request #725376 Handle script in attributes.
! * Only perform this test if it's version 1.4 or higher.
*/
! public void testJspWithinAttributes()
! {
! Parser parser;
!
! parser = new Parser ();
! if (1.4 <= Double.parseDouble (parser.getVersion ().substring (0, parser.getVersion ().indexOf (' '))))
! {
! getParameterTableFor(
! "a href=\"<%=Application(\"sURL\")%>/literature/index.htm"
! );
! assertStringEquals(
! "href",
! "<%=Application(\"sURL\")%>/literature/index.htm",
! (String)table.get("HREF")
! );
! }
! }
!
! /**
! * Test Script in attributes.
! * See feature request #725376 Handle script in attributes.
! * Only perform this test if it's version 1.4 or higher.
! */
! public void testScriptedTag ()
! {
! Parser parser;
!
! parser = new Parser ();
! if (1.4 <= Double.parseDouble (parser.getVersion ().substring (0, parser.getVersion ().indexOf (' '))))
! {
! getParameterTableFor("body onLoad=defaultStatus=''");
! String name = (String)table.get(Tag.TAGNAME);
! assertNotNull ("No Tag.TAGNAME", name);
! assertStringEquals("tag name parsed incorrectly", "BODY", name);
! String value = (String)table.get ("ONLOAD");
! assertStringEquals ("parameter parsed incorrectly", "defaultStatus=''", value);
! }
}
}
Index: TagParserTest.java
===================================================================
RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/parserHelperTests/TagParserTest.java,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** TagParserTest.java 5 May 2003 03:12:24 -0000 1.24
--- TagParserTest.java 11 May 2003 20:42:30 -0000 1.25
***************
*** 199,253 ****
}
! /*
! <meta name="foo" content="<foo>
! bar">
! */
public void testMultiLine5 () throws ParserException
{
createParser("<meta name=\"foo\" content=\"<foo>\nbar\">");
! parseAndAssertNodeCount (1);
! assertType ("should be Tag", Tag.class, node[0]);
! Tag tag = (Tag)node[0];
! String html = tag.toHtml ();
! assertStringEquals ("html","<META CONTENT=\"<foo>\r\nbar\" NAME=\"foo\">", html);
! String attribute1 = tag.getAttribute ("NAME");
! assertStringEquals ("attribute 1","foo", attribute1);
! String attribute2 = tag.getAttribute ("CONTENT");
! assertStringEquals ("attribute 2","<foo>\r\nbar", attribute2);
}
! /**
! * <meta name="foo" content="foo>
! * bar">
! */
! public void testMultiLine6 () throws ParserException {
createParser("<meta name=\"foo\" content=\"foo>\nbar\">");
! parseAndAssertNodeCount (1);
! assertType ("should be Tag", Tag.class, node[0]);
! Tag tag = (Tag)node[0];
! String html = tag.toHtml ();
! assertStringEquals ("html","<META CONTENT=\"foo>\r\nbar\" NAME=\"foo\">", html);
! String attribute1 = tag.getAttribute ("NAME");
! assertStringEquals ("attribute 1","foo", attribute1);
! String attribute2 = tag.getAttribute ("CONTENT");
! assertStringEquals ("attribute 2","foo>\r\nbar", attribute2);
}
! /**
! * <meta name="foo" content="<foo
! * bar">
! */
public void testMultiLine7 () throws ParserException
{
createParser("<meta name=\"foo\" content=\"<foo\nbar\"");
! parseAndAssertNodeCount (1);
! assertType ("should be Tag", Tag.class, node[0]);
! Tag tag = (Tag)node[0];
! String html = tag.toHtml ();
! assertStringEquals ("html","<META CONTENT=\"<foo\r\nbar\" NAME=\"foo\">", html);
! String attribute1 = tag.getAttribute ("NAME");
! assertStringEquals ("attribute 1","foo", attribute1);
! String attribute2 = tag.getAttribute ("CONTENT");
! assertStringEquals ("attribute 2","<foo\r\nbar", attribute2);
}
--- 199,272 ----
}
! /**
! * Test multiline tag like attribute.
! * See feature request #725749 Handle < and > in multi-line attributes.
! * Only perform this test if it's version 1.4 or higher.
! */
public void testMultiLine5 () throws ParserException
{
+ // <meta name="foo" content="<foo>
+ // bar">
createParser("<meta name=\"foo\" content=\"<foo>\nbar\">");
! if (1.4 <= Double.parseDouble (parser.getVersion ().substring (0, parser.getVersion ().indexOf (' '))))
! {
! parseAndAssertNodeCount (1);
! assertType ("should be Tag", Tag.class, node[0]);
! Tag tag = (Tag)node[0];
! String html = tag.toHtml ();
! assertStringEquals ("html","<META CONTENT=\"<foo>\r\nbar\" NAME=\"foo\">", html);
! String attribute1 = tag.getAttribute ("NAME");
! assertStringEquals ("attribute 1","foo", attribute1);
! String attribute2 = tag.getAttribute ("CONTENT");
! assertStringEquals ("attribute 2","<foo>\r\nbar", attribute2);
! }
}
! /**
! * Test multiline broken tag like attribute.
! * See feature request #725749 Handle < and > in multi-line attributes.
! * Only perform this test if it's version 1.4 or higher.
! */
! public void testMultiLine6 () throws ParserException
! {
! // <meta name="foo" content="foo>
! // bar">
createParser("<meta name=\"foo\" content=\"foo>\nbar\">");
! if (1.4 <= Double.parseDouble (parser.getVersion ().substring (0, parser.getVersion ().indexOf (' '))))
! {
! parseAndAssertNodeCount (1);
! assertType ("should be Tag", Tag.class, node[0]);
! Tag tag = (Tag)node[0];
! String html = tag.toHtml ();
! assertStringEquals ("html","<META CONTENT=\"foo>\r\nbar\" NAME=\"foo\">", html);
! String attribute1 = tag.getAttribute ("NAME");
! assertStringEquals ("attribute 1","foo", attribute1);
! String attribute2 = tag.getAttribute ("CONTENT");
! assertStringEquals ("attribute 2","foo>\r\nbar", attribute2);
! }
}
! /**
! * Test multiline split tag like attribute.
! * See feature request #725749 Handle < and > in multi-line attributes.
! * Only perform this test if it's version 1.4 or higher.
! */
public void testMultiLine7 () throws ParserException
{
+ // <meta name="foo" content="<foo
+ // bar">
createParser("<meta name=\"foo\" content=\"<foo\nbar\"");
! if (1.4 <= Double.parseDouble (parser.getVersion ().substring (0, parser.getVersion ().indexOf (' '))))
! {
! parseAndAssertNodeCount (1);
! assertType ("should be Tag", Tag.class, node[0]);
! Tag tag = (Tag)node[0];
! String html = tag.toHtml ();
! assertStringEquals ("html","<META CONTENT=\"<foo\r\nbar\" NAME=\"foo\">", html);
! String attribute1 = tag.getAttribute ("NAME");
! assertStringEquals ("attribute 1","foo", attribute1);
! String attribute2 = tag.getAttribute ("CONTENT");
! assertStringEquals ("attribute 2","<foo\r\nbar", attribute2);
! }
}
***************
*** 256,321 ****
*/
! public void testThreadSafety() throws Exception {
!
! String testHtml1 = "<a HREF=\"/cgi-bin/view_search?query_text=postdate>20020701&txt_clr=White&bg_clr=Red&url=http://localhost/Testing/Report1.html\">20020702 Report 1</A>" +
! TEST_HTML;
!
! String testHtml2 = "<a href=\"http://normallink.com/sometext.html\">" +
! TEST_HTML;
! ParsingThread parsingThread [] =
! new ParsingThread[100];
! results = new HashMap();
! testProgress = 0;
! for (int i=0;i<parsingThread.length;i++) {
! if (i<parsingThread.length/2)
! parsingThread[i] =
! new ParsingThread(i,testHtml1,parsingThread.length);
! else
! parsingThread[i] =
! new ParsingThread(i,testHtml2,parsingThread.length);
!
! Thread thread = new Thread(parsingThread[i]);
! thread.start();
! }
!
! int completionValue = computeCompletionValue(parsingThread.length);
!
! do {
! try {
! Thread.sleep(50);
! }
! catch (InterruptedException e) {
! }
! }
! while (testProgress!=completionValue);
! for (int i=0;i<parsingThread.length;i++) {
! if (!parsingThread[i].passed()) {
! assertNotNull("Thread "+i+" link 1",parsingThread[i].getLink1());
! assertNotNull("Thread "+i+" link 2",parsingThread[i].getLink2());
! if (i<parsingThread.length/2) {
! assertStringEquals(
! "Thread "+i+", link 1:",
! "/cgi-bin/view_search?query_text=postdate>20020701&txt_clr=White&bg_clr=Red&url=http://localhost/Testing/Report1.html",
! parsingThread[i].getLink1().getLink()
! );
! assertStringEquals(
! "Thread "+i+", link 2:",
! "http://normallink.com/sometext.html",
! parsingThread[i].getLink2().getLink()
! );
! } else {
! assertStringEquals(
! "Thread "+i+", link 1:",
! "http://normallink.com/sometext.html",
! parsingThread[i].getLink1().getLink()
! );
! assertNotNull("Thread "+i+" link 2",parsingThread[i].getLink2());
! assertStringEquals(
! "Thread "+i+", link 2:",
! "/cgi-bin/view_search?query_text=postdate>20020701&txt_clr=White&bg_clr=Red&url=http://localhost/Testing/Report1.html",
! parsingThread[i].getLink2().getLink()
! );
! }
! }
}
--- 275,349 ----
*/
! /**
! * Test multiple threads running against the parser.
! * See feature request #736144 Handle multi-threaded operation.
! * Only perform this test if it's version 1.4 or higher.
! */
! public void testThreadSafety() throws Exception
! {
! createParser("<html></html>");
! if (1.4 <= Double.parseDouble (parser.getVersion ().substring (0, parser.getVersion ().indexOf (' '))))
! {
! String testHtml1 = "<a HREF=\"/cgi-bin/view_search?query_text=postdate>20020701&txt_clr=White&bg_clr=Red&url=http://localhost/Testing/Report1.html\">20020702 Report 1</A>" +
! TEST_HTML;
!
! String testHtml2 = "<a href=\"http://normallink.com/sometext.html\">" +
! TEST_HTML;
! ParsingThread parsingThread [] =
! new ParsingThread[100];
! results = new HashMap();
! testProgress = 0;
! for (int i=0;i<parsingThread.length;i++) {
! if (i<parsingThread.length/2)
! parsingThread[i] =
! new ParsingThread(i,testHtml1,parsingThread.length);
! else
! parsingThread[i] =
! new ParsingThread(i,testHtml2,parsingThread.length);
!
! Thread thread = new Thread(parsingThread[i]);
! thread.start();
! }
!
! int completionValue = computeCompletionValue(parsingThread.length);
!
! do {
! try {
! Thread.sleep(50);
! }
! catch (InterruptedException e) {
! }
! }
! while (testProgress!=completionValue);
! for (int i=0;i<parsingThread.length;i++) {
! if (!parsingThread[i].passed()) {
! assertNotNull("Thread "+i+" link 1",parsingThread[i].getLink1());
! assertNotNull("Thread "+i+" link 2",parsingThread[i].getLink2());
! if (i<parsingThread.length/2) {
! assertStringEquals(
! "Thread "+i+", link 1:",
! "/cgi-bin/view_search?query_text=postdate>20020701&txt_clr=White&bg_clr=Red&url=http://localhost/Testing/Report1.html",
! parsingThread[i].getLink1().getLink()
! );
! assertStringEquals(
! "Thread "+i+", link 2:",
! "http://normallink.com/sometext.html",
! parsingThread[i].getLink2().getLink()
! );
! } else {
! assertStringEquals(
! "Thread "+i+", link 1:",
! "http://normallink.com/sometext.html",
! parsingThread[i].getLink1().getLink()
! );
! assertNotNull("Thread "+i+" link 2",parsingThread[i].getLink2());
! assertStringEquals(
! "Thread "+i+", link 2:",
! "/cgi-bin/view_search?query_text=postdate>20020701&txt_clr=White&bg_clr=Red&url=http://localhost/Testing/Report1.html",
! parsingThread[i].getLink2().getLink()
! );
! }
! }
! }
}
|