Ticket #16010: v1-0001-DownloadWmsAlongTrackActionTest-use-Awaitility-to.patch

File v1-0001-DownloadWmsAlongTrackActionTest-use-Awaitility-to.patch, 2.2 KB (added by ris, 6 years ago)
  • test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java

    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;  
    55import static org.junit.Assert.assertNotNull;
    66import static org.junit.Assert.assertNull;
    77import static org.junit.Assert.assertTrue;
     8import static java.util.concurrent.TimeUnit.MILLISECONDS;
    89
     10import org.awaitility.Awaitility;
    911import org.junit.Rule;
    1012import org.junit.Test;
    1113import org.openstreetmap.josm.data.gpx.GpxData;
    public class DownloadWmsAlongTrackActionTest {  
    4648    public void testTMSLayer() throws Exception {
    4749        final TileSourceRule tileSourceRule = this.test.getTileSourceRule();
    4850
    49         TMSLayer layer = new TMSLayer(
     51        final TMSLayer layer = new TMSLayer(
    5052            tileSourceRule.getSourcesList().get(0).getImageryInfo(tileSourceRule.port())
    5153        );
    5254        try {
    public class DownloadWmsAlongTrackActionTest {  
    5759            PrecacheWmsTask task = new DownloadWmsAlongTrackAction(GpxLayerTest.getMinimalGpxData()).createTask();
    5860            assertNotNull(task);
    5961            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());
    6264        } finally {
    6365            // Ensure we clean the place before leaving, even if test fails.
    6466            MainApplication.getLayerManager().removeLayer(layer);