1 package jalview.io.cache;
3 import java.util.LinkedHashSet;
5 import org.junit.Assert;
6 import org.testng.annotations.BeforeClass;
7 import org.testng.annotations.Test;
9 public class JvCacheableInputBoxTest
12 private AppCache appCache;
14 private static final String TEST_CACHE_KEY = "CACHE.UNIT_TEST";
16 private JvCacheableInputBox<String> cacheBox = new JvCacheableInputBox<>(
19 @BeforeClass(alwaysRun = true)
20 private void setUpCache()
22 appCache = AppCache.getInstance();
25 @Test(groups = { "Functional" })
26 public void getUserInputTest()
28 String userInput = cacheBox.getUserInput();
29 Assert.assertEquals("", userInput);
31 String testInput = "TestInput";
32 cacheBox.addItem(testInput);
33 cacheBox.setSelectedItem(testInput);
34 cacheBox.updateCacheNow(); // synchronous update
35 userInput = cacheBox.getUserInput();
36 Assert.assertEquals(testInput, userInput);
39 @Test(groups = { "Functional" })
40 public void updateCacheTest()
42 String testInput = "TestInput";
43 cacheBox.addItem(testInput);
44 cacheBox.setSelectedItem(testInput);
45 cacheBox.updateCacheNow();
46 LinkedHashSet<String> foundCache = appCache
47 .getAllCachedItemsFor(TEST_CACHE_KEY);
48 Assert.assertTrue(foundCache.contains(testInput));