Ignore:
Timestamp:
2016-02-17T22:05:02+01:00 (8 years ago)
Author:
Don-vip
Message:

fix coverity defect 1351474 (division by zero), add unit test

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadAlongTrackActionTest.java

    r9816 r9817  
    33
    44import static org.junit.Assert.assertNotNull;
     5import static org.junit.Assert.assertNull;
    56
    67import org.junit.BeforeClass;
     
    2829    }
    2930
    30     /**
    31      * Test action.
    32      * @throws Exception if an error occurs
    33      */
    34     @Test
    35     public void testDownload() throws Exception {
    36         final OsmDataLayer layer = new OsmDataLayer(new DataSet(), getClass().getName(), null);
     31    private static PleaseWaitRunnable createTask(String file) throws Exception {
     32        final OsmDataLayer layer = new OsmDataLayer(new DataSet(), DownloadAlongTrackActionTest.class.getName(), null);
    3733        try {
    3834            Main.main.addLayer(layer);
    3935            // Perform action
    40             final GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + "minimal.gpx");
    41             PleaseWaitRunnable task = new DownloadAlongTrackAction(gpx).createTask();
    42             assertNotNull(task);
     36            final GpxData gpx = GpxReaderTest.parseGpxData(TestUtils.getTestDataRoot() + file);
     37            return new DownloadAlongTrackAction(gpx).createTask();
    4338        } finally {
    4439            // Ensure we clean the place before leaving, even if test fails.
     
    4641        }
    4742    }
     43
     44    /**
     45     * Test action with nominal data set.
     46     * @throws Exception if an error occurs
     47     */
     48    @Test
     49    public void testDownload() throws Exception {
     50        assertNotNull(createTask("minimal.gpx"));
     51    }
     52
     53    /**
     54     * Test action with empty data set.
     55     * @throws Exception if an error occurs
     56     */
     57    @Test
     58    public void testDownloadEmpty() throws Exception {
     59        assertNull(createTask("empty.gpx"));
     60    }
    4861}
Note: See TracChangeset for help on using the changeset viewer.