Changeset 12795 in josm


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

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

Location:
trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/data/coor/conversion/LatLonParser.java

    r12792 r12795  
    5454        private double lat = Double.NaN;
    5555        private double lon = Double.NaN;
     56    }
     57
     58    private LatLonParser() {
     59        // private constructor
    5660    }
    5761
  • trunk/src/org/openstreetmap/josm/data/projection/ProjectionCLI.java

    r12792 r12795  
    3333    public static final ProjectionCLI INSTANCE = new ProjectionCLI();
    3434
    35     private boolean argInverse = false;
    36     private boolean argSwitchInput = false;
    37     private boolean argSwitchOutput = false;
     35    private boolean argInverse = false;         // NOPMD
     36    private boolean argSwitchInput = false;     // NOPMD
     37    private boolean argSwitchOutput = false;    // NOPMD
    3838
    3939    @Override
     
    6262                argSwitchOutput = true;
    6363                break;
     64            default:
     65                // ignore
    6466            }
    6567        }
     
    127129                "    EOF\n"+
    128130                "       => 1250371.1334500168 6545331.055189664\n" +
    129                 "          -1.3208998232319113E7 4486401.160664663\n" +
    130                 "";
     131                "          -1.3208998232319113E7 4486401.160664663\n";
    131132    }
    132133
  • trunk/src/org/openstreetmap/josm/gui/MainApplication.java

    r12792 r12795  
    978978        Main.toolbar = toolbar;
    979979        ProjectionPreference.setProjection();
    980         NTV2GridShiftFileWrapper.registerNTV2GridShiftFileSource(
    981                 NTV2GridShiftFileWrapper.NTV2_SOURCE_PRIORITY_LOCAL,
    982                 NTV2Proj4DirGridShiftFileSource.getInstance());
    983         NTV2GridShiftFileWrapper.registerNTV2GridShiftFileSource(
    984                 NTV2GridShiftFileWrapper.NTV2_SOURCE_PRIORITY_DOWNLOAD,
    985                 JOSM_WEBSITE_NTV2_SOURCE);
     980        setupNadGridSources();
    986981        GuiHelper.translateJavaInternalMessages();
    987982        preConstructorInit();
     
    10371032            RepaintManager.setCurrentManager(new CheckThreadViolationRepaintManager());
    10381033        }
     1034    }
     1035
     1036    /**
     1037     * Setup the sources for NTV2 grid shift files for projection support.
     1038     * @since 12795
     1039     */
     1040    public static void setupNadGridSources() {
     1041        NTV2GridShiftFileWrapper.registerNTV2GridShiftFileSource(
     1042                NTV2GridShiftFileWrapper.NTV2_SOURCE_PRIORITY_LOCAL,
     1043                NTV2Proj4DirGridShiftFileSource.getInstance());
     1044        NTV2GridShiftFileWrapper.registerNTV2GridShiftFileSource(
     1045                NTV2GridShiftFileWrapper.NTV2_SOURCE_PRIORITY_DOWNLOAD,
     1046                JOSM_WEBSITE_NTV2_SOURCE);
    10391047    }
    10401048
  • 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.