Index: trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java
===================================================================
--- trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java	(revision 14068)
+++ trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java	(revision 14069)
@@ -6,5 +6,7 @@
 import static org.junit.Assert.assertNull;
 import static org.junit.Assert.assertTrue;
+import static java.util.concurrent.TimeUnit.MILLISECONDS;
 
+import org.awaitility.Awaitility;
 import org.junit.Rule;
 import org.junit.Test;
@@ -47,5 +49,5 @@
         final TileSourceRule tileSourceRule = this.test.getTileSourceRule();
 
-        TMSLayer layer = new TMSLayer(
+        final TMSLayer layer = new TMSLayer(
             tileSourceRule.getSourcesList().get(0).getImageryInfo(tileSourceRule.port())
         );
@@ -58,6 +60,6 @@
             assertNotNull(task);
             task.run();
-            // Ensure cache is not empty
-            assertFalse(TMSLayer.getCache().getMatching(".*").isEmpty());
+            // Ensure cache is (eventually) not empty
+            Awaitility.await().atMost(10000, MILLISECONDS).until(() -> !TMSLayer.getCache().getMatching(".*").isEmpty());
         } finally {
             // Ensure we clean the place before leaving, even if test fails.
