X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=test%2Fjalview%2Fio%2Fcache%2FJvCacheableInputBoxTest.java;h=ce340442549cfe68ecdc7c3baf6566a38ee0adff;hb=b72ed01b68a8572022f912687db5be60b53c15cf;hp=5f9af2546e1c8ff124c5855066306d1af3e10993;hpb=6444e0413859ac9197c9bc493dc45e1f88de2c48;p=jalview.git diff --git a/test/jalview/io/cache/JvCacheableInputBoxTest.java b/test/jalview/io/cache/JvCacheableInputBoxTest.java index 5f9af25..ce34044 100644 --- a/test/jalview/io/cache/JvCacheableInputBoxTest.java +++ b/test/jalview/io/cache/JvCacheableInputBoxTest.java @@ -84,24 +84,28 @@ public class JvCacheableInputBoxTest cacheBox.addItem(testInput); cacheBox.setSelectedItem(testInput); cacheBox.updateCache(); - - try + boolean done[]=new boolean[] { false }; + // this event gets processed after updateCache's update event on the swing + // thread + SwingUtilities.invokeLater(() -> { + done[0]=true; + }); + long t=0; + while (!done[0] && t<200) { - // fix for JAL-4153 - // This delay is to let cacheBox.updateCache() finish updating the cache - SwingUtilities.invokeAndWait(() -> { - try - { - Thread.sleep(1); + try { + Thread.sleep(7); + t++; } catch (InterruptedException e) { e.printStackTrace(); } - }); - } catch (InvocationTargetException | InterruptedException e) + } + if (!done[0]) { - e.printStackTrace(); + Assert.fail("Giving up after 1.4s waiting for cache to be updated."); } + LinkedHashSet foundCache = appCache .getAllCachedItemsFor(TEST_CACHE_KEY); Assert.assertTrue(foundCache.contains(testInput));