source: josm/trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java@ 14116

Last change on this file since 14116 was 14116, checked in by Don-vip, 6 years ago

see #16590 - ignore failing unit test

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.layer.gpx;
3
4import static java.util.concurrent.TimeUnit.MILLISECONDS;
5import static org.junit.Assert.assertNotNull;
6import static org.junit.Assert.assertNull;
7import static org.junit.Assert.assertTrue;
8
9import org.awaitility.Awaitility;
10import org.junit.Ignore;
11import org.junit.Rule;
12import org.junit.Test;
13import org.openstreetmap.josm.data.gpx.GpxData;
14import org.openstreetmap.josm.gui.MainApplication;
15import org.openstreetmap.josm.gui.layer.GpxLayerTest;
16import org.openstreetmap.josm.gui.layer.TMSLayer;
17import org.openstreetmap.josm.gui.layer.gpx.DownloadWmsAlongTrackAction.PrecacheWmsTask;
18import org.openstreetmap.josm.testutils.JOSMTestRules;
19import org.openstreetmap.josm.testutils.TileSourceRule;
20
21import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
22
23/**
24 * Unit tests of {@link DownloadWmsAlongTrackAction} class.
25 */
26public class DownloadWmsAlongTrackActionTest {
27
28 /**
29 * Setup test.
30 */
31 @Rule
32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
33 public JOSMTestRules test = new JOSMTestRules().platform().main().projection().fakeImagery().timeout(20000);
34
35 /**
36 * Test action without layer.
37 */
38 @Test
39 public void testNoLayer() {
40 assertNull(new DownloadWmsAlongTrackAction(new GpxData()).createTask());
41 }
42
43 /**
44 * Test action with a TMS layer.
45 * @throws Exception if an error occurs
46 */
47 @Test
48 @Ignore("Test fails since r14052 - see #16590")
49 public void testTMSLayer() throws Exception {
50 final TileSourceRule tileSourceRule = this.test.getTileSourceRule();
51
52 final TMSLayer layer = new TMSLayer(
53 tileSourceRule.getSourcesList().get(0).getImageryInfo(tileSourceRule.port())
54 );
55 try {
56 MainApplication.getLayerManager().addLayer(layer);
57 TMSLayer.getCache().clear();
58 assertTrue(TMSLayer.getCache().getMatching(".*").isEmpty());
59 // Perform action
60 PrecacheWmsTask task = new DownloadWmsAlongTrackAction(GpxLayerTest.getMinimalGpxData()).createTask();
61 assertNotNull(task);
62 task.run();
63 // Ensure cache is (eventually) not empty
64 Awaitility.await().atMost(10000, MILLISECONDS).until(() -> !TMSLayer.getCache().getMatching(".*").isEmpty());
65 } finally {
66 // Ensure we clean the place before leaving, even if test fails.
67 MainApplication.getLayerManager().removeLayer(layer);
68 }
69 }
70}
Note: See TracBrowser for help on using the repository browser.