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 |
|
|
|
|
| 0% |
Uncovered Elements: 29 (29) |
Complexity: 5 |
Complexity Density: 0.21 |
|
30 |
|
public class ParseHtmlBodyAndLinksTest |
31 |
|
{ |
32 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
33 |
0 |
@BeforeClass(alwaysRun = true)... |
34 |
|
public void setUpJvOptionPane() |
35 |
|
{ |
36 |
0 |
JvOptionPane.setInteractiveMode(false); |
37 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
38 |
|
} |
39 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4-
|
|
40 |
0 |
@Test(groups = { "Functional" })... |
41 |
|
public void testParseHtml_noLinks() |
42 |
|
{ |
43 |
0 |
ParseHtmlBodyAndLinks testee = new ParseHtmlBodyAndLinks( |
44 |
|
"<html>something here</html>", false, "\n"); |
45 |
0 |
assertEquals("something here", testee.getContent()); |
46 |
0 |
assertEquals("something here", testee.getNonHtmlContent()); |
47 |
|
|
48 |
|
|
49 |
0 |
testee = new ParseHtmlBodyAndLinks("<html>something here</html>", true, |
50 |
|
"\n"); |
51 |
0 |
assertEquals("something here", testee.getContent()); |
52 |
0 |
assertEquals("something here", testee.getNonHtmlContent()); |
53 |
|
} |
54 |
|
|
|
|
| 0% |
Uncovered Elements: 6 (6) |
Complexity: 1 |
Complexity Density: 0.17 |
4-
|
|
55 |
0 |
@Test(groups = { "Functional" })... |
56 |
|
public void testParseHtml_withLinks() |
57 |
|
{ |
58 |
0 |
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 |
0 |
assertEquals( |
62 |
|
"Please click on this%LINK% to learn more about this%LINK%", |
63 |
|
testee.getContent()); |
64 |
0 |
assertEquals( |
65 |
|
"Please click on this%LINK% to learn more about this%LINK%", |
66 |
|
testee.getNonHtmlContent()); |
67 |
0 |
assertEquals(2, testee.getLinks().size()); |
68 |
0 |
assertEquals("on this|http://www.nowhere.com", |
69 |
|
testee.getLinks().get(0)); |
70 |
0 |
assertEquals("this|http://www.somewhere.com/here", |
71 |
|
testee.getLinks().get(1)); |
72 |
|
} |
73 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
4-
|
|
74 |
0 |
@Test(groups = { "Functional" })... |
75 |
|
public void testParseHtml_withLinksWithParameters() |
76 |
|
{ |
77 |
0 |
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 |
0 |
assertEquals("Please click on this%LINK% to learn more", |
81 |
|
testee.getContent()); |
82 |
0 |
assertEquals("Please click on this%LINK% to learn more", |
83 |
|
testee.getNonHtmlContent()); |
84 |
0 |
assertEquals(1, testee.getLinks().size()); |
85 |
0 |
assertEquals("on this|http://www.nowhere.com?id=234&taxon=human", |
86 |
|
testee.getLinks().get(0)); |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
4-
|
|
89 |
0 |
@Test(groups = { "Functional" })... |
90 |
|
public void testParseHtml_withLinksWithEncoding() |
91 |
|
{ |
92 |
0 |
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 |
0 |
assertEquals("Please click on this%LINK% to learn &<>more", |
97 |
|
testee.getContent()); |
98 |
0 |
assertEquals("Please click on this%LINK% to learn &<>more", |
99 |
|
testee.getNonHtmlContent()); |
100 |
0 |
assertEquals(1, testee.getLinks().size()); |
101 |
|
|
102 |
0 |
assertEquals( |
103 |
|
"on this|http://www.nowhere.com?id=234&taxon=human&id>3&id<10", |
104 |
|
testee.getLinks().get(0)); |
105 |
|
} |
106 |
|
} |