1 |
|
|
2 |
|
|
3 |
|
|
4 |
|
|
5 |
|
|
6 |
|
|
7 |
|
|
8 |
|
|
9 |
|
|
10 |
|
|
11 |
|
|
12 |
|
|
13 |
|
|
14 |
|
|
15 |
|
|
16 |
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
|
package jalview.io.cache; |
22 |
|
|
23 |
|
import java.util.LinkedHashSet; |
24 |
|
|
25 |
|
import org.testng.Assert; |
26 |
|
import org.testng.annotations.BeforeClass; |
27 |
|
import org.testng.annotations.Test; |
28 |
|
|
|
|
| 0% |
Uncovered Elements: 27 (27) |
Complexity: 5 |
Complexity Density: 0.24 |
|
29 |
|
public class AppCacheTest |
30 |
|
{ |
31 |
|
private AppCache appCache; |
32 |
|
|
33 |
|
private static final String TEST_CACHE_KEY = "CACHE.UNIT_TEST"; |
34 |
|
|
35 |
|
private static final String TEST_FAKE_CACHE_KEY = "CACHE.UNIT_TEST_FAKE"; |
36 |
|
|
|
|
| 0% |
Uncovered Elements: 1 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
37 |
0 |
@BeforeClass(alwaysRun = true)... |
38 |
|
public void setUpCache() |
39 |
|
{ |
40 |
0 |
appCache = AppCache.getInstance(); |
41 |
|
} |
42 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
43 |
0 |
public void generateTestCacheItems()... |
44 |
|
{ |
45 |
0 |
LinkedHashSet<String> testCacheItems = new LinkedHashSet<String>(); |
46 |
0 |
for (int x = 0; x < 10; x++) |
47 |
|
{ |
48 |
0 |
testCacheItems.add("TestCache" + x); |
49 |
|
} |
50 |
0 |
appCache.putCache(TEST_CACHE_KEY, testCacheItems); |
51 |
0 |
appCache.persistCache(TEST_CACHE_KEY); |
52 |
|
} |
53 |
|
|
|
|
| 0% |
Uncovered Elements: 8 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
4-
|
|
54 |
0 |
@Test(groups = { "Functional" })... |
55 |
|
public void appCacheTest() |
56 |
|
{ |
57 |
0 |
LinkedHashSet<String> cacheItems = appCache |
58 |
|
.getAllCachedItemsFor(TEST_FAKE_CACHE_KEY); |
59 |
0 |
Assert.assertEquals(cacheItems.size(), 0); |
60 |
0 |
generateTestCacheItems(); |
61 |
0 |
cacheItems = appCache.getAllCachedItemsFor(TEST_CACHE_KEY); |
62 |
0 |
Assert.assertEquals(cacheItems.size(), 10); |
63 |
0 |
appCache.deleteCacheItems(TEST_CACHE_KEY); |
64 |
0 |
cacheItems = appCache.getAllCachedItemsFor(TEST_CACHE_KEY); |
65 |
0 |
Assert.assertEquals(cacheItems.size(), 0); |
66 |
|
} |
67 |
|
|
|
|
| 0% |
Uncovered Elements: 7 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
4-
|
|
68 |
0 |
@Test(groups = { "Functional" })... |
69 |
|
public void appCacheLimitTest() |
70 |
|
{ |
71 |
0 |
String limit = appCache.getCacheLimit(TEST_CACHE_KEY); |
72 |
0 |
Assert.assertEquals(limit, "99"); |
73 |
0 |
limit = String.valueOf(appCache.updateCacheLimit(TEST_CACHE_KEY, 20)); |
74 |
0 |
Assert.assertEquals(limit, "20"); |
75 |
0 |
limit = appCache.getCacheLimit(TEST_CACHE_KEY); |
76 |
0 |
Assert.assertEquals(limit, "20"); |
77 |
0 |
appCache.updateCacheLimit(TEST_CACHE_KEY, 99); |
78 |
|
} |
79 |
|
|
80 |
|
} |