1 19 20 33 package org.htmlparser.tests.scannersTests; 34 35 import org.htmlparser.Node; 36 import org.htmlparser.StringNode; 37 import org.htmlparser.tags.Bullet; 38 import org.htmlparser.tags.BulletList; 39 import org.htmlparser.tags.CompositeTag; 40 import org.htmlparser.tests.ParserTestCase; 41 import org.htmlparser.util.NodeList; 42 import org.htmlparser.util.ParserException; 43 44 50 public class BulletListScannerTest extends ParserTestCase 51 { 52 53 public BulletListScannerTest(String name) 54 { 55 super(name); 56 } 57 58 public void testScan() throws ParserException 59 { 60 createParser( 61 "<ul TYPE=DISC>" 62 + "<ul TYPE=\"DISC\"><li>Energy supply\n" 63 + " (Campbell) <A HREF=\"/hansard/37th3rd/h20307p.htm#1646\">1646</A>\n" 64 + " (MacPhail) <A HREF=\"/hansard/37th3rd/h20307p.htm#1646\">1646</A>\n" 65 + "</ul><A NAME=\"calpinecorp\"></A><B>Calpine Corp.</B>\n" 66 + "<ul TYPE=\"DISC\"><li>Power plant projects\n" 67 + " (Neufeld) <A HREF=\"/hansard/37th3rd/h20314p.htm#1985\">1985</A>\n" 68 + "</ul>" 69 + "</ul>"); 70 parser.registerScanners(); 71 parseAndAssertNodeCount(1); 72 73 NodeList nestedBulletLists = 74 ((CompositeTag) node[0]).searchFor(BulletList.class); 75 assertEquals("bullets in first list", 2, nestedBulletLists.size()); 76 BulletList firstList = (BulletList) nestedBulletLists.elementAt(0); 77 Bullet firstBullet = (Bullet) firstList.childAt(0); 78 Node firstNodeInFirstBullet = firstBullet.childAt(0); 79 assertType( 80 "first child in bullet", 81 StringNode.class, 82 firstNodeInFirstBullet); 83 assertStringEquals( 84 "expected text", 85 "Energy supply\r\n" + " (Campbell) ", 86 firstNodeInFirstBullet.toPlainTextString()); 87 } 88 } 89 | Popular Tags |