Ignore:
Timestamp:
2014-08-04T21:31:18+02:00 (10 years ago)
Author:
donvip
Message:

[josm_elevation] fix unit test

Location:
applications/editors/josm/plugins/ElevationProfile/test
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ElevationProfile/test/unit/org/openstreetmap/josm/plugins/elevation/tests/HgtReaderTest.java

    r30344 r30558  
    22package org.openstreetmap.josm.plugins.elevation.tests;
    33
     4import java.io.IOException;
     5import java.nio.file.DirectoryIteratorException;
     6import java.nio.file.DirectoryStream;
     7import java.nio.file.Files;
     8import java.nio.file.Path;
     9import java.nio.file.Paths;
     10
    411import junit.framework.TestCase;
    512
    6 import org.openstreetmap.josm.Main;
    7 import org.openstreetmap.josm.data.Preferences;
     13import org.openstreetmap.josm.JOSMFixture;
     14import org.openstreetmap.josm.TestUtils;
    815import org.openstreetmap.josm.data.coor.LatLon;
    916import org.openstreetmap.josm.plugins.elevation.HgtReader;
     
    1320    /**
    1421     * Setup test.
     22     * @throws IOException if SRTM files cannot be installed
    1523     */
    1624    @Override
    17     public void setUp() {
    18         Main.pref = new Preferences();
     25    public void setUp() throws IOException {
     26        JOSMFixture.createUnitTestFixture().init();
     27        // Install SRTM files to plugin directory
     28        try (DirectoryStream<Path> stream = Files.newDirectoryStream(Paths.get(TestUtils.getTestDataRoot()), "*.hgt")) {
     29            Path dir = Paths.get(System.getProperty("josm.home")).resolve("elevation");
     30            if (!Files.exists(dir)) {
     31                Files.createDirectory(dir);
     32            }
     33            for (Path src: stream) {
     34                Path dst = dir.resolve(src.getFileName());
     35                if (!Files.exists(dst)) {
     36                    Files.copy(src, dst);
     37                }
     38            }
     39        } catch (DirectoryIteratorException ex) {
     40            // I/O error encounted during the iteration, the cause is an IOException
     41            throw ex.getCause();
     42        }
    1943    }
    2044
Note: See TracChangeset for help on using the changeset viewer.