Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/data/projection
- Timestamp:
- 2020-10-28T20:41:00+01:00 (4 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/data/projection
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/data/projection/CustomProjectionTest.java
r13602 r17275 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertTrue;6 import static org.junit. Assert.fail;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 import static org.junit.jupiter.api.Assertions.fail; 7 7 8 8 import java.util.stream.Stream; 9 9 10 import org.junit. Rule;11 import org.junit.Test; 10 import org.junit.jupiter.api.extension.RegisterExtension; 11 import org.junit.jupiter.api.Test; 12 12 import org.openstreetmap.josm.data.coor.LatLon; 13 13 import org.openstreetmap.josm.data.projection.CustomProjection.Polarity; … … 20 20 * @author Michael Zangl 21 21 */ 22 publicclass CustomProjectionTest {22 class CustomProjectionTest { 23 23 /** 24 24 * Need pref to load pref. 25 25 */ 26 @R ule26 @RegisterExtension 27 27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 28 28 public JOSMTestRules test = new JOSMTestRules().preferences(); … … 33 33 */ 34 34 @Test 35 publicvoid testParseAngle() throws ProjectionConfigurationException {35 void testParseAngle() throws ProjectionConfigurationException { 36 36 assertEquals(0, CustomProjection.parseAngle("0", "xxx"), 1e-10); 37 37 assertEquals(1, CustomProjection.parseAngle("1", "xxx"), 1e-10); … … 86 86 */ 87 87 @Test 88 publicvoid testPolarity() {88 void testPolarity() { 89 89 assertEquals(LatLon.NORTH_POLE, Polarity.NORTH.getLatLon()); 90 90 assertEquals(LatLon.SOUTH_POLE, Polarity.SOUTH.getLatLon()); -
trunk/test/unit/org/openstreetmap/josm/data/projection/EllipsoidTest.java
r11324 r17275 6 6 7 7 import org.junit.Assert; 8 import org.junit.Test; 8 import org.junit.jupiter.api.Test; 9 9 import org.openstreetmap.josm.data.coor.LatLon; 10 10 … … 12 12 * Unit tests for class {@link Ellipsoid}. 13 13 */ 14 publicclass EllipsoidTest {14 class EllipsoidTest { 15 15 16 16 private static final double EPSILON = 1e-8; … … 20 20 */ 21 21 @Test 22 publicvoid testLatLon2Cart2LatLon() {22 void testLatLon2Cart2LatLon() { 23 23 Random r = new SecureRandom(); 24 24 double maxErrLat = 0, maxErrLon = 0; -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java
r16643 r17275 34 34 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 35 35 import org.junit.Assert; 36 import org.junit. Rule;37 import org.junit.Test; 36 import org.junit.jupiter.api.extension.RegisterExtension; 37 import org.junit.jupiter.api.Test; 38 38 import org.openstreetmap.josm.data.Bounds; 39 39 import org.openstreetmap.josm.data.coor.EastNorth; … … 59 59 * of the algorithm, given a certain definition. 60 60 */ 61 publicclass ProjectionRefTest {61 class ProjectionRefTest { 62 62 63 63 private static final String CS2CS_EXE = "cs2cs"; … … 86 86 * Setup test. 87 87 */ 88 @R ule88 @RegisterExtension 89 89 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 90 90 public JOSMTestRules test = new JOSMTestRules().projectionNadGrids().timeout(90_000); … … 373 373 */ 374 374 @Test 375 publicvoid testProjections() throws IOException {375 void testProjections() throws IOException { 376 376 StringBuilder fail = new StringBuilder(); 377 377 Map<String, Set<String>> failingProjs = new HashMap<>(); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionRegressionTest.java
r16643 r17275 19 19 import java.util.stream.Collectors; 20 20 21 import org.junit. BeforeClass;22 import org.junit.Test; 21 import org.junit.jupiter.api.BeforeAll; 22 import org.junit.jupiter.api.Test; 23 23 import org.openstreetmap.josm.JOSMFixture; 24 24 import org.openstreetmap.josm.data.Bounds; … … 39 39 * test data, by running the main method of this class and commit the new data file. 40 40 */ 41 publicclass ProjectionRegressionTest {41 class ProjectionRegressionTest { 42 42 43 43 private static final String PROJECTION_DATA_FILE = "nodist/data/projection/projection-regression-test-data"; … … 136 136 * Setup test. 137 137 */ 138 @Before Class138 @BeforeAll 139 139 public static void setUp() { 140 140 JOSMFixture.createUnitTestFixture().init(); … … 146 146 */ 147 147 @Test 148 publicvoid testNonRegression() throws IOException {148 void testNonRegression() throws IOException { 149 149 List<TestData> allData = readData(); 150 150 Set<String> dataCodes = allData.stream().map(data -> data.code).collect(Collectors.toSet()); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ProjectionTest.java
r16913 r17275 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertTrue; 5 5 6 6 import java.security.SecureRandom; … … 11 11 12 12 import org.junit.Assert; 13 import org.junit.Test; 13 import org.junit.jupiter.api.Test; 14 14 import org.openstreetmap.josm.data.Bounds; 15 15 import org.openstreetmap.josm.data.coor.EastNorth; … … 19 19 * Unit tests for class {@link Projection}. 20 20 */ 21 publicclass ProjectionTest {21 class ProjectionTest { 22 22 23 23 private static final Random rand = new SecureRandom(); … … 30 30 */ 31 31 @Test 32 publicvoid testProjections() {32 void testProjections() { 33 33 error = false; 34 34 text = ""; … … 120 120 */ 121 121 @Test 122 publicvoid testProjs() {122 void testProjs() { 123 123 error2 = false; 124 124 text2 = ""; … … 150 150 Assert.fail(); 151 151 } 152 assertTrue("missing test: "+projIds , projIds.isEmpty());152 assertTrue(projIds.isEmpty(), "missing test: "+projIds); 153 153 } 154 154 … … 170 170 EastNorth en = p.latlon2eastNorth(ll1); 171 171 LatLon ll2 = p.eastNorth2latlon(en); 172 assertTrue(p.toCode() + " at " + ll1 + " is " + ll2 , ll2.isValid());172 assertTrue(ll2.isValid(), p.toCode() + " at " + ll1 + " is " + ll2); 173 173 double dist = ll1.greatCircleDistance(ll2); 174 174 if (dist > eps) { … … 189 189 */ 190 190 @Test 191 publicvoid testSwedishProjections() {191 void testSwedishProjections() { 192 192 for (int code = 3006; code <= 3018; code++) { 193 193 assertTrue(Projections.getProjectionByCode("EPSG:"+code).switchXY()); -
trunk/test/unit/org/openstreetmap/josm/data/projection/ShiftedProjectionTest.java
r12161 r17275 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.util.Comparator; … … 11 11 import java.util.stream.Collectors; 12 12 13 import org.junit.Test; 13 import org.junit.jupiter.api.Test; 14 14 import org.openstreetmap.josm.data.ProjectionBounds; 15 15 import org.openstreetmap.josm.data.coor.EastNorth; … … 21 21 * @author Michael Zangl 22 22 */ 23 publicclass ShiftedProjectionTest {23 class ShiftedProjectionTest { 24 24 private static final class ProjectingBase implements Projecting { 25 25 @Override … … 57 57 */ 58 58 @Test 59 publicvoid testLatlon2eastNorth() {59 void testLatlon2eastNorth() { 60 60 Projecting base = new ProjectingBase(); 61 61 … … 81 81 */ 82 82 @Test 83 publicvoid testEastNorth2latlonClamped() {83 void testEastNorth2latlonClamped() { 84 84 Projecting base = new ProjectingBase(); 85 85 … … 105 105 */ 106 106 @Test 107 publicvoid testGetProjectingsForArea() {107 void testGetProjectingsForArea() { 108 108 Projecting base = new ProjectingBase(); 109 109 ShiftedProjecting shifted = new ShiftedProjecting(base, new EastNorth(5, 7)); … … 124 124 */ 125 125 @Test 126 publicvoid testGetProjectingsForAreaMultiple() {126 void testGetProjectingsForAreaMultiple() { 127 127 Projecting base = new ProjectingBase(); 128 128 ShiftedProjecting shifted = new ShiftedProjecting(base, new EastNorth(5, 7)); -
trunk/test/unit/org/openstreetmap/josm/data/projection/SwissGridTest.java
r16913 r17275 2 2 package org.openstreetmap.josm.data.projection; 3 3 4 import static org.junit. Assert.assertSame;5 import static org.junit. Assert.assertTrue;6 7 import org.junit. BeforeClass;8 import org.junit. Rule;9 import org.junit. Test;4 import static org.junit.jupiter.api.Assertions.assertSame; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 7 import org.junit.jupiter.api.BeforeAll; 8 import org.junit.jupiter.api.Test; 9 import org.junit.jupiter.api.extension.RegisterExtension; 10 10 import org.openstreetmap.josm.data.coor.EastNorth; 11 11 import org.openstreetmap.josm.data.coor.LatLon; … … 17 17 * Unit tests for the Swiss projection grid. 18 18 */ 19 publicclass SwissGridTest {19 class SwissGridTest { 20 20 private static final String SWISS_EPSG_CODE = "EPSG:21781"; 21 21 private final boolean debug = false; … … 24 24 * Setup test. 25 25 */ 26 @R ule26 @RegisterExtension 27 27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 28 28 public JOSMTestRules test = new JOSMTestRules().projectionNadGrids(); … … 31 31 * Setup test. 32 32 */ 33 @Before Class33 @BeforeAll 34 34 public static void setUp() { 35 35 ProjectionRegistry.setProjection(Projections.getProjectionByCode(SWISS_EPSG_CODE)); // Swiss grid … … 79 79 } 80 80 } 81 assertSame(errs. toString(), errs.length(), 0);81 assertSame(errs.length(), 0, errs::toString); 82 82 } 83 83 … … 86 86 */ 87 87 @Test 88 publicvoid testProjReferenceTestAccurate() {88 void testProjReferenceTestAccurate() { 89 89 projReferenceTest(EPSILON_ACCURATE); 90 90 } … … 94 94 */ 95 95 @Test 96 publicvoid testAlatlon2eastNorth() {96 void testAlatlon2eastNorth() { 97 97 LatLon ll = new LatLon(46.518, 6.567); 98 98 EastNorth en = ProjectionRegistry.getProjection().latlon2eastNorth(ll); … … 100 100 System.out.println(en); 101 101 } 102 assertTrue( "Lausanne",Math.abs(en.east() - 533112.13) < 0.1);103 assertTrue( "Lausanne",Math.abs(en.north() - 152227.35) < 0.1);102 assertTrue(Math.abs(en.east() - 533112.13) < 0.1, "Lausanne"); 103 assertTrue(Math.abs(en.north() - 152227.35) < 0.1, "Lausanne"); 104 104 105 105 ll = new LatLon(47.78, 8.58); … … 108 108 System.out.println(en); 109 109 } 110 assertTrue( "Schafouse",Math.abs(en.east() - 685542.97) < 0.1);111 assertTrue( "Schafouse",Math.abs(en.north() - 292783.21) < 0.1);110 assertTrue(Math.abs(en.east() - 685542.97) < 0.1, "Schafouse"); 111 assertTrue(Math.abs(en.north() - 292783.21) < 0.1, "Schafouse"); 112 112 113 113 ll = new LatLon(46.58, 10.48); … … 116 116 System.out.println(en); 117 117 } 118 assertTrue( "Grinson",Math.abs(en.east() - 833066.95) < 0.1);119 assertTrue( "Grinson",Math.abs(en.north() - 163265.32) < 0.1);118 assertTrue(Math.abs(en.east() - 833066.95) < 0.1, "Grinson"); 119 assertTrue(Math.abs(en.north() - 163265.32) < 0.1, "Grinson"); 120 120 121 121 ll = new LatLon(46.0 + 57.0 / 60 + 3.89813884505 / 3600, 7.0 + 26.0 / 60 + 19.076595154147 / 3600); … … 124 124 System.out.println(en); 125 125 } 126 assertTrue( "Berne",Math.abs(en.east() - 600000.0) < 0.1);127 assertTrue( "Berne",Math.abs(en.north() - 200000.0) < 0.1);126 assertTrue(Math.abs(en.east() - 600000.0) < 0.1, "Berne"); 127 assertTrue(Math.abs(en.north() - 200000.0) < 0.1, "Berne"); 128 128 129 129 // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000 … … 133 133 System.out.println(en); 134 134 } 135 assertTrue( "Ref",Math.abs(en.east() - 700000.0) < 0.1);136 assertTrue( "Ref",Math.abs(en.north() - 100000.0) < 0.1);135 assertTrue(Math.abs(en.east() - 700000.0) < 0.1, "Ref"); 136 assertTrue(Math.abs(en.north() - 100000.0) < 0.1, "Ref"); 137 137 } 138 138 … … 141 141 */ 142 142 @Test 143 publicvoid testBeastNorth2latlon() {143 void testBeastNorth2latlon() { 144 144 EastNorth en = new EastNorth(533112.13, 152227.35); 145 145 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); … … 147 147 System.out.println(ll); 148 148 } 149 assertTrue( "Lausanne",Math.abs(ll.lat() - 46.518) < 0.00001);150 assertTrue( "Lausanne",Math.abs(ll.lon() - 6.567) < 0.00001);149 assertTrue(Math.abs(ll.lat() - 46.518) < 0.00001, "Lausanne"); 150 assertTrue(Math.abs(ll.lon() - 6.567) < 0.00001, "Lausanne"); 151 151 152 152 en = new EastNorth(685542.97, 292783.21); … … 155 155 System.out.println(ll); 156 156 } 157 assertTrue( "Schafouse",Math.abs(ll.lat() - 47.78) < 0.00001);158 assertTrue( "Schafouse",Math.abs(ll.lon() - 8.58) < 0.00001);157 assertTrue(Math.abs(ll.lat() - 47.78) < 0.00001, "Schafouse"); 158 assertTrue(Math.abs(ll.lon() - 8.58) < 0.00001, "Schafouse"); 159 159 160 160 en = new EastNorth(833066.95, 163265.32); … … 163 163 System.out.println(ll); 164 164 } 165 assertTrue( "Grinson",Math.abs(ll.lat() - 46.58) < 0.00001);166 assertTrue( "Grinson",Math.abs(ll.lon() - 10.48) < 0.00001);165 assertTrue(Math.abs(ll.lat() - 46.58) < 0.00001, "Grinson"); 166 assertTrue(Math.abs(ll.lon() - 10.48) < 0.00001, "Grinson"); 167 167 168 168 en = new EastNorth(600000.0, 200000.0); … … 171 171 System.out.println(ll); 172 172 } 173 assertTrue( "Berne",Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001);174 assertTrue( "Berne",Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001);173 assertTrue(Math.abs(ll.lat() - (46.0 + 57.0 / 60 + 3.89813884505 / 3600)) < 0.00001, "Berne"); 174 assertTrue(Math.abs(ll.lon() - (7.0 + 26.0 / 60 + 19.076595154147 / 3600)) < 0.00001, "Berne"); 175 175 176 176 // http://geodesy.geo.admin.ch/reframe/lv03towgs84?easting=700000&northing=100000 … … 180 180 System.out.println(ll); 181 181 } 182 assertTrue( "Ref",Math.abs(ll.lat() - 46.04412093223244) < 0.00001);183 assertTrue( "Ref",Math.abs(ll.lon() - 8.730497366167727) < 0.00001);182 assertTrue(Math.abs(ll.lat() - 46.04412093223244) < 0.00001, "Ref"); 183 assertTrue(Math.abs(ll.lon() - 8.730497366167727) < 0.00001, "Ref"); 184 184 } 185 185 … … 188 188 */ 189 189 @Test 190 publicvoid testCsendandreturn() {190 void testCsendandreturn() { 191 191 EastNorth en = new EastNorth(533111.69, 152227.85); 192 192 LatLon ll = ProjectionRegistry.getProjection().eastNorth2latlon(en); … … 198 198 System.out.println(en.north() - en2.north()); 199 199 } 200 assertTrue( "Lausanne",Math.abs(en.east() - en2.east()) < 0.002);201 assertTrue( "Lausanne",Math.abs(en.north() - en2.north()) < 0.002);200 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Lausanne"); 201 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Lausanne"); 202 202 203 203 en = new EastNorth(685544.16, 292782.91); … … 210 210 System.out.println(en.north() - en2.north()); 211 211 } 212 assertTrue( "Schafouse",Math.abs(en.east() - en2.east()) < 0.002);213 assertTrue( "Schafouse",Math.abs(en.north() - en2.north()) < 0.002);212 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Schafouse"); 213 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Schafouse"); 214 214 215 215 en = new EastNorth(833068.04, 163265.39); … … 222 222 System.out.println(en.north() - en2.north()); 223 223 } 224 assertTrue( "Grinson",Math.abs(en.east() - en2.east()) < 0.002);225 assertTrue( "Grinson",Math.abs(en.north() - en2.north()) < 0.002);224 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Grinson"); 225 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Grinson"); 226 226 227 227 en = new EastNorth(600000.0, 200000.0); … … 234 234 System.out.println(en.north() - en2.north()); 235 235 } 236 assertTrue( "Berne",Math.abs(en.east() - en2.east()) < 0.002);237 assertTrue( "Berne",Math.abs(en.north() - en2.north()) < 0.002);236 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Berne"); 237 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Berne"); 238 238 239 239 en = new EastNorth(700000.0, 100000.0); … … 246 246 System.out.println(en.north() - en2.north()); 247 247 } 248 assertTrue( "Ref",Math.abs(en.east() - en2.east()) < 0.002);249 assertTrue( "Ref",Math.abs(en.north() - en2.north()) < 0.002);248 assertTrue(Math.abs(en.east() - en2.east()) < 0.002, "Ref"); 249 assertTrue(Math.abs(en.north() - en2.north()) < 0.002, "Ref"); 250 250 } 251 251 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/proj/LonLatTest.java
r11931 r17275 2 2 package org.openstreetmap.josm.data.projection.proj; 3 3 4 import static org.junit. Assert.assertFalse;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 5 6 import org.junit. Rule;7 import org.junit.Test; 6 import org.junit.jupiter.api.extension.RegisterExtension; 7 import org.junit.jupiter.api.Test; 8 8 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 9 … … 13 13 * Tests for {@link LonLat}. 14 14 */ 15 publicclass LonLatTest {15 class LonLatTest { 16 16 /** 17 17 * Setup rule. 18 18 */ 19 @R ule19 @RegisterExtension 20 20 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 21 21 public JOSMTestRules test = new JOSMTestRules(); … … 25 25 */ 26 26 @Test 27 publicvoid testLonIsLinearToEast() {27 void testLonIsLinearToEast() { 28 28 assertFalse(new LonLat().lonIsLinearToEast()); 29 29 } -
trunk/test/unit/org/openstreetmap/josm/data/projection/proj/MercatorTest.java
r11931 r17275 2 2 package org.openstreetmap.josm.data.projection.proj; 3 3 4 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertTrue; 5 5 6 import org.junit. Rule;7 import org.junit.Test; 6 import org.junit.jupiter.api.extension.RegisterExtension; 7 import org.junit.jupiter.api.Test; 8 8 import org.openstreetmap.josm.testutils.JOSMTestRules; 9 9 … … 13 13 * Tests for {@link Mercator}. 14 14 */ 15 publicclass MercatorTest {15 class MercatorTest { 16 16 /** 17 17 * Setup rule. 18 18 */ 19 @R ule19 @RegisterExtension 20 20 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 21 21 public JOSMTestRules test = new JOSMTestRules(); … … 25 25 */ 26 26 @Test 27 publicvoid testLonIsLinearToEast() {27 void testLonIsLinearToEast() { 28 28 assertTrue(new Mercator().lonIsLinearToEast()); 29 29 }
Note:
See TracChangeset
for help on using the changeset viewer.