Changeset 30558 in osm for applications


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
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ElevationProfile/.classpath

    r30550 r30558  
    33        <classpathentry kind="src" path="src"/>
    44        <classpathentry kind="src" path="test/unit"/>
    5         <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/3"/>
     5        <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/>
    66        <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/>
    77        <classpathentry combineaccessrules="false" kind="src" path="/JOSM"/>
  • applications/editors/josm/plugins/ElevationProfile/README

    r23784 r30558  
    66For detailed instructions please refer to http://wiki.openstreetmap.org/wiki/JOSM/Plugins/ElevationProfile.
    77
     8SRTM data in test/data is downloaded from http://dds.cr.usgs.gov/srtm/version2_1/SRTM3/Eurasia/
     9
    810Please report bugs to oliver.wieland@online.de.
  • 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.