Clover icon

jalviewX

  1. Project Clover database Wed Oct 31 2018 15:13:58 GMT
  2. Package jalview.io.cache

File AppCacheTest.java

 

Code metrics

2
21
4
1
61
50
5
0.24
5.25
4
1.25

Classes

Class Line # Actions
AppCacheTest 9 21 5 0
1.0100%
 

Contributing tests

This file is covered by 2 tests. .

Source view

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   
 
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   
 
17  1 toggle @BeforeClass(alwaysRun = true)
18    public void setUpCache()
19    {
20  1 appCache = AppCache.getInstance();
21    }
22   
 
23  1 toggle 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   
 
34  1 toggle @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   
 
48  1 toggle @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    }