1 27 package org.htmlparser.tests.tagTests; 28 29 import org.htmlparser.Node; 30 import org.htmlparser.PrototypicalNodeFactory; 31 import org.htmlparser.Tag; 32 import org.htmlparser.tags.Span; 33 import org.htmlparser.tags.TableColumn; 34 import org.htmlparser.tests.ParserTestCase; 35 36 public class SpanTagTest extends ParserTestCase 37 { 38 static 39 { 40 System.setProperty ("org.htmlparser.tests.tagTests.SpanTagTest", "SpanTagTest"); 41 } 42 43 private static final String HTML_WITH_SPAN = 44 "<TD BORDER=\"0.0\" VALIGN=\"Top\" COLSPAN=\"4\" WIDTH=\"33.33%\">" + 45 " <DIV>" + 46 " <SPAN>Flavor: small(90 to 120 minutes)<BR /></SPAN>" + 47 " <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>" + 48 " </DIV>" + 49 "</TD>"; 50 51 public SpanTagTest (String name) 52 { 53 super(name); 54 } 55 56 public void testScan() throws Exception { 57 createParser( 58 HTML_WITH_SPAN 59 ); 60 parser.setNodeFactory ( 61 new PrototypicalNodeFactory ( 62 new Tag[] { 63 new TableColumn (), 64 new Span (), 65 })); 66 parseAndAssertNodeCount(1); 67 assertType("node",TableColumn.class,node[0]); 68 TableColumn col = (TableColumn)node[0]; 69 Node spans [] = col.searchFor(Span.class, true).toNodeArray(); 70 assertEquals("number of spans found",2,spans.length); 71 assertStringEquals( 72 "span 1", 73 "Flavor: small(90 to 120 minutes)", 74 spans[0].toPlainTextString() 75 ); 76 assertStringEquals( 77 "span 2", 78 "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.
", 79 spans[1].toPlainTextString() 80 ); 81 82 } 83 } 84
| Popular Tags
|