Changeset 12795 in josm for trunk/test


Ignore:
Timestamp:
2017-09-09T10:35:27+02:00 (2 years ago)
Author:
bastiK
Message:

see #15273, see #15229 - fix unit tests, PMD, etc.

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r12760 r12795  
    121121        Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    122122
     123        // setup projection grid files
     124        MainApplication.setupNadGridSources();
     125
    123126        // make sure we don't upload to or test against production
    124127        url = OsmApi.getOsmApi().getBaseUrl().toLowerCase(Locale.ENGLISH).trim();
  • trunk/test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java

    r12746 r12795  
    269269    }
    270270
    271     /**
    272      * Unit test of {@link LatLon#parse} method.
    273      */
    274     @Test
    275     public void testParse() {
    276         assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918° 19.24788°"));
    277         assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("N 49.29918 E 19.24788°"));
    278         assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918° 19.24788°"));
    279         assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("N 49.29918 E 19.24788"));
    280         assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("n 49.29918 e 19.24788"));
    281         assertEquals(new LatLon(-19 - 24.788 / 60, -49 - 29.918 / 60), LatLon.parse("W 49°29.918' S 19°24.788'"));
    282         assertEquals(new LatLon(-19 - 24.788 / 60, -49 - 29.918 / 60), LatLon.parse("w 49°29.918' s 19°24.788'"));
    283         assertEquals(new LatLon(49 + 29. / 60 + 04. / 3600, 19 + 24. / 60 + 43. / 3600), LatLon.parse("N 49°29'04\" E 19°24'43\""));
    284         assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918 N, 19.24788 E"));
    285         assertEquals(new LatLon(49.29918, 19.24788), LatLon.parse("49.29918 n, 19.24788 e"));
    286         assertEquals(new LatLon(49 + 29. / 60 + 21. / 3600, 19 + 24. / 60 + 38. / 3600), LatLon.parse("49°29'21\" N 19°24'38\" E"));
    287         assertEquals(new LatLon(49 + 29. / 60 + 51. / 3600, 19 + 24. / 60 + 18. / 3600), LatLon.parse("49 29 51, 19 24 18"));
    288         assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLon.parse("49 29, 19 24"));
    289         assertEquals(new LatLon(19 + 24. / 60, 49 + 29. / 60), LatLon.parse("E 49 29, N 19 24"));
    290         assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLon.parse("49° 29; 19° 24"));
    291         assertEquals(new LatLon(49 + 29. / 60, 19 + 24. / 60), LatLon.parse("49° 29; 19° 24"));
    292         assertEquals(new LatLon(49 + 29. / 60, -19 - 24. / 60), LatLon.parse("N 49° 29, W 19° 24"));
    293         assertEquals(new LatLon(-49 - 29.5 / 60, 19 + 24.6 / 60), LatLon.parse("49° 29.5 S, 19° 24.6 E"));
    294         assertEquals(new LatLon(49 + 29.918 / 60, 19 + 15.88 / 60), LatLon.parse("N 49 29.918 E 19 15.88"));
    295         assertEquals(new LatLon(49 + 29.4 / 60, 19 + 24.5 / 60), LatLon.parse("49 29.4 19 24.5"));
    296         assertEquals(new LatLon(-49 - 29.4 / 60, 19 + 24.5 / 60), LatLon.parse("-49 29.4 N -19 24.5 W"));
    297     }
    298 
    299     /**
    300      * Unit test of {@link LatLon#parse} method - invalid case 1.
    301      */
    302     @Test(expected = IllegalArgumentException.class)
    303     public void testParseInvalid1() {
    304         LatLon.parse("48°45'S 23°30'S");
    305     }
    306 
    307     /**
    308      * Unit test of {@link LatLon#parse} method - invalid case 2.
    309      */
    310     @Test(expected = IllegalArgumentException.class)
    311     public void testParseInvalid2() {
    312         LatLon.parse("47°45'N 24°00'S");
    313     }
    314271}
  • trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

    r12438 r12795  
    8484    @Rule
    8585    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    86     public JOSMTestRules test = new JOSMTestRules().platform().timeout(30_000);
     86    public JOSMTestRules test = new JOSMTestRules().platform().projectionNadGrids().timeout(30_000);
    8787
    8888    /**
  • trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java

    r11660 r12795  
    2424    @Rule
    2525    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    26     public JOSMTestRules test = new JOSMTestRules().platform();
     26    public JOSMTestRules test = new JOSMTestRules().projectionNadGrids().platform();
    2727
    2828    /**
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r12760 r12795  
    5555    private boolean platform;
    5656    private boolean useProjection;
     57    private boolean useProjectionNadGrids;
    5758    private boolean commands;
    5859    private boolean allowMemoryManagerLeaks;
     
    154155    public JOSMTestRules projection() {
    155156        useProjection = true;
     157        return this;
     158    }
     159
     160    /**
     161     * Set up loading of NTV2 grit shift files to support projections that need them.
     162     * @return this instance, for easy chaining
     163     */
     164    public JOSMTestRules projectionNadGrids() {
     165        useProjectionNadGrids = true;
    156166        return this;
    157167    }
     
    313323        if (useProjection) {
    314324            Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     325        }
     326
     327        if (useProjectionNadGrids) {
     328            MainApplication.setupNadGridSources();
    315329        }
    316330
Note: See TracChangeset for help on using the changeset viewer.