Ignore:
Timestamp:
2012-11-03T18:32:39+01:00 (11 years ago)
Author:
Don-vip
Message:

see #8172 - fix JUnit tests

Location:
trunk/test/unit/org/openstreetmap/josm/data
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

    r4126 r5556  
    2020import org.openstreetmap.josm.data.Preferences;
    2121import org.openstreetmap.josm.data.coor.LatLon;
    22 import org.openstreetmap.josm.data.projection.Mercator;
     22import org.openstreetmap.josm.data.projection.Projections;
    2323
    2424public class DataSetMergerTest {
     
    7676        their = new DataSet();
    7777        their.setVersion("0.6");
    78         Main.setProjection(new Mercator());
     78        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    7979    }
    8080
  • trunk/test/unit/org/openstreetmap/josm/data/osm/FilterTest.java

    r4126 r5556  
    1919import org.openstreetmap.josm.data.Preferences;
    2020import org.openstreetmap.josm.data.coor.LatLon;
    21 import org.openstreetmap.josm.data.projection.Mercator;
     21import org.openstreetmap.josm.data.projection.Projections;
    2222import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2323import org.openstreetmap.josm.io.IllegalDataException;
     
    2929    @BeforeClass
    3030    public static void setUp() {
    31         Main.setProjection(new Mercator());
     31        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    3232        Main.pref = new Preferences();
    3333    }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveTest.java

    r4126 r5556  
    1111import org.openstreetmap.josm.data.Preferences;
    1212import org.openstreetmap.josm.data.coor.LatLon;
    13 import org.openstreetmap.josm.data.projection.Mercator;
     13import org.openstreetmap.josm.data.projection.Projections;
    1414
    1515public class OsmPrimitiveTest {
     
    2929    @BeforeClass
    3030    public static void setUp() {
    31         Main.setProjection(new Mercator());
     31        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    3232    }
    3333
  • trunk/test/unit/org/openstreetmap/josm/data/osm/QuadBucketsTest.java

    r4126 r5556  
    1616import org.openstreetmap.josm.data.Preferences;
    1717import org.openstreetmap.josm.data.coor.LatLon;
    18 import org.openstreetmap.josm.data.projection.Mercator;
     18import org.openstreetmap.josm.data.projection.Projections;
    1919import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2020import org.openstreetmap.josm.io.OsmReader;
     
    6666    @Test
    6767    public void testRemove() throws Exception {
    68         Main.setProjection(new Mercator());
     68        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    6969        DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE);
    7070        removeAllTest(ds);
     
    7373    @Test
    7474    public void testMove() throws Exception {
    75         Main.setProjection(new Mercator());
     75        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    7676        DataSet ds = OsmReader.parseDataSet(new FileInputStream("data_nodist/restriction.osm"), NullProgressMonitor.INSTANCE);
    7777
  • trunk/test/unit/org/openstreetmap/josm/data/osm/RelationTest.java

    r4126 r5556  
    1010import org.openstreetmap.josm.data.Preferences;
    1111import org.openstreetmap.josm.data.coor.LatLon;
    12 import org.openstreetmap.josm.data.projection.Mercator;
     12import org.openstreetmap.josm.data.projection.Projections;
    1313
    1414public class RelationTest {
     
    1616    @BeforeClass
    1717    public static void setUp() {
    18         Main.setProjection(new Mercator());
     18        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    1919        Main.pref = new Preferences();
    2020    }
  • trunk/test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java

    r4126 r5556  
    2121import org.openstreetmap.josm.data.osm.RelationMember;
    2222import org.openstreetmap.josm.data.osm.Way;
    23 import org.openstreetmap.josm.data.projection.Mercator;
     23import org.openstreetmap.josm.data.projection.Projections;
    2424
    2525public class MergeSourceBuildingVisitorTest {
     
    3737    @BeforeClass
    3838    public static void setUp() {
    39         Main.setProjection(new Mercator());
     39        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    4040        Main.pref = new Preferences();
    4141    }
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java

    r5236 r5556  
    2323        text = "";
    2424
    25         testProj(new Epsg4326());
    26         testProj(new Mercator());
     25        testProj(Projections.getProjectionByCode("EPSG:4326")); // WGS 84
     26        testProj(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    2727        if (!"yes".equals(System.getProperty("suppressPermanentFailure"))) {
    28             testProj(new LambertEST());
     28            testProj(Projections.getProjectionByCode("EPSG:3301")); // Lambert EST
    2929        }
    3030
    3131        for (int i=0; i<=3; ++i) {
    32             testProj(new Lambert(i));
     32            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(27561+i))); // Lambert 4 Zones France
    3333        }
    3434
    3535        for (int i=0; i<=4; ++i) {
    36             testProj(new Puwg(i));
     36            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(2176+i))); // PUWG Poland
    3737        }
    3838
    39         testProj(new SwissGrid());
     39        testProj(Projections.getProjectionByCode("EPSG:21781")); // Swiss grid
    4040
    41         for (int i=0; i<=6; ++i) {
    42             int zone;
    43             if (i==0) {
    44                 zone = 1;
    45             } else if (i==6) {
    46                 zone = 60;
    47             } else {
    48                 zone = rand.nextInt(60) + 1;
    49             }
    50             UTM.Hemisphere hem = rand.nextBoolean() ? UTM.Hemisphere.North : UTM.Hemisphere.South;
    51             testProj(new UTM(zone, hem));
     41        for (int i=0; i<=60; ++i) {
     42            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32601+i))); // UTM North
     43            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(32701+i))); // UTM South
    5244        }
    5345
    5446        if (!"yes".equals(System.getProperty("suppressPermanentFailure"))) {
    5547            for (int i=0; i<=4; ++i) {
    56                 testProj(new UTM_France_DOM(i));
     48                testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(2969+i))); // UTM France DOM
    5749            }
    5850        }
    5951
    6052        for (int i=0; i<=8; ++i) {
    61             testProj(new LambertCC9Zones(i));
     53            testProj(Projections.getProjectionByCode("EPSG:"+Integer.toString(3942+i))); // Lambert CC9 Zones France
    6254        }
    6355
     
    6961
    7062    private void testProj(Projection p) {
    71         double maxErrLat = 0, maxErrLon = 0;
    72 
    73         Bounds b = p.getWorldBoundsLatLon();
    74 
    75         text += String.format("*** %s %s\n", p.toString(), p.toCode());
    76         for (int num=0; num < 1000; ++num) {
    77 
    78             double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat();
    79             double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon();
    80 
    81             LatLon ll = new LatLon(lat, lon);
    82 
    83             for (int i=0; i<10; ++i) {
    84                 EastNorth en = p.latlon2eastNorth(ll);
    85                 ll = p.eastNorth2latlon(en);
     63        if (p != null) {
     64            double maxErrLat = 0, maxErrLon = 0;
     65            Bounds b = p.getWorldBoundsLatLon();
     66   
     67            text += String.format("*** %s %s\n", p.toString(), p.toCode());
     68            for (int num=0; num < 1000; ++num) {
     69   
     70                double lat = rand.nextDouble() * (b.getMax().lat() - b.getMin().lat()) + b.getMin().lat();
     71                double lon = rand.nextDouble() * (b.getMax().lon() - b.getMin().lon()) + b.getMin().lon();
     72   
     73                LatLon ll = new LatLon(lat, lon);
     74   
     75                for (int i=0; i<10; ++i) {
     76                    EastNorth en = p.latlon2eastNorth(ll);
     77                    ll = p.eastNorth2latlon(en);
     78                }
     79                maxErrLat = Math.max(maxErrLat, Math.abs(lat - ll.lat()));
     80                maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon()));
    8681            }
    87             maxErrLat = Math.max(maxErrLat, Math.abs(lat - ll.lat()));
    88             maxErrLon = Math.max(maxErrLon, Math.abs(lon - ll.lon()));
     82   
     83            String mark = "";
     84            if (maxErrLat + maxErrLon > 1e-5) {
     85                mark = "--FAILED-- ";
     86                error = true;
     87            }
     88            text += String.format("%s errorLat: %s errorLon: %s\n", mark, maxErrLat, maxErrLon);
    8989        }
    90 
    91         String mark = "";
    92         if (maxErrLat + maxErrLon > 1e-5) {
    93             mark = "--FAILED-- ";
    94             error = true;
    95         }
    96         text += String.format("%s errorLat: %s errorLon: %s\n", mark, maxErrLat, maxErrLon);
    9790    }
    9891}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r4126 r5556  
    1515    @BeforeClass
    1616    public static void setUp() {
    17         Main.setProjection(new SwissGrid());
     17        Main.setProjection(Projections.getProjectionByCode("EPSG:21781")); // Swiss grid
    1818    }
    1919
     
    4747    @Test
    4848    public void projReferenceTest() {
    49         Projection swiss = new SwissGrid();
     49        Projection swiss = Projections.getProjectionByCode("EPSG:21781"); // Swiss grid
    5050        String errs = "";
    5151        for (ProjData pd : data) {
Note: See TracChangeset for help on using the changeset viewer.