1 19 20 33 package org.htmlparser.tests.scannersTests; 34 35 36 import org.htmlparser.Node; 37 import org.htmlparser.scanners.SpanScanner; 38 import org.htmlparser.scanners.TableScanner; 39 import org.htmlparser.tags.Span; 40 import org.htmlparser.tags.TableColumn; 41 import org.htmlparser.tests.ParserTestCase; 42 43 public class SpanScannerTest extends ParserTestCase 44 { 45 46 private static final String HTML_WITH_SPAN = 47 "<TD BORDER=\"0.0\" VALIGN=\"Top\" COLSPAN=\"4\" WIDTH=\"33.33%\">" 48 + " <DIV>" 49 + " <SPAN>Flavor: small(90 to 120 minutes)<BR /></SPAN>" 50 + " <SPAN>The short version of our Refactoring Challenge gives participants a general feel for the smells in the code base and includes time for participants to find and implement important refactorings.
<BR /></SPAN>" 51 + " </DIV>" 52 + "</TD>"; 53 54 public SpanScannerTest(String name) 55 { 56 super(name); 57 } 58 59 public void testScan() throws Exception 60 { 61 createParser(HTML_WITH_SPAN); 62 parser.addScanner(new TableScanner(parser)); 63 parser.addScanner(new SpanScanner()); 64 parseAndAssertNodeCount(1); 65 assertType("node", TableColumn.class, node[0]); 66 TableColumn col = (TableColumn) node[0]; 67 Node spans[] = col.searchFor(Span.class).toNodeArray(); 68 assertEquals("number of spans found", 2, spans.length); 69 assertStringEquals( 70 "span 1", 71 "Flavor: small(90 to 120 minutes)", 72 spans[0].toPlainTextString()); 73 assertStringEquals( 74 "span 2", 75 "The short version of our Refactoring Challenge gives participants a general feel for the smells in the code base and includes time for participants to find and implement important refactorings.
", 76 spans[1].toPlainTextString()); 77 78 } 79 } 80 | Popular Tags |