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.assertTrue; |
25 |
|
|
26 |
|
import org.testng.annotations.Test; |
27 |
|
|
|
|
| 94% |
Uncovered Elements: 3 (50) |
Complexity: 2 |
Complexity Density: 0.04 |
|
28 |
|
public class MemorySettingTest |
29 |
|
{ |
30 |
|
|
|
|
| 93.9% |
Uncovered Elements: 3 (49) |
Complexity: 2 |
Complexity Density: 0.04 |
1PASS
|
|
31 |
1 |
@Test(groups = "Functional")... |
32 |
|
public void testGetMemorySetting() |
33 |
|
{ |
34 |
1 |
long KB = 1024; |
35 |
1 |
long MB = KB * KB; |
36 |
1 |
long GB = MB * KB; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
|
42 |
|
|
43 |
1 |
long mem1 = MemorySetting.getMemorySetting("1T", "100"); |
44 |
1 |
long fullmem = mem1 + 512 * MB; |
45 |
1 |
long mem1b = MemorySetting.getMemorySetting("1t", "100"); |
46 |
1 |
assertTrue(mem1 > 1 * GB); |
47 |
1 |
assertEquals(mem1, mem1b); |
48 |
|
|
49 |
|
|
50 |
|
|
51 |
|
|
52 |
1 |
String pc; |
53 |
1 |
Float pcf; |
54 |
1 |
if (mem1 > 5 * GB) |
55 |
|
{ |
56 |
1 |
pc = "10"; |
57 |
1 |
pcf = 0.1f; |
58 |
|
} |
59 |
|
else |
60 |
|
{ |
61 |
0 |
pc = "50"; |
62 |
0 |
pcf = 0.5f; |
63 |
|
} |
64 |
1 |
long mem1c = MemorySetting.getMemorySetting("1T", pc); |
65 |
1 |
assertTrue(mem1c > (pcf - 0.01) * fullmem |
66 |
|
&& mem1c < (pcf + 0.01) * fullmem); |
67 |
|
|
68 |
|
|
69 |
|
|
70 |
1 |
long mem2 = MemorySetting.getMemorySetting("1G", "100"); |
71 |
1 |
long mem2b = MemorySetting.getMemorySetting("1g", "100"); |
72 |
1 |
assertEquals(mem2, 1 * GB); |
73 |
1 |
assertEquals(mem2, mem2b); |
74 |
|
|
75 |
1 |
long mem3 = MemorySetting.getMemorySetting("1024M", "100"); |
76 |
1 |
long mem3b = MemorySetting.getMemorySetting("1024m", "100"); |
77 |
1 |
assertEquals(mem3, 1024 * MB); |
78 |
1 |
assertEquals(mem3, mem3b); |
79 |
|
|
80 |
1 |
long mem4 = MemorySetting.getMemorySetting("1048576K", "100"); |
81 |
1 |
long mem4b = MemorySetting.getMemorySetting("1048576k", "100"); |
82 |
1 |
assertEquals(mem4, 1048576 * KB); |
83 |
1 |
assertEquals(mem4, mem4b); |
84 |
|
|
85 |
1 |
long mem5 = MemorySetting.getMemorySetting("1073741824B", "100"); |
86 |
1 |
long mem5b = MemorySetting.getMemorySetting("1073741824b", "100"); |
87 |
1 |
long mem5c = MemorySetting.getMemorySetting("1073741824", "100"); |
88 |
1 |
assertEquals(mem5, 1073741824L); |
89 |
1 |
assertEquals(mem5, mem5b); |
90 |
1 |
assertEquals(mem5, mem5c); |
91 |
|
|
92 |
|
|
93 |
1 |
assertEquals(mem2, mem3); |
94 |
1 |
assertEquals(mem2, mem4); |
95 |
1 |
assertEquals(mem2, mem5); |
96 |
|
|
97 |
|
|
98 |
1 |
long mem6 = MemorySetting.getMemorySetting(); |
99 |
1 |
assertTrue(mem6 <= (long) (0.905 * fullmem)); |
100 |
1 |
assertTrue(mem6 <= 32 * GB); |
101 |
|
|
102 |
|
|
103 |
1 |
long mem7 = MemorySetting.getMemorySetting("1B", "0.000000001"); |
104 |
1 |
assertEquals(mem7, 512 * MB); |
105 |
|
|
106 |
|
|
107 |
1 |
long mem8 = MemorySetting.getMemorySetting("2T", "100"); |
108 |
|
|
109 |
1 |
long mem8b = MemorySetting.getMemorySetting("2T", "50"); |
110 |
|
|
111 |
1 |
long diff = mem8b * 2 - mem8; |
112 |
1 |
assertTrue(512 * MB - 10 * KB < diff && diff < 512 * MB + 10 * KB); |
113 |
|
|
114 |
|
} |
115 |
|
|
116 |
|
} |