[Htmlparser-cvs] htmlparser/src/org/htmlparser/tests/parserHelperTests RemarkNodeParserTest.java,1.4
Brought to you by:
derrickoswald
From: Derrick O. <der...@us...> - 2004-05-24 16:19:16
|
Update of /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/parserHelperTests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19028/src/org/htmlparser/tests/parserHelperTests Modified Files: RemarkNodeParserTest.java StringParserTest.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: RemarkNodeParserTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/parserHelperTests/RemarkNodeParserTest.java,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** RemarkNodeParserTest.java 2 Jan 2004 16:24:56 -0000 1.44 --- RemarkNodeParserTest.java 24 May 2004 16:18:32 -0000 1.45 *************** *** 29,34 **** import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.RemarkNode; ! import org.htmlparser.StringNode; import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; --- 29,34 ---- import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.Remark; ! import org.htmlparser.Text; import org.htmlparser.tags.Tag; import org.htmlparser.tests.ParserTestCase; *************** *** 39,46 **** static { ! System.setProperty ("org.htmlparser.tests.parserHelperTests.RemarkNodeParserTest", "RemarkNodeParserTest"); } ! public RemarkNodeParserTest(String name) { super(name); } --- 39,46 ---- static { ! System.setProperty ("org.htmlparser.tests.parserHelperTests.RemarkParserTest", "RemarkParserTest"); } ! public RemarkNodeParserTest (String name) { super(name); } *************** *** 61,65 **** * This bug was reported by Serge Kruppa (2002-Feb-08). */ ! public void testRemarkNodeBug() throws ParserException { createParser( --- 61,65 ---- * This bug was reported by Serge Kruppa (2002-Feb-08). */ ! public void testRemarkBug() throws ParserException { createParser( *************** *** 76,87 **** Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(15); ! // The first node should be a HTMLRemarkNode ! assertTrue("First node should be a RemarkNode",node[0] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[0]; ! assertEquals("Text of the remarkNode #1"," saved from url=(0022)http://internet.e-mail ",remarkNode.getText()); ! // The tenth node should be a HTMLRemarkNode ! assertTrue("Tenth node should be a RemarkNode",node[9] instanceof RemarkNode); ! remarkNode = (RemarkNode)node[9]; ! assertEquals("Text of the remarkNode #10","\n Whats gonna happen now ?\n",remarkNode.getText()); } --- 76,87 ---- Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(15); ! // The first node should be a Remark ! assertTrue("First node should be a Remark",node[0] instanceof Remark); ! Remark Remark = (Remark)node[0]; ! assertEquals("Text of the Remark #1"," saved from url=(0022)http://internet.e-mail ",Remark.getText()); ! // The tenth node should be a Remark ! assertTrue("Tenth node should be a Remark",node[9] instanceof Remark); ! Remark = (Remark)node[9]; ! assertEquals("Text of the Remark #10","\n Whats gonna happen now ?\n",Remark.getText()); } *************** *** 100,111 **** Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(15); ! // The first node should be a HTMLRemarkNode ! assertTrue("First node should be a RemarkNode",node[0] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[0]; ! assertEquals("Plain Text of the remarkNode #1"," saved from url=(0022)http://internet.e-mail ",remarkNode.toPlainTextString()); ! // The tenth node should be a HTMLRemarkNode ! assertTrue("Tenth node should be a RemarkNode",node[9] instanceof RemarkNode); ! remarkNode = (RemarkNode)node[9]; ! assertEquals("Plain Text of the remarkNode #10","\n Whats gonna happen now ?\n",remarkNode.getText()); } --- 100,111 ---- Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(15); ! // The first node should be a Remark ! assertTrue("First node should be a Remark",node[0] instanceof Remark); ! Remark Remark = (Remark)node[0]; ! assertEquals("Plain Text of the Remark #1"," saved from url=(0022)http://internet.e-mail ",Remark.toPlainTextString()); ! // The tenth node should be a Remark ! assertTrue("Tenth node should be a Remark",node[9] instanceof Remark); ! Remark = (Remark)node[9]; ! assertEquals("Plain Text of the Remark #10","\n Whats gonna happen now ?\n",Remark.getText()); } *************** *** 125,145 **** Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(15); ! // The first node should be a HTMLRemarkNode ! assertTrue("First node should be a RemarkNode",node[0] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[0]; ! assertStringEquals("Raw String of the remarkNode #1","<!-- saved from url=(0022)http://internet.e-mail -->",remarkNode.toHtml()); ! // The tenth node should be a HTMLRemarkNode ! assertTrue("Tenth node should be a RemarkNode",node[9] instanceof RemarkNode); ! remarkNode = (RemarkNode)node[9]; ! assertStringEquals("Raw String of the remarkNode #6","<!--\n Whats gonna happen now ?\n-->",remarkNode.toHtml()); } ! public void testNonRemarkNode() throws ParserException { createParser(" <![endif]>"); parseAndAssertNodeCount(2); ! // The first node should be a HTMLRemarkNode ! assertTrue("First node should be a string node",node[0] instanceof StringNode); assertTrue("Second node should be a Tag",node[1] instanceof Tag); ! StringNode stringNode = (StringNode)node[0]; Tag tag = (Tag)node[1]; assertEquals("Text contents"," ",stringNode.getText()); --- 125,145 ---- Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(15); ! // The first node should be a Remark ! assertTrue("First node should be a Remark",node[0] instanceof Remark); ! Remark Remark = (Remark)node[0]; ! assertStringEquals("Raw String of the Remark #1","<!-- saved from url=(0022)http://internet.e-mail -->",Remark.toHtml()); ! // The tenth node should be a Remark ! assertTrue("Tenth node should be a Remark",node[9] instanceof Remark); ! Remark = (Remark)node[9]; ! assertStringEquals("Raw String of the Remark #6","<!--\n Whats gonna happen now ?\n-->",Remark.toHtml()); } ! public void testNonRemark() throws ParserException { createParser(" <![endif]>"); parseAndAssertNodeCount(2); ! // The first node should be a Remark ! assertTrue("First node should be a string node",node[0] instanceof Text); assertTrue("Second node should be a Tag",node[1] instanceof Tag); ! Text stringNode = (Text)node[0]; Tag tag = (Tag)node[1]; assertEquals("Text contents"," ",stringNode.getText()); *************** *** 154,158 **** * the state */ ! public void testRemarkNodeWithBlankLine() throws ParserException { createParser("<!--\n"+ "\n"+ --- 154,158 ---- * the state */ ! public void testRemarkWithBlankLine() throws ParserException { createParser("<!--\n"+ "\n"+ *************** *** 161,167 **** Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(1); ! assertTrue("Node should be a HTMLRemarkNode",node[0] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[0]; ! assertEquals("Expected contents","\n\n",remarkNode.getText()); } --- 161,167 ---- Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(1); ! assertTrue("Node should be a Remark",node[0] instanceof Remark); ! Remark Remark = (Remark)node[0]; ! assertEquals("Expected contents","\n\n",Remark.getText()); } *************** *** 172,182 **** * If it is a comment with nothing in it, parser crashes */ ! public void testRemarkNodeWithNothing() throws ParserException { createParser("<!-->"); parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("Node should be a RemarkNode",node[0] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[0]; ! assertEquals("Expected contents","",remarkNode.getText()); } --- 172,182 ---- * If it is a comment with nothing in it, parser crashes */ ! public void testRemarkWithNothing() throws ParserException { createParser("<!-->"); parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("Node should be a Remark",node[0] instanceof Remark); ! Remark Remark = (Remark)node[0]; ! assertEquals("Expected contents","",Remark.getText()); } *************** *** 188,192 **** * it doesent get parsed correctly */ ! public void testTagWithinRemarkNode() throws ParserException { createParser("<!-- \n"+ "<A>\n"+ --- 188,192 ---- * it doesent get parsed correctly */ ! public void testTagWithinRemark() throws ParserException { createParser("<!-- \n"+ "<A>\n"+ *************** *** 195,201 **** Parser.setLineSeparator("\n"); parseAndAssertNodeCount(1); ! assertTrue("Node should be a HTMLRemarkNode",node[0] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[0]; ! assertStringEquals("Expected contents"," \n<A>\nbcd ",remarkNode.getText()); } --- 195,201 ---- Parser.setLineSeparator("\n"); parseAndAssertNodeCount(1); ! assertTrue("Node should be a Remark",node[0] instanceof Remark); ! Remark Remark = (Remark)node[0]; ! assertStringEquals("Expected contents"," \n<A>\nbcd ",Remark.getText()); } *************** *** 207,211 **** * -<br> * ssd --><br> ! * This is not supposed to be a remarknode */ public void testInvalidTag() throws ParserException { --- 207,211 ---- * -<br> * ssd --><br> ! * This is not supposed to be a Remark */ public void testInvalidTag() throws ParserException { *************** *** 234,240 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("Node should be a HTMLRemarkNode but was "+node[0],node[0] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[0]; ! assertEquals("Remark Node contents"," -- ",remarkNode.getText()); } --- 234,240 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("Node should be a Remark but was "+node[0],node[0] instanceof Remark); ! Remark Remark = (Remark)node[0]; ! assertEquals("Remark Node contents"," -- ",Remark.getText()); } *************** *** 281,287 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(18); ! assertTrue("Node should be a RemarkNode but was "+node[12],node[12] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[12]; ! assertEquals("Remark Node contents"," Id: html-sgml.sgm,v 1.5 1995/05/26 21:29:50 connolly Exp ",remarkNode.getText()); } --- 281,287 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(18); ! assertTrue("Node should be a Remark but was "+node[12],node[12] instanceof Remark); ! Remark Remark = (Remark)node[12]; ! assertEquals("Remark Node contents"," Id: html-sgml.sgm,v 1.5 1995/05/26 21:29:50 connolly Exp ",Remark.getText()); } *************** *** 305,311 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(18); ! assertTrue("Node should be a RemarkNode but was "+node[12],node[12] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[12]; ! assertEquals("Remark Node contents"," another -- -- comment ",remarkNode.getText()); } --- 305,311 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(18); ! assertTrue("Node should be a Remark but was "+node[12],node[12] instanceof Remark); ! Remark Remark = (Remark)node[12]; ! assertEquals("Remark Node contents"," another -- -- comment ",Remark.getText()); } *************** *** 329,335 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(18); ! assertTrue("Node should be a RemarkNode but was "+node[12],node[12] instanceof RemarkNode); ! RemarkNode remarkNode = (RemarkNode)node[12]; ! assertEquals("Remark Node contents","",remarkNode.getText()); } --- 329,335 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(18); ! assertTrue("Node should be a Remark but was "+node[12],node[12] instanceof Remark); ! Remark Remark = (Remark)node[12]; ! assertEquals("Remark Node contents","",Remark.getText()); } *************** *** 355,361 **** // ); // parseAndAssertNodeCount(10); ! // assertTrue("Node should not be a HTMLRemarkNode",!(node[7] instanceof HTMLRemarkNode)); ! // assertTrue("Node should be a HTMLStringNode but was "+node[7],node[7].getType()==HTMLStringNode.TYPE); ! // HTMLStringNode stringNode = (HTMLStringNode)node[7]; // assertEquals("String Node contents","<!- not a comment, just regular old data characters ->\n",stringNode.getText()); // } --- 355,361 ---- // ); // parseAndAssertNodeCount(10); ! // assertTrue("Node should not be a Remark",!(node[7] instanceof Remark)); ! // assertTrue("Node should be a HTMLText but was "+node[7],node[7].getType()==HTMLText.TYPE); ! // HTMLText stringNode = (HTMLText)node[7]; // assertEquals("String Node contents","<!- not a comment, just regular old data characters ->\n",stringNode.getText()); // } *************** *** 381,385 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount (18); ! assertTrue("Node should be a RemarkNode but was " + node[12], node[12] instanceof RemarkNode); assertStringEquals ("remark text", "<!-- foobar --!>", node[12].toHtml ()); } --- 381,385 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount (18); ! assertTrue("Node should be a Remark but was " + node[12], node[12] instanceof Remark); assertStringEquals ("remark text", "<!-- foobar --!>", node[12].toHtml ()); } Index: StringParserTest.java =================================================================== RCS file: /cvsroot/htmlparser/htmlparser/src/org/htmlparser/tests/parserHelperTests/StringParserTest.java,v retrieving revision 1.47 retrieving revision 1.48 diff -C2 -d -r1.47 -r1.48 *** StringParserTest.java 22 May 2004 03:57:30 -0000 1.47 --- StringParserTest.java 24 May 2004 16:18:32 -0000 1.48 *************** *** 29,34 **** import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.RemarkNode; ! import org.htmlparser.StringNode; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; --- 29,34 ---- import org.htmlparser.Parser; import org.htmlparser.PrototypicalNodeFactory; ! import org.htmlparser.Remark; ! import org.htmlparser.Text; import org.htmlparser.tags.HeadTag; import org.htmlparser.tags.Html; *************** *** 57,68 **** * Creation date: (6/17/2001 4:01:06 PM) */ ! public void testStringNodeBug1() throws ParserException { createParser("<HTML><HEAD><TITLE>Google</TITLE>"); parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(5); ! // The fourth node should be a StringNode- with the text - Google ! assertTrue("Fourth node should be a StringNode",node[3] instanceof StringNode); ! StringNode stringNode = (StringNode)node[3]; ! assertEquals("Text of the StringNode","Google",stringNode.getText()); } --- 57,68 ---- * Creation date: (6/17/2001 4:01:06 PM) */ ! public void testTextBug1() throws ParserException { createParser("<HTML><HEAD><TITLE>Google</TITLE>"); parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(5); ! // The fourth node should be a Text- with the text - Google ! assertTrue("Fourth node should be a Text",node[3] instanceof Text); ! Text stringNode = (Text)node[3]; ! assertEquals("Text of the Text","Google",stringNode.getText()); } *************** *** 75,79 **** * Creation date: (8/2/2001 2:07:32 AM) */ ! public void testStringNodeBug2() throws ParserException { // Register the link scanner --- 75,79 ---- * Creation date: (8/2/2001 2:07:32 AM) */ ! public void testTextBug2() throws ParserException { // Register the link scanner *************** *** 82,89 **** Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(3); ! // The first node should be a StringNode- with the text - view these documents, you must have ! assertTrue("First node should be a StringNode",node[0] instanceof StringNode); ! StringNode stringNode = (StringNode)node[0]; ! assertEquals("Text of the StringNode","view these documents, you must have ",stringNode.getText()); assertTrue("Second node should be a link node",node[1] instanceof LinkTag); LinkTag linkNode = (LinkTag)node[1]; --- 82,89 ---- Parser.setLineSeparator("\r\n"); parseAndAssertNodeCount(3); ! // The first node should be a Text- with the text - view these documents, you must have ! assertTrue("First node should be a Text",node[0] instanceof Text); ! Text stringNode = (Text)node[0]; ! assertEquals("Text of the Text","view these documents, you must have ",stringNode.getText()); assertTrue("Second node should be a link node",node[1] instanceof LinkTag); LinkTag linkNode = (LinkTag)node[1]; *************** *** 91,96 **** assertEquals("Link text is","Adobe \nAcrobat Reader",linkNode.getLinkText()); ! assertTrue("Third node should be a string node",node[2] instanceof StringNode); ! StringNode stringNode2 = (StringNode)node[2]; assertEquals("Contents of third node"," installed on your computer.",stringNode2.getText()); } --- 91,96 ---- assertEquals("Link text is","Adobe \nAcrobat Reader",linkNode.getLinkText()); ! assertTrue("Third node should be a string node",node[2] instanceof Text); ! Text stringNode2 = (Text)node[2]; assertEquals("Contents of third node"," installed on your computer.",stringNode2.getText()); } *************** *** 102,106 **** * The string node is not correctly identified */ ! public void testTagCharsInStringNode() throws ParserException { createParser("<a href=\"http://asgard.ch\">[> ASGARD <]</a>"); parseAndAssertNodeCount(1); --- 102,106 ---- * The string node is not correctly identified */ ! public void testTagCharsInText() throws ParserException { createParser("<a href=\"http://asgard.ch\">[> ASGARD <]</a>"); parseAndAssertNodeCount(1); *************** *** 115,123 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(10); ! assertTrue("Fourth Node identified must be a string node",node[3] instanceof StringNode); ! StringNode stringNode = (StringNode)node[3]; assertEquals("First String Node","This is the Title",stringNode.toPlainTextString()); ! assertTrue("Eighth Node identified must be a string node",node[7] instanceof StringNode); ! stringNode = (StringNode)node[7]; assertEquals("Second string node","Hello World, this is the HTML Parser",stringNode.toPlainTextString()); } --- 115,123 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(10); ! assertTrue("Fourth Node identified must be a string node",node[3] instanceof Text); ! Text stringNode = (Text)node[3]; assertEquals("First String Node","This is the Title",stringNode.toPlainTextString()); ! assertTrue("Eighth Node identified must be a string node",node[7] instanceof Text); ! stringNode = (Text)node[7]; assertEquals("Second string node","Hello World, this is the HTML Parser",stringNode.toPlainTextString()); } *************** *** 127,135 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(10); ! assertTrue("Fourth Node identified must be a string node",node[3] instanceof StringNode); ! StringNode stringNode = (StringNode)node[3]; assertEquals("First String Node","This is the Title",stringNode.toHtml()); ! assertTrue("Eighth Node identified must be a string node",node[7] instanceof StringNode); ! stringNode = (StringNode)node[7]; assertEquals("Second string node","Hello World, this is the HTML Parser",stringNode.toHtml()); } --- 127,135 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(10); ! assertTrue("Fourth Node identified must be a string node",node[3] instanceof Text); ! Text stringNode = (Text)node[3]; assertEquals("First String Node","This is the Title",stringNode.toHtml()); ! assertTrue("Eighth Node identified must be a string node",node[7] instanceof Text); ! stringNode = (Text)node[7]; assertEquals("Second string node","Hello World, this is the HTML Parser",stringNode.toHtml()); } *************** *** 143,147 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(4); ! assertTrue("Third Node identified must be a string node",node[2] instanceof StringNode); } --- 143,147 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(4); ! assertTrue("Third Node identified must be a string node",node[2] instanceof Text); } *************** *** 156,167 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(3); ! assertTrue("First node should be StringNode",node[0] instanceof StringNode); ! assertTrue("Second node should be RemarkNode",node[1] instanceof RemarkNode); ! assertTrue("Third node should be StringNode",node[2] instanceof StringNode); ! StringNode stringNode = (StringNode)node[0]; assertEquals("First String node contents","Before Comment ",stringNode.getText()); ! StringNode stringNode2 = (StringNode)node[2]; assertEquals("Second String node contents"," After Comment",stringNode2.getText()); ! RemarkNode remarkNode = (RemarkNode)node[1]; assertEquals("Remark Node contents"," Comment ",remarkNode.getText()); --- 156,167 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(3); ! assertTrue("First node should be Text",node[0] instanceof Text); ! assertTrue("Second node should be Remark",node[1] instanceof Remark); ! assertTrue("Third node should be Text",node[2] instanceof Text); ! Text stringNode = (Text)node[0]; assertEquals("First String node contents","Before Comment ",stringNode.getText()); ! Text stringNode2 = (Text)node[2]; assertEquals("Second String node contents"," After Comment",stringNode2.getText()); ! Remark remarkNode = (Remark)node[1]; assertEquals("Remark Node contents"," Comment ",remarkNode.getText()); *************** *** 170,174 **** /** * Based on a bug report submitted by Cedric Rosa, if the last line contains a single character, ! * StringNode does not return the string node correctly. */ public void testLastLineWithOneChar() throws ParserException { --- 170,174 ---- /** * Based on a bug report submitted by Cedric Rosa, if the last line contains a single character, ! * Text does not return the string node correctly. */ public void testLastLineWithOneChar() throws ParserException { *************** *** 176,181 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("First node should be StringNode",node[0] instanceof StringNode); ! StringNode stringNode = (StringNode)node[0]; assertEquals("First String node contents","a",stringNode.getText()); } --- 176,181 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("First node should be Text",node[0] instanceof Text); ! Text stringNode = (Text)node[0]; assertEquals("First String node contents","a",stringNode.getText()); } *************** *** 186,191 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("First node should be StringNode",node[0] instanceof StringNode); ! StringNode stringNode = (StringNode)node[0]; assertStringEquals("First String node contents",text,stringNode.getText()); } --- 186,191 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertTrue("First node should be Text",node[0] instanceof Text); ! Text stringNode = (Text)node[0]; assertStringEquals("First String node contents",text,stringNode.getText()); } *************** *** 238,243 **** parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertType("first node",StringNode.class,node[0]); ! StringNode stringNode = (StringNode)node[0]; assertStringEquals("text",text,stringNode.toPlainTextString()); } --- 238,243 ---- parser.setNodeFactory (new PrototypicalNodeFactory (true)); parseAndAssertNodeCount(1); ! assertType("first node",Text.class,node[0]); ! Text stringNode = (Text)node[0]; assertStringEquals("text",text,stringNode.toPlainTextString()); } |