1 27 package org.htmlparser.tests.visitorsTests; 28 29 import org.htmlparser.tests.ParserTestCase; 30 import org.htmlparser.visitors.LinkFindingVisitor; 31 32 public class LinkFindingVisitorTest extends ParserTestCase { 33 34 static 35 { 36 System.setProperty ("org.htmlparser.tests.visitorsTests.LinkFindingVisitorTest", "LinkFindingVisitorTest"); 37 } 38 39 private String html = 40 "<HTML><HEAD><TITLE>This is the Title</TITLE></HEAD><BODY>Hello World, <A HREF=\"http://www.industriallogic.com\">Industrial Logic</a></BODY></HTML>"; 41 42 public LinkFindingVisitorTest(String name) { 43 super(name); 44 } 45 46 public void testLinkFoundCorrectly() throws Exception { 47 createParser(html); 48 LinkFindingVisitor visitor = new LinkFindingVisitor("Industrial Logic"); 49 parser.visitAllNodesWith(visitor); 50 assertTrue("Found Industrial Logic Link",visitor.linkTextFound()); 51 assertEquals("Link Count",1,visitor.getCount()); 52 } 53 54 } 55 | Popular Tags |