1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.bin; |
22 |
|
|
23 |
|
import static org.testng.AssertJUnit.assertEquals; |
24 |
|
import static org.testng.AssertJUnit.assertFalse; |
25 |
|
import static org.testng.AssertJUnit.assertNull; |
26 |
|
import static org.testng.AssertJUnit.assertTrue; |
27 |
|
|
28 |
|
import jalview.bin.ArgsParser; |
29 |
|
import jalview.gui.JvOptionPane; |
30 |
|
|
31 |
|
import org.testng.annotations.BeforeClass; |
32 |
|
import org.testng.annotations.Test; |
33 |
|
|
|
|
| 0% |
Uncovered Elements: 32 (32) |
Complexity: 5 |
Complexity Density: 0.19 |
|
34 |
|
public class ArgsParserTest |
35 |
|
{ |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 2 (2) |
Complexity: 1 |
Complexity Density: 0.5 |
|
37 |
0 |
@BeforeClass(alwaysRun = true)... |
38 |
|
public void setUpJvOptionPane() |
39 |
|
{ |
40 |
0 |
JvOptionPane.setInteractiveMode(false); |
41 |
0 |
JvOptionPane.setMockResponse(JvOptionPane.CANCEL_OPTION); |
42 |
|
} |
43 |
|
|
|
|
| 0% |
Uncovered Elements: 11 (11) |
Complexity: 1 |
Complexity Density: 0.09 |
4-
|
|
44 |
0 |
@Test(groups = "Functional")... |
45 |
|
public void testGetValue() |
46 |
|
{ |
47 |
0 |
ArgsParser ap = new ArgsParser( |
48 |
|
new String[] |
49 |
|
{ "-name", "Henry", "-job", "Tester" }); |
50 |
0 |
assertEquals(4, ap.getSize()); |
51 |
0 |
assertNull(ap.getValue("rubbish")); |
52 |
0 |
assertEquals("Tester", ap.getValue("job")); |
53 |
|
|
54 |
0 |
assertEquals(2, ap.getSize()); |
55 |
0 |
assertNull(ap.getValue("job")); |
56 |
0 |
assertFalse(ap.contains("job")); |
57 |
0 |
assertFalse(ap.contains("Tester")); |
58 |
|
|
59 |
0 |
assertEquals("Henry", ap.getValue("name")); |
60 |
0 |
assertEquals(0, ap.getSize()); |
61 |
0 |
assertNull(ap.getValue("name")); |
62 |
|
} |
63 |
|
|
|
|
| 0% |
Uncovered Elements: 4 (4) |
Complexity: 1 |
Complexity Density: 0.25 |
4-
|
|
64 |
0 |
@Test(groups = "Functional")... |
65 |
|
public void testGetValue_decoded() |
66 |
|
{ |
67 |
0 |
ArgsParser ap = new ArgsParser( |
68 |
|
new String[] |
69 |
|
{ "-name%241", "Henry", "-job", "Test%203%2a" }); |
70 |
|
|
71 |
0 |
assertEquals("Test 3*", ap.getValue("job", true)); |
72 |
|
|
73 |
0 |
assertNull(ap.getValue("name$1", true)); |
74 |
0 |
assertEquals("Henry", ap.getValue("name%241", true)); |
75 |
|
} |
76 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
4-
|
|
77 |
0 |
@Test(groups = "Functional")... |
78 |
|
public void testNextValue() |
79 |
|
{ |
80 |
0 |
ArgsParser ap = new ArgsParser( |
81 |
|
new String[] |
82 |
|
{ "-name", "Henry", "-job", "Tester" }); |
83 |
0 |
assertEquals("name", ap.nextValue()); |
84 |
0 |
assertEquals("Henry", ap.nextValue()); |
85 |
0 |
assertEquals("job", ap.nextValue()); |
86 |
0 |
assertEquals("Tester", ap.nextValue()); |
87 |
|
} |
88 |
|
|
|
|
| 0% |
Uncovered Elements: 5 (5) |
Complexity: 1 |
Complexity Density: 0.2 |
4-
|
|
89 |
0 |
@Test(groups = "Functional")... |
90 |
|
public void testContains() |
91 |
|
{ |
92 |
0 |
ArgsParser ap = new ArgsParser( |
93 |
|
new String[] |
94 |
|
{ "-name", "Henry", "-job", "Tester" }); |
95 |
0 |
assertFalse(ap.contains("Susan")); |
96 |
0 |
assertFalse(ap.contains("-name")); |
97 |
0 |
assertTrue(ap.contains("name")); |
98 |
|
|
99 |
0 |
assertFalse(ap.contains("name")); |
100 |
|
} |
101 |
|
} |