| 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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (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 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
| 37 |
1 |
@BeforeClass(alwaysRun = true)... |
| 38 |
|
public void setUpCache() |
| 39 |
|
{ |
| 40 |
1 |
appCache = AppCache.getInstance(); |
| 41 |
|
} |
| 42 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 2 |
Complexity Density: 0.4 |
|
| 43 |
1 |
public void generateTestCacheItems()... |
| 44 |
|
{ |
| 45 |
1 |
LinkedHashSet<String> testCacheItems = new LinkedHashSet<String>(); |
| 46 |
11 |
for (int x = 0; x < 10; x++) |
| 47 |
|
{ |
| 48 |
10 |
testCacheItems.add("TestCache" + x); |
| 49 |
|
} |
| 50 |
1 |
appCache.putCache(TEST_CACHE_KEY, testCacheItems); |
| 51 |
1 |
appCache.persistCache(TEST_CACHE_KEY); |
| 52 |
|
} |
| 53 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0.12 |
1PASS
|
|
| 54 |
1 |
@Test(groups = { "Functional" })... |
| 55 |
|
public void appCacheTest() |
| 56 |
|
{ |
| 57 |
1 |
LinkedHashSet<String> cacheItems = appCache |
| 58 |
|
.getAllCachedItemsFor(TEST_FAKE_CACHE_KEY); |
| 59 |
1 |
Assert.assertEquals(cacheItems.size(), 0); |
| 60 |
1 |
generateTestCacheItems(); |
| 61 |
1 |
cacheItems = appCache.getAllCachedItemsFor(TEST_CACHE_KEY); |
| 62 |
1 |
Assert.assertEquals(cacheItems.size(), 10); |
| 63 |
1 |
appCache.deleteCacheItems(TEST_CACHE_KEY); |
| 64 |
1 |
cacheItems = appCache.getAllCachedItemsFor(TEST_CACHE_KEY); |
| 65 |
1 |
Assert.assertEquals(cacheItems.size(), 0); |
| 66 |
|
} |
| 67 |
|
|
| |
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0.14 |
1PASS
|
|
| 68 |
1 |
@Test(groups = { "Functional" })... |
| 69 |
|
public void appCacheLimitTest() |
| 70 |
|
{ |
| 71 |
1 |
String limit = appCache.getCacheLimit(TEST_CACHE_KEY); |
| 72 |
1 |
Assert.assertEquals(limit, "99"); |
| 73 |
1 |
limit = String.valueOf(appCache.updateCacheLimit(TEST_CACHE_KEY, 20)); |
| 74 |
1 |
Assert.assertEquals(limit, "20"); |
| 75 |
1 |
limit = appCache.getCacheLimit(TEST_CACHE_KEY); |
| 76 |
1 |
Assert.assertEquals(limit, "20"); |
| 77 |
1 |
appCache.updateCacheLimit(TEST_CACHE_KEY, 99); |
| 78 |
|
} |
| 79 |
|
|
| 80 |
|
} |