From bb7696401c4b92d19509c7bc142f2a65a542667e Mon Sep 17 00:00:00 2001
From: Robert Scott <code@humanleg.org.uk>
Date: Wed, 1 Aug 2018 00:39:55 +0100
Subject: [PATCH v1] DownloadWmsAlongTrackActionTest: use Awaitility to give
cache a chance to fill before we fail it
---
.../josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java b/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java
index 2a600cf8a..bfe95f8ad 100644
a
|
b
|
import static org.junit.Assert.assertFalse;
|
5 | 5 | import static org.junit.Assert.assertNotNull; |
6 | 6 | import static org.junit.Assert.assertNull; |
7 | 7 | import static org.junit.Assert.assertTrue; |
| 8 | import static java.util.concurrent.TimeUnit.MILLISECONDS; |
8 | 9 | |
| 10 | import org.awaitility.Awaitility; |
9 | 11 | import org.junit.Rule; |
10 | 12 | import org.junit.Test; |
11 | 13 | import org.openstreetmap.josm.data.gpx.GpxData; |
… |
… |
public class DownloadWmsAlongTrackActionTest {
|
46 | 48 | public void testTMSLayer() throws Exception { |
47 | 49 | final TileSourceRule tileSourceRule = this.test.getTileSourceRule(); |
48 | 50 | |
49 | | TMSLayer layer = new TMSLayer( |
| 51 | final TMSLayer layer = new TMSLayer( |
50 | 52 | tileSourceRule.getSourcesList().get(0).getImageryInfo(tileSourceRule.port()) |
51 | 53 | ); |
52 | 54 | try { |
… |
… |
public class DownloadWmsAlongTrackActionTest {
|
57 | 59 | PrecacheWmsTask task = new DownloadWmsAlongTrackAction(GpxLayerTest.getMinimalGpxData()).createTask(); |
58 | 60 | assertNotNull(task); |
59 | 61 | task.run(); |
60 | | // Ensure cache is not empty |
61 | | assertFalse(TMSLayer.getCache().getMatching(".*").isEmpty()); |
| 62 | // Ensure cache is (eventually) not empty |
| 63 | Awaitility.await().atMost(10000, MILLISECONDS).until(() -> !TMSLayer.getCache().getMatching(".*").isEmpty()); |
62 | 64 | } finally { |
63 | 65 | // Ensure we clean the place before leaving, even if test fails. |
64 | 66 | MainApplication.getLayerManager().removeLayer(layer); |