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