Clover icon

Coverage Report

  1. Project Clover database Thu Nov 7 2024 17:01:39 GMT
  2. Package jalview.io.cache

File AppCacheTest.java

 

Code metrics

2
21
4
1
80
50
5
0.24
5.25
4
1.25

Classes

Class Line # Actions
AppCacheTest 29 21 5
0.00%
 

Contributing tests

No tests hitting this source file were found.

Source view

1    /*
2    * Jalview - A Sequence Alignment Editor and Viewer ($$Version-Rel$$)
3    * Copyright (C) $$Year-Rel$$ The Jalview Authors
4    *
5    * This file is part of Jalview.
6    *
7    * Jalview is free software: you can redistribute it and/or
8    * modify it under the terms of the GNU General Public License
9    * as published by the Free Software Foundation, either version 3
10    * of the License, or (at your option) any later version.
11    *
12    * Jalview is distributed in the hope that it will be useful, but
13    * WITHOUT ANY WARRANTY; without even the implied warranty
14    * of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15    * PURPOSE. See the GNU General Public License for more details.
16    *
17    * You should have received a copy of the GNU General Public License
18    * along with Jalview. If not, see <http://www.gnu.org/licenses/>.
19    * The Jalview Authors are detailed in the 'AUTHORS' file.
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   
 
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   
 
37  0 toggle @BeforeClass(alwaysRun = true)
38    public void setUpCache()
39    {
40  0 appCache = AppCache.getInstance();
41    }
42   
 
43  0 toggle 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   
 
54  0 toggle @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   
 
68  0 toggle @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    }