1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.util; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
|
25 |
|
import jalview.gui.JvOptionPane; |
26 |
|
|
27 |
|
import org.testng.annotations.BeforeClass; |
28 |
|
import org.testng.annotations.Test; |
29 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 5 |
Complexity Density: 0.21 |
|
30 |
|
public class ParseHtmlBodyAndLinksTest |
31 |
|
{ |
32 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
33 |
1 |
@BeforeClass(alwaysRun = true)... |
34 |
|
public void setUpJvOptionPane() |
35 |
|
{ |
36 |
1 |
JvOptionPane.setInteractiveMode(false); |
37 |
1 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
38 |
|
} |
39 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
40 |
1 |
@Test(groups = { "Functional" })... |
41 |
|
public void testParseHtml_noLinks() |
42 |
|
{ |
43 |
1 |
ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks( |
44 |
|
"<html>something here</html>", false, "\n"); |
45 |
1 |
assertEquals("something here", testee.getContent()); |
46 |
1 |
assertEquals("something here", testee.getNonHtmlContent()); |
47 |
|
|
48 |
|
|
49 |
1 |
testee = new ParseHtmlBodyAndLinks("<html>something here</html>", true, |
50 |
|
"\n"); |
51 |
1 |
assertEquals("something here", testee.getContent()); |
52 |
1 |
assertEquals("something here", testee.getNonHtmlContent()); |
53 |
|
} |
54 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
1PASS
|
|
55 |
1 |
@Test(groups = { "Functional" })... |
56 |
|
public void testParseHtml_withLinks() |
57 |
|
{ |
58 |
1 |
ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks( |
59 |
|
"<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>", |
60 |
|
false, "\n"); |
61 |
1 |
assertEquals( |
62 |
|
"Please click on this%LINK% to learn more about this%LINK%", |
63 |
|
testee.getContent()); |
64 |
1 |
assertEquals( |
65 |
|
"Please click on this%LINK% to learn more about this%LINK%", |
66 |
|
testee.getNonHtmlContent()); |
67 |
1 |
assertEquals(2, testee.getLinks().size()); |
68 |
1 |
assertEquals("on this|http://www.nowhere.com", |
69 |
|
testee.getLinks().get(0)); |
70 |
1 |
assertEquals("this|http://www.somewhere.com/here", |
71 |
|
testee.getLinks().get(1)); |
72 |
|
} |
73 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
74 |
1 |
@Test(groups = { "Functional" })... |
75 |
|
public void testParseHtml_withLinksWithParameters() |
76 |
|
{ |
77 |
1 |
ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks( |
78 |
|
"<html>Please click <a href=\"http://www.nowhere.com?id=234&taxon=human\">on this</a> to learn more</html>", |
79 |
|
false, "\n"); |
80 |
1 |
assertEquals("Please click on this%LINK% to learn more", |
81 |
|
testee.getContent()); |
82 |
1 |
assertEquals("Please click on this%LINK% to learn more", |
83 |
|
testee.getNonHtmlContent()); |
84 |
1 |
assertEquals(1, testee.getLinks().size()); |
85 |
1 |
assertEquals("on this|http://www.nowhere.com?id=234&taxon=human", |
86 |
|
testee.getLinks().get(0)); |
87 |
|
} |
88 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
1PASS
|
|
89 |
1 |
@Test(groups = { "Functional" })... |
90 |
|
public void testParseHtml_withLinksWithEncoding() |
91 |
|
{ |
92 |
1 |
ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks( |
93 |
|
"<html>Please click <a href=\"http://www.nowhere.com?id=234&taxon=human&id>3&id<10\">on this</a> to learn &<>more</html>", |
94 |
|
false, "\n"); |
95 |
|
|
96 |
1 |
assertEquals("Please click on this%LINK% to learn &<>more", |
97 |
|
testee.getContent()); |
98 |
1 |
assertEquals("Please click on this%LINK% to learn &<>more", |
99 |
|
testee.getNonHtmlContent()); |
100 |
1 |
assertEquals(1, testee.getLinks().size()); |
101 |
|
|
102 |
1 |
assertEquals( |
103 |
|
"on this|http://www.nowhere.com?id=234&taxon=human&id>3&id<10", |
104 |
|
testee.getLinks().get(0)); |
105 |
|
} |
106 |
|
} |