3 import static org.testng.AssertJUnit.assertEquals;
5 import org.testng.annotations.Test;
7 public class ParseHtmlBodyAndLinksTest
9 @Test(groups = { "Functional" })
10 public void testParseHtml_noLinks()
12 ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks(
13 "<html>something here</html>", false, "\n");
14 assertEquals("something here", testee.getContent());
15 assertEquals("something here", testee.getNonHtmlContent());
17 // second argument makes no difference??
18 testee = new ParseHtmlBodyAndLinks("<html>something here</html>", true,
20 assertEquals("something here", testee.getContent());
21 assertEquals("something here", testee.getNonHtmlContent());
24 @Test(groups = { "Functional" })
25 public void testParseHtml_withLinks()
27 ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks(
28 "<html>Please click <a href=\"http://www.nowhere.com\">on this</a> to learn more about <a href=\"http://www.somewhere.com/here\">this</a></html>",
31 "Please click on this%LINK% to learn more about this%LINK%",
34 "Please click on this%LINK% to learn more about this%LINK%",
35 testee.getNonHtmlContent());
36 assertEquals(2, testee.getLinks().size());
37 assertEquals("on this|http://www.nowhere.com", testee.getLinks().get(0));
38 assertEquals("this|http://www.somewhere.com/here", testee.getLinks()
42 @Test(groups = { "Functional" })
43 public void testParseHtml_withLinksWithParameters()
45 ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks(
46 "<html>Please click <a href=\"http://www.nowhere.com?id=234&taxon=human\">on this</a> to learn more</html>",
48 assertEquals("Please click on this%LINK% to learn more",
50 assertEquals("Please click on this%LINK% to learn more",
51 testee.getNonHtmlContent());
52 assertEquals(1, testee.getLinks().size());
53 assertEquals("on this|http://www.nowhere.com?id=234&taxon=human",
54 testee.getLinks().get(0));
57 @Test(groups = { "Functional" })
58 public void testParseHtml_withLinksWithEncoding()
60 ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks(
61 "<html>Please click <a href=\"http://www.nowhere.com?id=234&taxon=human&id>3&id<10\">on this</a> to learn &<>more</html>",
63 // html encoding in the text body is translated
64 assertEquals("Please click on this%LINK% to learn &<>more",
66 assertEquals("Please click on this%LINK% to learn &<>more",
67 testee.getNonHtmlContent());
68 assertEquals(1, testee.getLinks().size());
69 // html encoding in the url links is not translated
71 "on this|http://www.nowhere.com?id=234&taxon=human&id>3&id<10",
72 testee.getLinks().get(0));