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