1 |
|
package jalview.io.cache; |
2 |
|
|
3 |
|
import java.util.LinkedHashSet; |
4 |
|
|
5 |
|
import org.junit.Assert; |
6 |
|
import org.testng.annotations.BeforeClass; |
7 |
|
import org.testng.annotations.Test; |
8 |
|
|
|
|
| 91.3% |
Uncovered Elements: 2 (23) |
Complexity: 5 |
Complexity Density: 0.25 |
|
9 |
|
public class JvCacheableInputBoxTest |
10 |
|
{ |
11 |
|
|
12 |
|
private AppCache appCache; |
13 |
|
|
14 |
|
private static final String TEST_CACHE_KEY = "CACHE.UNIT_TEST"; |
15 |
|
|
16 |
|
private JvCacheableInputBox<String> cacheBox = new JvCacheableInputBox<String>( |
17 |
|
TEST_CACHE_KEY); |
18 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
|
19 |
1 |
@BeforeClass(alwaysRun = true)... |
20 |
|
private void setUpCache() |
21 |
|
{ |
22 |
1 |
appCache = AppCache.getInstance(); |
23 |
|
} |
24 |
|
|
|
|
| 90% |
Uncovered Elements: 1 (10) |
Complexity: 2 |
Complexity Density: 0.2 |
1PASS
|
|
25 |
1 |
@Test(groups = { "Functional" })... |
26 |
|
public void getUserInputTest() |
27 |
|
{ |
28 |
1 |
String userInput = cacheBox.getUserInput(); |
29 |
1 |
Assert.assertEquals("", userInput); |
30 |
|
|
31 |
1 |
String testInput = "TestInput"; |
32 |
1 |
cacheBox.addItem(testInput); |
33 |
1 |
cacheBox.setSelectedItem(testInput); |
34 |
|
|
35 |
1 |
try |
36 |
|
{ |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
1 |
Thread.sleep(100); |
41 |
|
} catch (InterruptedException e) |
42 |
|
{ |
43 |
0 |
e.printStackTrace(); |
44 |
|
} |
45 |
1 |
userInput = cacheBox.getUserInput(); |
46 |
1 |
Assert.assertEquals(testInput, userInput); |
47 |
|
} |
48 |
|
|
|
|
| 88.9% |
Uncovered Elements: 1 (9) |
Complexity: 2 |
Complexity Density: 0.22 |
1PASS
|
|
49 |
1 |
@Test(groups = { "Functional" })... |
50 |
|
public void updateCacheTest() |
51 |
|
{ |
52 |
1 |
String testInput = "TestInput"; |
53 |
1 |
cacheBox.addItem(testInput); |
54 |
1 |
cacheBox.setSelectedItem(testInput); |
55 |
1 |
cacheBox.updateCache(); |
56 |
1 |
try |
57 |
|
{ |
58 |
|
|
59 |
|
|
60 |
1 |
Thread.sleep(200); |
61 |
|
} catch (InterruptedException e) |
62 |
|
{ |
63 |
0 |
e.printStackTrace(); |
64 |
|
} |
65 |
1 |
LinkedHashSet<String> foundCache = appCache |
66 |
|
.getAllCachedItemsFor(TEST_CACHE_KEY); |
67 |
1 |
Assert.assertTrue(foundCache.contains(testInput)); |
68 |
|
} |
69 |
|
} |