Changeset 17275 in josm for trunk/test/unit/org/openstreetmap/josm/tools
- Timestamp:
- 2020-10-28T20:41:00+01:00 (5 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/tools
- Files:
-
- 44 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/tools/AlphanumComparatorTest.java
r11405 r17275 2 2 package org.openstreetmap.josm.tools; 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.Arrays; … … 8 8 import java.util.List; 9 9 10 import org.junit.Test; 10 import org.junit.jupiter.api.Test; 11 11 12 12 /** 13 13 * Unit tests of {@link AlphanumComparator}. 14 14 */ 15 publicclass AlphanumComparatorTest {15 class AlphanumComparatorTest { 16 16 17 17 /** … … 19 19 */ 20 20 @Test 21 publicvoid testNumeric() {21 void testNumeric() { 22 22 List<String> lst = Arrays.asList("1", "20", "-1", "00999", "100"); 23 23 Collections.sort(lst, AlphanumComparator.getInstance()); … … 29 29 */ 30 30 @Test 31 publicvoid testMixed() {31 void testMixed() { 32 32 List<String> lst = Arrays.asList("b1", "b20", "a5", "a00999", "a100"); 33 33 Collections.sort(lst, AlphanumComparator.getInstance()); -
trunk/test/unit/org/openstreetmap/josm/tools/CheckParameterUtilTest.java
r16182 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import org.junit. Rule;5 import org.junit.Test; 4 import org.junit.jupiter.api.extension.RegisterExtension; 5 import org.junit.jupiter.api.Test; 6 6 import org.openstreetmap.josm.testutils.JOSMTestRules; 7 7 … … 12 12 * Unit tests of {@link CheckParameterUtil} class. 13 13 */ 14 publicclass CheckParameterUtilTest {14 class CheckParameterUtilTest { 15 15 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(); … … 26 26 */ 27 27 @Test 28 publicvoid testUtilityClass() throws ReflectiveOperationException {28 void testUtilityClass() throws ReflectiveOperationException { 29 29 UtilityClassTestUtil.assertUtilityClassWellDefined(CheckParameterUtil.class); 30 30 } -
trunk/test/unit/org/openstreetmap/josm/tools/ColorHelperTest.java
r16319 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 6 7 7 import java.awt.Color; 8 8 9 import org.junit.Test; 9 import org.junit.jupiter.api.Test; 10 10 11 11 /** 12 12 * Unit tests for class {@link ColorHelper}. 13 13 */ 14 publicclass ColorHelperTest {14 class ColorHelperTest { 15 15 16 16 /** … … 18 18 */ 19 19 @Test 20 publicvoid testHtml2color() {20 void testHtml2color() { 21 21 assertNull(ColorHelper.html2color("")); 22 22 assertNull(ColorHelper.html2color("xyz")); … … 33 33 */ 34 34 @Test 35 publicvoid testColor2html() {35 void testColor2html() { 36 36 assertNull(ColorHelper.color2html(null)); 37 37 assertEquals("#FF0000", ColorHelper.color2html(Color.RED)); … … 46 46 */ 47 47 @Test 48 publicvoid testGetForegroundColor() {48 void testGetForegroundColor() { 49 49 assertNull(ColorHelper.getForegroundColor(null)); 50 50 assertEquals(Color.WHITE, ColorHelper.getForegroundColor(Color.BLACK)); … … 59 59 */ 60 60 @Test 61 publicvoid testColorFloat2int() {61 void testColorFloat2int() { 62 62 assertNull(ColorHelper.float2int(null)); 63 63 assertEquals(255, (int) ColorHelper.float2int(-1.0f)); … … 74 74 */ 75 75 @Test 76 publicvoid testColorInt2float() {76 void testColorInt2float() { 77 77 assertNull(ColorHelper.int2float(null)); 78 78 assertEquals(1.0f, ColorHelper.int2float(-1), 1e-3); … … 89 89 */ 90 90 @Test 91 publicvoid testAlphaMultiply() {91 void testAlphaMultiply() { 92 92 final Color color = new Color(0x12345678, true); 93 93 assertEquals(new Color(0x12345678, true), ColorHelper.alphaMultiply(color, 1f)); … … 99 99 */ 100 100 @Test 101 publicvoid testComplement() {101 void testComplement() { 102 102 assertEquals(Color.cyan, ColorHelper.complement(Color.red)); 103 103 assertEquals(Color.red, ColorHelper.complement(Color.cyan)); -
trunk/test/unit/org/openstreetmap/josm/tools/ColorScaleTest.java
r9669 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNull; 6 6 7 7 import java.awt.Color; 8 8 9 import org.junit.Test; 9 import org.junit.jupiter.api.Test; 10 10 11 11 /** 12 12 * Unit tests for class {@link ColorScale}. 13 13 */ 14 publicclass ColorScaleTest {14 class ColorScaleTest { 15 15 16 16 /** … … 18 18 */ 19 19 @Test 20 publicvoid testHSBScale() {20 void testHSBScale() { 21 21 final ColorScale scale = ColorScale.createHSBScale(256); 22 22 assertEquals(new Color(255, 0, 0), scale.getColor(0)); -
trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
r16407 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.io.IOException; … … 11 11 import java.util.TimeZone; 12 12 13 import org.junit. Before;14 import org.junit. Rule;15 import org.junit. Test;13 import org.junit.jupiter.api.BeforeEach; 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension; 16 16 import org.openstreetmap.josm.io.ChangesetClosedException; 17 17 import org.openstreetmap.josm.io.IllegalDataException; … … 31 31 * Unit tests of {@link ExceptionUtil} class. 32 32 */ 33 publicclass ExceptionUtilTest {33 class ExceptionUtilTest { 34 34 35 35 /** 36 36 * Setup rule. 37 37 */ 38 @R ule38 @RegisterExtension 39 39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 40 40 public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI(); … … 49 49 * @throws Exception in case of error 50 50 */ 51 @Before 51 @BeforeEach 52 52 public void setUp() throws Exception { 53 53 OsmApi api = OsmApi.getOsmApi(); … … 63 63 */ 64 64 @Test 65 publicvoid testExplainBadRequest() {65 void testExplainBadRequest() { 66 66 assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br></html>", 67 67 ExceptionUtil.explainBadRequest(new OsmApiException(""))); … … 94 94 */ 95 95 @Test 96 publicvoid testExplainBandwidthLimitExceeded() {96 void testExplainBandwidthLimitExceeded() { 97 97 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. "+ 98 98 "The server replied<br>the following error code and the following error message:<br>"+ … … 105 105 */ 106 106 @Test 107 publicvoid testExplainChangesetClosedException() {107 void testExplainChangesetClosedException() { 108 108 assertEquals("<html>Failed to upload to changeset <strong>0</strong><br>because it has already been closed on ?.", 109 109 ExceptionUtil.explainChangesetClosedException(new ChangesetClosedException(""))); … … 117 117 */ 118 118 @Test 119 publicvoid testExplainClientTimeout() {119 void testExplainClientTimeout() { 120 120 assertEquals("<html>Communication with the OSM server '"+baseUrl+"' timed out. Please retry later.</html>", 121 121 ExceptionUtil.explainClientTimeout(new OsmApiException(""))); … … 126 126 */ 127 127 @Test 128 publicvoid testExplainConflict() {128 void testExplainConflict() { 129 129 int code = HttpURLConnection.HTTP_CONFLICT; 130 130 assertEquals("<html>The server reported that it has detected a conflict.</html>", … … 146 146 */ 147 147 @Test 148 publicvoid testExplainException() {148 void testExplainException() { 149 149 assertEquals("ResponseCode=0", 150 150 ExceptionUtil.explainException(new OsmApiException(""))); … … 161 161 */ 162 162 @Test 163 publicvoid testExplainFailedAuthorisation() {163 void testExplainFailedAuthorisation() { 164 164 assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+ 165 165 "'The server replied an error with code 0.'</html>", … … 183 183 */ 184 184 @Test 185 publicvoid testExplainFailedOAuthAuthorisation() {185 void testExplainFailedOAuthAuthorisation() { 186 186 assertEquals("<html>Authorisation at the OSM server with the OAuth token 'null' failed.<br>"+ 187 187 "The token is not authorised to access the protected resource<br>'unknown'.<br>"+ … … 198 198 */ 199 199 @Test 200 publicvoid testExplainFailedBasicAuthentication() {200 void testExplainFailedBasicAuthentication() { 201 201 assertEquals("<html>Authentication at the OSM server with the username '"+user+"' failed.<br>"+ 202 202 "Please check the username and the password in the JOSM preferences.</html>", … … 208 208 */ 209 209 @Test 210 publicvoid testExplainFailedOAuthAuthentication() {210 void testExplainFailedOAuthAuthentication() { 211 211 assertEquals("<html>Authentication at the OSM server with the OAuth token 'null' failed.<br>"+ 212 212 "Please launch the preferences dialog and retrieve another OAuth token.</html>", … … 218 218 */ 219 219 @Test 220 publicvoid testExplainGenericOsmApiException() {220 void testExplainGenericOsmApiException() { 221 221 assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+ 222 222 "the following error code and the following error message:<br><strong>Error code:<strong> 0<br>"+ … … 239 239 */ 240 240 @Test 241 publicvoid testExplainGoneForUnknownPrimitive() {241 void testExplainGoneForUnknownPrimitive() { 242 242 assertEquals("<html>The server reports that an object is deleted.<br>"+ 243 243 "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "+ … … 251 251 */ 252 252 @Test 253 publicvoid testExplainInternalServerError() {253 void testExplainInternalServerError() { 254 254 assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+ 255 255 "This is most likely a temporary problem. Please try again later.</html>", … … 261 261 */ 262 262 @Test 263 publicvoid testExplainMissingOAuthAccessTokenException() {263 void testExplainMissingOAuthAccessTokenException() { 264 264 assertEquals("<html>Failed to authenticate at the OSM server 'http://fake.xxx/api'.<br>"+ 265 265 "You are using OAuth to authenticate but currently there is no<br>OAuth Access Token configured.<br>"+ … … 272 272 */ 273 273 @Test 274 publicvoid testExplainNestedIllegalDataException() {274 void testExplainNestedIllegalDataException() { 275 275 assertEquals("<html>Failed to download data. Its format is either unsupported, ill-formed, and/or inconsistent.<br><br>"+ 276 276 "Details (untranslated): null</html>", … … 286 286 */ 287 287 @Test 288 publicvoid testExplainNestedIOException() {288 void testExplainNestedIOException() { 289 289 assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+ 290 290 "due to a problem with transferring data.<br>Details (untranslated): null</html>", … … 300 300 */ 301 301 @Test 302 publicvoid testExplainNestedSocketException() {302 void testExplainNestedSocketException() { 303 303 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+ 304 304 "Please check your internet connection.</html>", … … 310 310 */ 311 311 @Test 312 publicvoid testExplainNestedUnknownHostException() {312 void testExplainNestedUnknownHostException() { 313 313 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+ 314 314 "Host name '"+host+"' could not be resolved. <br>"+ … … 321 321 */ 322 322 @Test 323 publicvoid testExplainNotFound() {323 void testExplainNotFound() { 324 324 assertEquals("<html>The OSM server '"+baseUrl+"' does not know about an object<br>"+ 325 325 "you tried to read, update, or delete. Either the respective object<br>"+ … … 333 333 */ 334 334 @Test 335 publicvoid testExplainOfflineAccessException() {335 void testExplainOfflineAccessException() { 336 336 assertEquals("<html>Failed to download data.<br><br>Details: null</html>", 337 337 ExceptionUtil.explainOfflineAccessException(new OsmApiException(""))); … … 344 344 */ 345 345 @Test 346 publicvoid testExplainOsmApiInitializationException() {346 void testExplainOsmApiInitializationException() { 347 347 assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+ 348 348 "Check the server URL in your preferences and your internet connection.</html>", … … 354 354 */ 355 355 @Test 356 publicvoid testExplainOsmTransferException() {356 void testExplainOsmTransferException() { 357 357 assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'<br>"+ 358 358 "for security reasons. This is most likely because you are running<br>"+ … … 410 410 */ 411 411 @Test 412 publicvoid testExplainPreconditionFailed() {412 void testExplainPreconditionFailed() { 413 413 int code = HttpURLConnection.HTTP_PRECON_FAILED; 414 414 assertEquals("<html>Uploading to the server <strong>failed</strong> because your current<br>dataset violates a precondition.<br>"+ -
trunk/test/unit/org/openstreetmap/josm/tools/ExifReaderTest.java
r16006 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertNotNull;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 6 7 7 import java.io.File; … … 12 12 import java.util.Date; 13 13 14 import org.junit. Before;15 import org.junit. Rule;16 import org.junit. Test;14 import org.junit.jupiter.api.BeforeEach; 15 import org.junit.jupiter.api.Test; 16 import org.junit.jupiter.api.extension.RegisterExtension; 17 17 import org.openstreetmap.josm.TestUtils; 18 18 import org.openstreetmap.josm.data.coor.LatLon; … … 27 27 * @since 6209 28 28 */ 29 publicclass ExifReaderTest {29 class ExifReaderTest { 30 30 /** 31 31 * Set the timezone and timeout. 32 32 */ 33 @R ule33 @RegisterExtension 34 34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 35 35 public JOSMTestRules test = new JOSMTestRules(); … … 40 40 * Setup test 41 41 */ 42 @Before 42 @BeforeEach 43 43 public void setUp() { 44 44 directionSampleFile = new File("nodist/data/exif-example_direction.jpg"); … … 51 51 */ 52 52 @Test 53 publicvoid testReadTime() throws ParseException {53 void testReadTime() throws ParseException { 54 54 Date date = ExifReader.readTime(directionSampleFile); 55 55 doTest("2010-05-15T17:12:05.000", date); … … 61 61 */ 62 62 @Test 63 publicvoid testReadTimeSubSecond1() throws ParseException {63 void testReadTimeSubSecond1() throws ParseException { 64 64 Date date = ExifReader.readTime(new File("nodist/data/IMG_20150711_193419.jpg")); 65 65 doTest("2015-07-11T19:34:19.100", date); … … 78 78 */ 79 79 @Test 80 publicvoid testReadOrientation() {80 void testReadOrientation() { 81 81 Integer orientation = ExifReader.readOrientation(orientationSampleFile); 82 82 assertEquals(Integer.valueOf(6), orientation); … … 87 87 */ 88 88 @Test 89 publicvoid testReadLatLon() {89 void testReadLatLon() { 90 90 LatLon latlon = ExifReader.readLatLon(directionSampleFile); 91 91 assertNotNull(latlon); … … 99 99 */ 100 100 @Test 101 publicvoid testReadDirection() {101 void testReadDirection() { 102 102 assertEquals(Double.valueOf(46.5), ExifReader.readDirection(directionSampleFile)); 103 103 } … … 107 107 */ 108 108 @Test 109 publicvoid testReadSpeed() {109 void testReadSpeed() { 110 110 assertEquals(Double.valueOf(12.3), ExifReader.readSpeed(new File("nodist/data/exif-example_speed_ele.jpg"))); 111 111 } … … 115 115 */ 116 116 @Test 117 publicvoid testReadElevation() {117 void testReadElevation() { 118 118 assertEquals(Double.valueOf(23.4), ExifReader.readElevation(new File("nodist/data/exif-example_speed_ele.jpg"))); 119 119 } … … 124 124 */ 125 125 @Test 126 publicvoid testTicket11685() throws IOException {126 void testTicket11685() throws IOException { 127 127 doTestFile("2015-11-08T15:33:27.500", 11685, "2015-11-08_15-33-27-Xiaomi_YI-Y0030832.jpg"); 128 128 } … … 133 133 */ 134 134 @Test 135 publicvoid testTicket14209() throws IOException {135 void testTicket14209() throws IOException { 136 136 doTestFile("2017-01-16T18:27:00.000", 14209, "0MbEfj1S--.1.jpg"); 137 137 doTestFile("2016-08-13T19:51:13.000", 14209, "7VWFOryj--.1.jpg"); -
trunk/test/unit/org/openstreetmap/josm/tools/FontsManagerTest.java
r16182 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.fail;4 import static org.junit.jupiter.api.Assertions.fail; 5 5 6 6 import java.awt.Font; 7 7 import java.awt.GraphicsEnvironment; 8 8 9 import org.junit. Rule;10 import org.junit.Test; 9 import org.junit.jupiter.api.extension.RegisterExtension; 10 import org.junit.jupiter.api.Test; 11 11 import org.openstreetmap.josm.testutils.JOSMTestRules; 12 12 … … 17 17 * Unit tests of {@link FontsManager} class. 18 18 */ 19 publicclass FontsManagerTest {19 class FontsManagerTest { 20 20 21 21 /** 22 22 * Setup test. 23 23 */ 24 @R ule24 @RegisterExtension 25 25 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 26 26 public JOSMTestRules test = new JOSMTestRules(); … … 30 30 */ 31 31 @Test 32 publicvoid testFontsManager() {32 void testFontsManager() { 33 33 FontsManager.initialize(); 34 34 boolean found = false; … … 49 49 */ 50 50 @Test 51 publicvoid testUtilityClass() throws ReflectiveOperationException {51 void testUtilityClass() throws ReflectiveOperationException { 52 52 UtilityClassTestUtil.assertUtilityClassWellDefined(FontsManager.class); 53 53 } -
trunk/test/unit/org/openstreetmap/josm/tools/GeoUrlToBoundsTest.java
r16618 r17275 5 5 import static org.hamcrest.MatcherAssert.assertThat; 6 6 import static org.hamcrest.core.Is.is; 7 import static org.junit.jupiter.api.Assertions.assertThrows; 7 8 8 import org.junit.Test; 9 import org.junit.jupiter.api.Test; 9 10 10 11 /** 11 12 * Unit tests of {@link GeoUrlToBoundsTest} class. 12 13 */ 13 publicclass GeoUrlToBoundsTest {14 class GeoUrlToBoundsTest { 14 15 15 16 /** … … 17 18 */ 18 19 @Test 19 publicvoid testParse() {20 void testParse() { 20 21 assertThat( 21 22 GeoUrlToBounds.parse("geo:12.34,56.78?z=9"), … … 28 29 */ 29 30 @Test 30 publicvoid testParseWithoutZoom() {31 void testParseWithoutZoom() { 31 32 assertThat( 32 33 GeoUrlToBounds.parse("geo:12.34,56.78"), … … 43 44 */ 44 45 @Test 45 publicvoid testParseCrsUncertainty() {46 void testParseCrsUncertainty() { 46 47 assertThat( 47 48 GeoUrlToBounds.parse("geo:60.00000,17.000000;crs=wgs84"), … … 62 63 */ 63 64 @Test 64 publicvoid testInvalid() {65 void testInvalid() { 65 66 assertThat(GeoUrlToBounds.parse("geo:foo"), nullValue()); 66 67 assertThat(GeoUrlToBounds.parse("geo:foo,bar"), nullValue()); … … 70 71 * Tests parsing null. 71 72 */ 72 @Test (expected = IllegalArgumentException.class)73 publicvoid testNull() {74 GeoUrlToBounds.parse(null); 73 @Test 74 void testNull() { 75 assertThrows(IllegalArgumentException.class, () -> GeoUrlToBounds.parse(null)); 75 76 } 76 77 } -
trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
r15069 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotEquals;7 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotEquals; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 8 9 9 import java.io.InputStream; … … 15 15 16 16 import org.junit.Assert; 17 import org.junit. Rule;18 import org.junit.Test; 17 import org.junit.jupiter.api.extension.RegisterExtension; 18 import org.junit.jupiter.api.Test; 19 19 import org.openstreetmap.josm.TestUtils; 20 20 import org.openstreetmap.josm.data.coor.EastNorth; … … 35 35 * Unit tests of {@link Geometry} class. 36 36 */ 37 publicclass GeometryTest {37 class GeometryTest { 38 38 /** 39 39 * Primitives need preferences and projection. 40 40 */ 41 @R ule41 @RegisterExtension 42 42 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 43 43 public JOSMTestRules test = new JOSMTestRules().preferences().projection(); … … 47 47 */ 48 48 @Test 49 publicvoid testLineLineIntersection() {49 void testLineLineIntersection() { 50 50 EastNorth p1 = new EastNorth(-9477809.106349014, 1.5392960539974203E7); 51 51 EastNorth p2 = new EastNorth(-9477813.789091509, 1.5392954297092048E7); … … 81 81 */ 82 82 @Test 83 publicvoid testClosedWayArea() throws Exception {83 void testClosedWayArea() throws Exception { 84 84 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) { 85 85 DataSet ds = OsmReader.parseDataSet(in, null); … … 97 97 */ 98 98 @Test 99 publicvoid testMultipolygonArea() throws Exception {99 void testMultipolygonArea() throws Exception { 100 100 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) { 101 101 DataSet ds = OsmReader.parseDataSet(in, null); … … 112 112 */ 113 113 @Test 114 publicvoid testAreaAndPerimeter() throws Exception {114 void testAreaAndPerimeter() throws Exception { 115 115 try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) { 116 116 DataSet ds = OsmReader.parseDataSet(in, null); … … 127 127 */ 128 128 @Test 129 publicvoid testRightAngle() {129 void testRightAngle() { 130 130 Node n1 = new Node(1); 131 131 Node n2 = new Node(2); … … 159 159 */ 160 160 @Test 161 publicvoid testCentroidEN() {161 void testCentroidEN() { 162 162 EastNorth en1 = new EastNorth(100, 200); 163 163 EastNorth en2 = new EastNorth(150, 400); … … 173 173 */ 174 174 @Test 175 publicvoid testPolygonIntersectionTriangles() {175 void testPolygonIntersectionTriangles() { 176 176 Node node1 = new Node(new LatLon(0.0, 1.0)); 177 177 Node node2 = new Node(new LatLon(0.0, 2.0)); … … 204 204 */ 205 205 @Test 206 publicvoid testPolygonIntersectionVShapes() {206 void testPolygonIntersectionVShapes() { 207 207 Node node1 = new Node(new LatLon(1.0, 1.0)); 208 208 Node node2 = new Node(new LatLon(2.0, 2.0)); … … 234 234 */ 235 235 @Test 236 publicvoid testIsPolygonInsideMultiPolygon() {236 void testIsPolygonInsideMultiPolygon() { 237 237 Node node1 = new Node(new LatLon(1.01, 1.0)); 238 238 Node node2 = new Node(new LatLon(1.01, 1.1)); … … 268 268 */ 269 269 @Test 270 publicvoid testFilterInsideMultiPolygon() {270 void testFilterInsideMultiPolygon() { 271 271 Node node1 = new Node(new LatLon(1.01, 1.0)); 272 272 Node node2 = new Node(new LatLon(1.01, 1.1)); … … 310 310 */ 311 311 @Test 312 publicvoid testGetDistance() {312 void testGetDistance() { 313 313 Node node1 = new Node(new LatLon(0, 0)); 314 314 Node node2 = new Node(new LatLon(0.1, 1)); … … 361 361 */ 362 362 @Test 363 publicvoid testGetClosestPrimitive() {363 void testGetClosestPrimitive() { 364 364 Node node1 = new Node(new LatLon(0, 0)); 365 365 Node node2 = new Node(new LatLon(0.1, 1)); … … 380 380 */ 381 381 @Test 382 publicvoid testGetFurthestPrimitive() {382 void testGetFurthestPrimitive() { 383 383 Node node1 = new Node(new LatLon(0, 0)); 384 384 Node node2 = new Node(new LatLon(0, 1.1)); … … 407 407 */ 408 408 @Test 409 publicvoid testGetClosestWaySegment() {409 void testGetClosestWaySegment() { 410 410 Node node1 = new Node(new LatLon(0, 0)); 411 411 Node node2 = new Node(new LatLon(0, 1)); … … 423 423 */ 424 424 @Test 425 publicvoid testGetDistanceSegmentSegment() {425 void testGetDistanceSegmentSegment() { 426 426 Node node1 = new Node(new LatLon(2.0, 2.0)); 427 427 Node node2 = new Node(new LatLon(2.0, 3.0)); -
trunk/test/unit/org/openstreetmap/josm/tools/I18nTest.java
r11404 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 import org.junit.Test; 6 import org.junit.jupiter.api.Test; 7 7 8 8 /** 9 9 * Unit tests of {@link I18n}. 10 10 */ 11 publicclass I18nTest {11 class I18nTest { 12 12 13 13 /** … … 15 15 */ 16 16 @Test 17 publicvoid testEscape() {17 void testEscape() { 18 18 String foobar = "{foo'bar}"; 19 19 assertEquals("'{'foo''bar'}'", I18n.escape(foobar)); -
trunk/test/unit/org/openstreetmap/josm/tools/ImageResizeModeTest.java
r17151 r17275 8 8 import java.awt.Dimension; 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.testutils.JOSMTestRules; 13 13 … … 17 17 * Unit tests of {@link ImageResizeMode} class. 18 18 */ 19 publicclass ImageResizeModeTest {19 class ImageResizeModeTest { 20 20 21 21 /** 22 22 * Setup test. 23 23 */ 24 @R ule24 @RegisterExtension 25 25 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 26 26 public JOSMTestRules test = new JOSMTestRules().preferences(); … … 33 33 */ 34 34 @Test 35 publicvoid testComputeDimensionAuto() {35 void testComputeDimensionAuto() { 36 36 assertThrows(IllegalArgumentException.class, () -> ImageResizeMode.AUTO.computeDimension(new Dimension(0, 0), image)); 37 37 assertEquals(new Dimension(64, 48), ImageResizeMode.AUTO.computeDimension(ImageResource.DEFAULT_DIMENSION, image)); … … 47 47 */ 48 48 @Test 49 publicvoid testComputeDimensionBounded() {49 void testComputeDimensionBounded() { 50 50 assertEquals(new Dimension(64, 48), ImageResizeMode.BOUNDED.computeDimension(ImageResource.DEFAULT_DIMENSION, image)); 51 51 assertEquals(new Dimension(64, 48), ImageResizeMode.BOUNDED.computeDimension(new Dimension(-1, -1), image)); … … 68 68 */ 69 69 @Test 70 publicvoid testComputeDimensionPadded() {70 void testComputeDimensionPadded() { 71 71 assertThrows(IllegalArgumentException.class, () -> ImageResizeMode.PADDED.computeDimension(new Dimension(0, 0), image)); 72 72 assertThrows(IllegalArgumentException.class, () -> ImageResizeMode.PADDED.computeDimension(ImageResource.DEFAULT_DIMENSION, image)); … … 82 82 */ 83 83 @Test 84 publicvoid testCacheKey() {84 void testCacheKey() { 85 85 assertEquals(0x00180018, ImageResizeMode.AUTO.cacheKey(ImageProvider.ImageSizes.LARGEICON.getImageDimension())); 86 86 assertEquals(0x10180018, ImageResizeMode.BOUNDED.cacheKey(ImageProvider.ImageSizes.LARGEICON.getImageDimension())); -
trunk/test/unit/org/openstreetmap/josm/tools/JosmDecimalFormatSymbolsProviderTest.java
r17155 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertTrue; 6 6 import static org.junit.Assume.assumeTrue; 7 7 … … 10 10 import java.util.stream.Stream; 11 11 12 import org.junit. Rule;13 import org.junit.Test; 12 import org.junit.jupiter.api.extension.RegisterExtension; 13 import org.junit.jupiter.api.Test; 14 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 15 … … 19 19 * Unit tests of {@link JosmDecimalFormatSymbolsProvider}. 20 20 */ 21 publicclass JosmDecimalFormatSymbolsProviderTest {21 class JosmDecimalFormatSymbolsProviderTest { 22 22 23 23 /** 24 24 * Setup rule. 25 25 */ 26 @R ule26 @RegisterExtension 27 27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 28 28 public JOSMTestRules test = new JOSMTestRules(); 29 29 30 30 @Test 31 publicvoid testGroupingSeparator() {31 void testGroupingSeparator() { 32 32 System.out.println(Locale.getDefault()); 33 33 assumeTrue(Utils.getJavaVersion() >= 9); … … 47 47 */ 48 48 @Test 49 publicvoid testParseDouble() {49 void testParseDouble() { 50 50 final Locale defLocale = Locale.getDefault(); 51 51 try { -
trunk/test/unit/org/openstreetmap/josm/tools/KeyboardUtilsTest.java
r16643 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.awt.event.KeyEvent; … … 13 13 import java.util.Map.Entry; 14 14 15 import org.junit. Rule;16 import org.junit.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension; 16 import org.junit.jupiter.api.Test; 17 17 import org.openstreetmap.josm.testutils.JOSMTestRules; 18 18 … … 22 22 * Unit tests of {@link KeyboardUtils} class. 23 23 */ 24 publicclass KeyboardUtilsTest {24 class KeyboardUtilsTest { 25 25 /** 26 26 * Initializes test. 27 27 */ 28 @R ule28 @RegisterExtension 29 29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 30 30 public JOSMTestRules rules = new JOSMTestRules(); … … 34 34 */ 35 35 @Test 36 publicvoid testExtendedCharacters() {36 void testExtendedCharacters() { 37 37 Map<Integer, Character> map = new LinkedHashMap<>(); 38 38 KeyboardUtils.addLatinCharacters(map); … … 55 55 */ 56 56 @Test 57 publicvoid testGetCharactersForKeyE00() {57 void testGetCharactersForKeyE00() { 58 58 char deadCircumflex = (char) KeyEvent.VK_DEAD_CIRCUMFLEX; 59 59 char deadCaron = (char) KeyEvent.VK_DEAD_CARON; -
trunk/test/unit/org/openstreetmap/josm/tools/LanguageInfoTest.java
r15661 r17275 9 9 10 10 import org.junit.Assert; 11 import org.junit. Rule;12 import org.junit.Test; 11 import org.junit.jupiter.api.extension.RegisterExtension; 12 import org.junit.jupiter.api.Test; 13 13 import org.openstreetmap.josm.testutils.JOSMTestRules; 14 14 … … 18 18 * Unit tests of {@link LanguageInfo}. 19 19 */ 20 publicclass LanguageInfoTest {20 class LanguageInfoTest { 21 21 22 22 /** 23 23 * Setup test. 24 24 */ 25 @R ule25 @RegisterExtension 26 26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 27 27 public JOSMTestRules test = new JOSMTestRules().i18n("ca@valencia"); … … 42 42 */ 43 43 @Test 44 publicvoid testWikiLanguagePrefix() {44 void testWikiLanguagePrefix() { 45 45 testGetWikiLanguagePrefixes(LanguageInfo.LocaleType.DEFAULT, 46 46 "En:", "De:", "Pt_BR:", "Ca-Valencia:", "Zh_CN:", "Zh_TW:", "Ast:", "En_GB:", "Ru:", "Nb:"); … … 66 66 */ 67 67 @Test 68 publicvoid testGetLocale() {68 void testGetLocale() { 69 69 Assert.assertEquals(RU, LanguageInfo.getLocale("ru")); 70 70 Assert.assertEquals(EN_GB, LanguageInfo.getLocale("en_GB")); … … 79 79 */ 80 80 @Test 81 publicvoid testGetJOSMLocaleCode() {81 void testGetJOSMLocaleCode() { 82 82 Assert.assertEquals("de", LanguageInfo.getJOSMLocaleCode(DE_DE)); 83 83 Assert.assertEquals("pt_BR", LanguageInfo.getJOSMLocaleCode(PT_BR)); … … 89 89 */ 90 90 @Test 91 publicvoid testGetJavaLocaleCode() {91 void testGetJavaLocaleCode() { 92 92 Assert.assertEquals("ca__valencia", LanguageInfo.getJavaLocaleCode("ca@valencia")); 93 93 } … … 97 97 */ 98 98 @Test 99 publicvoid testGetLanguageCodeXML() {99 void testGetLanguageCodeXML() { 100 100 Assert.assertEquals("ca-valencia.", LanguageInfo.getLanguageCodeXML()); 101 101 } … … 105 105 */ 106 106 @Test 107 publicvoid testGetLanguageCodeManifest() {107 void testGetLanguageCodeManifest() { 108 108 Assert.assertEquals("ca-valencia_", LanguageInfo.getLanguageCodeManifest()); 109 109 } … … 113 113 */ 114 114 @Test 115 publicvoid testGetLanguageCodes() {115 void testGetLanguageCodes() { 116 116 Assert.assertEquals(Arrays.asList("ca_ES@valencia", "ca@valencia", "ca_ES", "ca"), LanguageInfo.getLanguageCodes(CA_ES_VALENCIA)); 117 117 } -
trunk/test/unit/org/openstreetmap/josm/tools/ListenableWeakReferenceTest.java
r12181 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertFalse;5 import static org.junit. Assert.assertNotNull;6 import static org.junit. Assert.assertNull;7 import static org.junit. Assert.assertSame;8 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertFalse; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertSame; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 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.testutils.JOSMTestRules; 13 13 … … 19 19 * @since 12181 20 20 */ 21 publicclass ListenableWeakReferenceTest {21 class ListenableWeakReferenceTest { 22 22 /** 23 23 * Default test rules. 24 24 */ 25 @R ule25 @RegisterExtension 26 26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 27 27 public JOSMTestRules test = new JOSMTestRules(); … … 34 34 */ 35 35 @Test 36 publicvoid testOnDereference() throws InterruptedException {36 void testOnDereference() throws InterruptedException { 37 37 object = new Object(); 38 38 called = false; -
trunk/test/unit/org/openstreetmap/josm/tools/LoggingTest.java
r16945 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNotNull;7 import static org.junit. Assert.assertNull;8 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertNull; 8 import static org.junit.jupiter.api.Assertions.assertTrue; 9 9 10 10 import java.io.IOException; … … 14 14 import java.util.logging.LogRecord; 15 15 16 import org.junit. After;17 import org.junit. Before;18 import org.junit.Test; 16 import org.junit.jupiter.api.AfterEach; 17 import org.junit.jupiter.api.BeforeEach; 18 import org.junit.jupiter.api.Test; 19 19 20 20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 24 24 * 25 25 */ 26 publicclass LoggingTest {26 class LoggingTest { 27 27 28 28 private LogRecord captured; … … 46 46 * @throws SecurityException if a security error occurs 47 47 */ 48 @Before 48 @BeforeEach 49 49 public void setUp() throws SecurityException { 50 50 captured = null; … … 55 55 * @throws SecurityException if a security error occurs 56 56 */ 57 @After 57 @AfterEach 58 58 public void tearDown() throws SecurityException { 59 59 Logging.getLogger().removeHandler(handler); … … 64 64 */ 65 65 @Test 66 publicvoid testSetLogLevel() {66 void testSetLogLevel() { 67 67 Logging.setLogLevel(Logging.LEVEL_DEBUG); 68 68 assertEquals(Logging.LEVEL_DEBUG, Logging.getLogger().getLevel()); … … 95 95 */ 96 96 @Test 97 publicvoid testErrorString() {97 void testErrorString() { 98 98 testLogCaptured(Logging.LEVEL_ERROR, "test", () -> Logging.error("test")); 99 99 } … … 103 103 */ 104 104 @Test 105 publicvoid testErrorStringObjectArray() {105 void testErrorStringObjectArray() { 106 106 testLogCaptured(Logging.LEVEL_ERROR, "test x 1", () -> Logging.error("test {0} {1}", "x", 1)); 107 107 } … … 111 111 */ 112 112 @Test 113 publicvoid testWarnString() {113 void testWarnString() { 114 114 testLogCaptured(Logging.LEVEL_WARN, "test", () -> Logging.warn("test")); 115 115 } … … 119 119 */ 120 120 @Test 121 publicvoid testWarnStringObjectArray() {121 void testWarnStringObjectArray() { 122 122 testLogCaptured(Logging.LEVEL_WARN, "test x 1", () -> Logging.warn("test {0} {1}", "x", 1)); 123 123 } … … 127 127 */ 128 128 @Test 129 publicvoid testInfoString() {129 void testInfoString() { 130 130 testLogCaptured(Logging.LEVEL_INFO, "test", () -> Logging.info("test")); 131 131 } … … 135 135 */ 136 136 @Test 137 publicvoid testInfoStringObjectArray() {137 void testInfoStringObjectArray() { 138 138 testLogCaptured(Logging.LEVEL_INFO, "test x 1", () -> Logging.info("test {0} {1}", "x", 1)); 139 139 } … … 143 143 */ 144 144 @Test 145 publicvoid testDebugString() {145 void testDebugString() { 146 146 testLogCaptured(Logging.LEVEL_DEBUG, "test", () -> Logging.debug("test")); 147 147 } … … 151 151 */ 152 152 @Test 153 publicvoid testDebugStringObjectArray() {153 void testDebugStringObjectArray() { 154 154 testLogCaptured(Logging.LEVEL_DEBUG, "test x 1", () -> Logging.debug("test {0} {1}", "x", 1)); 155 155 } … … 159 159 */ 160 160 @Test 161 publicvoid testTraceString() {161 void testTraceString() { 162 162 testLogCaptured(Logging.LEVEL_TRACE, "test", () -> Logging.trace("test")); 163 163 } … … 167 167 */ 168 168 @Test 169 publicvoid testTraceStringObjectArray() {169 void testTraceStringObjectArray() { 170 170 testLogCaptured(Logging.LEVEL_TRACE, "test x 1", () -> Logging.trace("test {0} {1}", "x", 1)); 171 171 } … … 175 175 */ 176 176 @Test 177 publicvoid testLogLevelThrowable() {177 void testLogLevelThrowable() { 178 178 testLogCaptured(Logging.LEVEL_ERROR, "java.io.IOException: x", () -> Logging.log(Logging.LEVEL_ERROR, new IOException("x"))); 179 179 … … 185 185 */ 186 186 @Test 187 publicvoid testLogLevelStringThrowable() {187 void testLogLevelStringThrowable() { 188 188 testLogCaptured(Logging.LEVEL_ERROR, "y: java.io.IOException: x", () -> Logging.log(Logging.LEVEL_ERROR, "y", new IOException("x"))); 189 189 … … 195 195 */ 196 196 @Test 197 publicvoid testLogWithStackTraceLevelThrowable() {197 void testLogWithStackTraceLevelThrowable() { 198 198 Consumer<String> test = string -> { 199 199 assertTrue(string.startsWith("java.io.IOException: x")); … … 215 215 */ 216 216 @Test 217 publicvoid testLogWithStackTraceLevelStringThrowable() {217 void testLogWithStackTraceLevelStringThrowable() { 218 218 Consumer<String> test = string -> { 219 219 assertTrue(string.startsWith("y: java.io.IOException: x")); … … 228 228 */ 229 229 @Test 230 publicvoid testIsLoggingEnabled() {230 void testIsLoggingEnabled() { 231 231 Logging.setLogLevel(Logging.LEVEL_ERROR); 232 232 assertTrue(Logging.isLoggingEnabled(Logging.LEVEL_ERROR)); … … 247 247 */ 248 248 @Test 249 publicvoid testClearLastErrorAndWarnings() {249 void testClearLastErrorAndWarnings() { 250 250 Logging.setLogLevel(Logging.LEVEL_WARN); 251 251 Logging.clearLastErrorAndWarnings(); … … 261 261 */ 262 262 @Test 263 publicvoid testGetLastErrorAndWarnings() {263 void testGetLastErrorAndWarnings() { 264 264 Logging.setLogLevel(Logging.LEVEL_WARN); 265 265 Logging.clearLastErrorAndWarnings(); … … 267 267 268 268 assertEquals(1, Logging.getLastErrorAndWarnings().size()); 269 assertTrue(Logging.getLastErrorAndWarnings(). toString(), Logging.getLastErrorAndWarnings().get(0).endsWith("W: x"));269 assertTrue(Logging.getLastErrorAndWarnings().get(0).endsWith("W: x"), Logging.getLastErrorAndWarnings()::toString); 270 270 271 271 Logging.setLogLevel(Logging.LEVEL_ERROR); … … 277 277 278 278 assertEquals(2, Logging.getLastErrorAndWarnings().size()); 279 assertTrue(Logging.getLastErrorAndWarnings(). toString(), Logging.getLastErrorAndWarnings().get(0).endsWith("W: x"));280 assertTrue(Logging.getLastErrorAndWarnings(). toString(), Logging.getLastErrorAndWarnings().get(1).endsWith("E: y"));279 assertTrue(Logging.getLastErrorAndWarnings().get(0).endsWith("W: x"), Logging.getLastErrorAndWarnings()::toString); 280 assertTrue(Logging.getLastErrorAndWarnings().get(1).endsWith("E: y"), Logging.getLastErrorAndWarnings()::toString); 281 281 282 282 // limit somewhere reasonable -
trunk/test/unit/org/openstreetmap/josm/tools/MediawikiTest.java
r16988 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 import org.junit.Test; 6 import org.junit.jupiter.api.Test; 7 7 8 8 /** 9 9 * Unit tests of {@link Mediawiki}. 10 10 */ 11 publicclass MediawikiTest {11 class MediawikiTest { 12 12 13 13 /** … … 15 15 */ 16 16 @Test 17 publicvoid testImageUrl() {17 void testImageUrl() { 18 18 assertEquals("https://upload.wikimedia.org/wikipedia/commons/1/18/OpenJDK_logo.svg", 19 19 Mediawiki.getImageUrl("https://upload.wikimedia.org/wikipedia/commons", "OpenJDK_logo.svg")); -
trunk/test/unit/org/openstreetmap/josm/tools/MemoryManagerTest.java
r10717 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertSame; 7 import static org.junit.Assert.assertTrue; 8 import static org.junit.Assert.fail; 4 import static org.junit.jupiter.api.Assertions.fail; 5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertSame; 8 import static org.junit.jupiter.api.Assertions.assertThrows; 9 import static org.junit.jupiter.api.Assertions.assertTrue; 9 10 10 11 import java.util.List; 11 12 12 import org.junit. Rule;13 import org.junit. Test;13 import org.junit.jupiter.api.Test; 14 import org.junit.jupiter.api.extension.RegisterExtension; 14 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 16 import org.openstreetmap.josm.tools.MemoryManager.MemoryHandle; … … 26 27 * Base test environment 27 28 */ 28 @R ule29 @RegisterExtension 29 30 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 30 31 public JOSMTestRules test = new JOSMTestRules().memoryManagerLeaks(); … … 35 36 */ 36 37 @Test 37 publicvoid testUseMemory() throws NotEnoughMemoryException {38 void testUseMemory() throws NotEnoughMemoryException { 38 39 MemoryManager manager = MemoryManager.getInstance(); 39 40 long available = manager.getAvailableMemory(); … … 59 60 * @throws NotEnoughMemoryException if there is not enough memory 60 61 */ 61 @Test (expected = IllegalStateException.class)62 publicvoid testUseAfterFree() throws NotEnoughMemoryException {62 @Test 63 void testUseAfterFree() throws NotEnoughMemoryException { 63 64 MemoryManager manager = MemoryManager.getInstance(); 64 65 MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new); 65 66 testMemory.free(); 66 testMemory.get(); 67 assertThrows(IllegalStateException.class, () -> testMemory.get()); 67 68 } 68 69 … … 71 72 * @throws NotEnoughMemoryException if there is not enough memory 72 73 */ 73 @Test (expected = IllegalStateException.class)74 publicvoid testFreeAfterFree() throws NotEnoughMemoryException {74 @Test 75 void testFreeAfterFree() throws NotEnoughMemoryException { 75 76 MemoryManager manager = MemoryManager.getInstance(); 76 77 MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new); 77 78 testMemory.free(); 78 testMemory.free(); 79 assertThrows(IllegalStateException.class, () -> testMemory.free()); 79 80 } 80 81 … … 83 84 * @throws NotEnoughMemoryException always 84 85 */ 85 @Test (expected = NotEnoughMemoryException.class)86 publicvoid testAllocationFails() throws NotEnoughMemoryException {86 @Test 87 void testAllocationFails() throws NotEnoughMemoryException { 87 88 MemoryManager manager = MemoryManager.getInstance(); 88 89 long available = manager.getAvailableMemory(); 89 90 90 manager.allocateMemory("test", available + 1, () -> { 91 assertThrows(NotEnoughMemoryException.class, () -> manager.allocateMemory("test", available + 1, () -> { 91 92 fail("Should not reach"); 92 93 return null; 93 }); 94 })); 94 95 } 95 96 … … 98 99 * @throws NotEnoughMemoryException never 99 100 */ 100 @Test (expected = IllegalArgumentException.class)101 publicvoid testSupplierFails() throws NotEnoughMemoryException {101 @Test 102 void testSupplierFails() throws NotEnoughMemoryException { 102 103 MemoryManager manager = MemoryManager.getInstance(); 103 104 104 manager.allocateMemory("test", 1, () -> null); 105 assertThrows(IllegalArgumentException.class, () -> manager.allocateMemory("test", 1, () -> null)); 105 106 } 106 107 … … 109 110 */ 110 111 @Test 111 publicvoid testIsAvailable() {112 void testIsAvailable() { 112 113 MemoryManager manager = MemoryManager.getInstance(); 113 114 assertTrue(manager.isAvailable(10)); … … 120 121 * @throws NotEnoughMemoryException never 121 122 */ 122 @Test (expected = IllegalArgumentException.class)123 publicvoid testIsAvailableFails() throws NotEnoughMemoryException {123 @Test 124 void testIsAvailableFails() throws NotEnoughMemoryException { 124 125 MemoryManager manager = MemoryManager.getInstance(); 125 126 126 manager.isAvailable(-10); 127 assertThrows(IllegalArgumentException.class, () -> manager.isAvailable(-10)); 127 128 } 128 129 … … 132 133 */ 133 134 @Test 134 publicvoid testResetState() throws NotEnoughMemoryException {135 void testResetState() throws NotEnoughMemoryException { 135 136 MemoryManager manager = MemoryManager.getInstance(); 136 137 assertTrue(manager.resetState().isEmpty()); … … 147 148 * @throws NotEnoughMemoryException if there is not enough memory 148 149 */ 149 @Test (expected = IllegalStateException.class)150 publicvoid testResetStateUseAfterFree() throws NotEnoughMemoryException {150 @Test 151 void testResetStateUseAfterFree() throws NotEnoughMemoryException { 151 152 MemoryManager manager = MemoryManager.getInstance(); 152 153 MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new); 153 154 154 155 assertFalse(manager.resetState().isEmpty()); 155 testMemory.get(); 156 assertThrows(IllegalStateException.class, () -> testMemory.get()); 156 157 } 157 158 … … 163 164 List<MemoryHandle<?>> hadLeaks = MemoryManager.getInstance().resetState(); 164 165 if (!allowMemoryManagerLeaks) { 165 assertTrue("Memory manager had leaking memory: " + hadLeaks , hadLeaks.isEmpty());166 assertTrue(hadLeaks.isEmpty(), "Memory manager had leaking memory: " + hadLeaks); 166 167 } 167 168 } -
trunk/test/unit/org/openstreetmap/josm/tools/MultiMapTest.java
r15870 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertNull;7 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 8 9 9 import java.util.Arrays; … … 13 13 import java.util.Set; 14 14 15 import org.junit.Test; 15 import org.junit.jupiter.api.Test; 16 16 import org.openstreetmap.josm.TestUtils; 17 17 … … 21 21 * Unit tests of {@link MultiMap} class. 22 22 */ 23 publicclass MultiMapTest {23 class MultiMapTest { 24 24 25 25 /** … … 27 27 */ 28 28 @Test 29 publicvoid testEqualsContract() {29 void testEqualsContract() { 30 30 TestUtils.assumeWorkingEqualsVerifier(); 31 31 EqualsVerifier.forClass(MultiMap.class).usingGetClass().verify(); … … 36 36 */ 37 37 @Test 38 publicvoid testMultiMap() {38 void testMultiMap() { 39 39 final MultiMap<String, String> map = new MultiMap<>(); 40 40 assertTrue(map.isEmpty()); -
trunk/test/unit/org/openstreetmap/josm/tools/OptionParserTest.java
r16618 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;6 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 7 import static org.junit.jupiter.api.Assertions.assertThrows; 8 8 … … 13 13 import java.util.concurrent.atomic.AtomicReference; 14 14 15 import org.junit. Rule;16 import org.junit.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension; 16 import org.junit.jupiter.api.Test; 17 17 import org.openstreetmap.josm.testutils.JOSMTestRules; 18 18 import org.openstreetmap.josm.tools.OptionParser.OptionCount; … … 25 25 * @author Michael Zangl 26 26 */ 27 publicclass OptionParserTest {27 class OptionParserTest { 28 28 /** 29 29 * Setup test. 30 30 */ 31 @R ule31 @RegisterExtension 32 32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 33 33 public JOSMTestRules test = new JOSMTestRules().i18n(); … … 35 35 // A reason for moving to jupiter... 36 36 @Test 37 publicvoid testEmptyParserRejectsLongopt() {37 void testEmptyParserRejectsLongopt() { 38 38 Exception e = assertThrows(OptionParseException.class, () -> 39 39 new OptionParser("test").parseOptions(Arrays.asList("--long"))); … … 42 42 43 43 @Test 44 publicvoid testEmptyParserRejectsShortopt() {44 void testEmptyParserRejectsShortopt() { 45 45 Exception e = assertThrows(OptionParseException.class, () -> 46 46 new OptionParser("test").parseOptions(Arrays.asList("-s"))); … … 49 49 50 50 @Test 51 publicvoid testParserRejectsWrongShortopt() {51 void testParserRejectsWrongShortopt() { 52 52 Exception e = assertThrows(OptionParseException.class, () -> 53 53 new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", "t") … … 57 57 58 58 @Test 59 publicvoid testParserRejectsWrongLongopt() {59 void testParserRejectsWrongLongopt() { 60 60 Exception e = assertThrows(OptionParseException.class, () -> 61 61 new OptionParser("test").addFlagParameter("test", this::nop).parseOptions(Arrays.asList("--wrong"))); … … 64 64 65 65 @Test 66 publicvoid testParserOption() {66 void testParserOption() { 67 67 AtomicReference<String> argFound = new AtomicReference<>(); 68 68 OptionParser parser = new OptionParser("test") … … 74 74 75 75 @Test 76 publicvoid testParserOptionFailsIfMissing() {76 void testParserOptionFailsIfMissing() { 77 77 AtomicReference<String> argFound = new AtomicReference<>(); 78 78 OptionParser parser = new OptionParser("test") … … 84 84 85 85 @Test 86 publicvoid testParserOptionFailsIfMissingArgument() {86 void testParserOptionFailsIfMissingArgument() { 87 87 AtomicReference<String> argFound = new AtomicReference<>(); 88 88 OptionParser parser = new OptionParser("test") … … 94 94 95 95 @Test 96 publicvoid testParserOptionFailsIfMissing2() {96 void testParserOptionFailsIfMissing2() { 97 97 AtomicReference<String> argFound = new AtomicReference<>(); 98 98 OptionParser parser = new OptionParser("test") … … 104 104 105 105 @Test 106 publicvoid testParserOptionFailsIfTwice() {106 void testParserOptionFailsIfTwice() { 107 107 AtomicReference<String> argFound = new AtomicReference<>(); 108 108 OptionParser parser = new OptionParser("test") … … 114 114 115 115 @Test 116 publicvoid testParserOptionFailsIfTwiceForAlias() {116 void testParserOptionFailsIfTwiceForAlias() { 117 117 AtomicReference<String> argFound = new AtomicReference<>(); 118 118 OptionParser parser = new OptionParser("test") … … 125 125 126 126 @Test 127 publicvoid testOptionalOptionFailsIfTwice() {127 void testOptionalOptionFailsIfTwice() { 128 128 OptionParser parser = new OptionParser("test") 129 129 .addFlagParameter("test", this::nop); … … 133 133 134 134 @Test 135 publicvoid testOptionalOptionFailsIfTwiceForAlias() {135 void testOptionalOptionFailsIfTwiceForAlias() { 136 136 OptionParser parser = new OptionParser("test") 137 137 .addFlagParameter("test", this::nop) … … 142 142 143 143 @Test 144 publicvoid testOptionalOptionFailsIfTwiceForAlias2() {144 void testOptionalOptionFailsIfTwiceForAlias2() { 145 145 OptionParser parser = new OptionParser("test") 146 146 .addFlagParameter("test", this::nop) … … 151 151 152 152 @Test 153 publicvoid testLongArgumentsUsingEqualSign() {153 void testLongArgumentsUsingEqualSign() { 154 154 AtomicReference<String> argFound = new AtomicReference<>(); 155 155 OptionParser parser = new OptionParser("test") … … 173 173 174 174 @Test 175 publicvoid testLongArgumentsMissingOption() {175 void testLongArgumentsMissingOption() { 176 176 OptionParser parser = new OptionParser("test") 177 177 .addArgumentParameter("test", OptionCount.REQUIRED, this::nop); … … 182 182 183 183 @Test 184 publicvoid testLongArgumentsMissingOption2() {184 void testLongArgumentsMissingOption2() { 185 185 OptionParser parser = new OptionParser("test") 186 186 .addArgumentParameter("test", OptionCount.REQUIRED, this::nop); … … 191 191 192 192 @Test 193 publicvoid testShortArgumentsMissingOption() {193 void testShortArgumentsMissingOption() { 194 194 OptionParser parser = new OptionParser("test") 195 195 .addArgumentParameter("test", OptionCount.REQUIRED, this::nop) … … 201 201 202 202 @Test 203 publicvoid testShortArgumentsMissingOption2() {203 void testShortArgumentsMissingOption2() { 204 204 OptionParser parser = new OptionParser("test") 205 205 .addArgumentParameter("test", OptionCount.REQUIRED, this::nop) … … 211 211 212 212 @Test 213 publicvoid testLongFlagHasOption() {213 void testLongFlagHasOption() { 214 214 OptionParser parser = new OptionParser("test") 215 215 .addFlagParameter("test", this::nop); … … 220 220 221 221 @Test 222 publicvoid testShortFlagHasOption() {222 void testShortFlagHasOption() { 223 223 OptionParser parser = new OptionParser("test") 224 224 .addFlagParameter("test", this::nop) … … 230 230 231 231 @Test 232 publicvoid testShortArgumentsUsingEqualSign() {232 void testShortArgumentsUsingEqualSign() { 233 233 AtomicReference<String> argFound = new AtomicReference<>(); 234 234 OptionParser parser = new OptionParser("test") … … 243 243 244 244 @Test 245 publicvoid testMultipleArguments() {245 void testMultipleArguments() { 246 246 AtomicReference<String> argFound = new AtomicReference<>(); 247 247 List<String> multiFound = new ArrayList<>(); … … 266 266 267 267 @Test 268 publicvoid testUseAlternatives() {268 void testUseAlternatives() { 269 269 AtomicReference<String> argFound = new AtomicReference<>(); 270 270 AtomicBoolean usedFlag = new AtomicBoolean(); … … 285 285 286 286 @Test 287 publicvoid testAmbiguousAlternatives() {287 void testAmbiguousAlternatives() { 288 288 AtomicReference<String> argFound = new AtomicReference<>(); 289 289 AtomicBoolean usedFlag = new AtomicBoolean(); … … 300 300 301 301 @Test 302 publicvoid testMultipleShort() {302 void testMultipleShort() { 303 303 AtomicReference<String> argFound = new AtomicReference<>(); 304 304 AtomicBoolean usedFlag = new AtomicBoolean(); … … 328 328 329 329 @Test 330 publicvoid testIllegalOptionName() {330 void testIllegalOptionName() { 331 331 Exception e = assertThrows(IllegalArgumentException.class, () -> 332 332 new OptionParser("test").addFlagParameter("", this::nop)); … … 335 335 336 336 @Test 337 publicvoid testIllegalOptionName2() {337 void testIllegalOptionName2() { 338 338 Exception e = assertThrows(IllegalArgumentException.class, () -> 339 339 new OptionParser("test").addFlagParameter("-", this::nop)); … … 342 342 343 343 @Test 344 publicvoid testIllegalOptionName3() {344 void testIllegalOptionName3() { 345 345 Exception e = assertThrows(IllegalArgumentException.class, () -> 346 346 new OptionParser("test").addFlagParameter("-test", this::nop)); … … 349 349 350 350 @Test 351 publicvoid testIllegalOptionName4() {351 void testIllegalOptionName4() { 352 352 Exception e = assertThrows(IllegalArgumentException.class, () -> 353 353 new OptionParser("test").addFlagParameter("$", this::nop)); … … 356 356 357 357 @Test 358 publicvoid testDuplicateOptionName() {358 void testDuplicateOptionName() { 359 359 Exception e = assertThrows(IllegalArgumentException.class, () -> 360 360 new OptionParser("test").addFlagParameter("test", this::nop).addFlagParameter("test", this::nop)); … … 363 363 364 364 @Test 365 publicvoid testDuplicateOptionName2() {365 void testDuplicateOptionName2() { 366 366 Exception e = assertThrows(IllegalArgumentException.class, () -> 367 367 new OptionParser("test").addFlagParameter("test", this::nop) … … 371 371 372 372 @Test 373 publicvoid testInvalidShortAlias() {373 void testInvalidShortAlias() { 374 374 Exception e = assertThrows(IllegalArgumentException.class, () -> 375 375 new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", "$")); … … 378 378 379 379 @Test 380 publicvoid testInvalidShortAlias2() {380 void testInvalidShortAlias2() { 381 381 Exception e = assertThrows(IllegalArgumentException.class, () -> 382 382 new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", "")); … … 385 385 386 386 @Test 387 publicvoid testInvalidShortAlias3() {387 void testInvalidShortAlias3() { 388 388 Exception e = assertThrows(IllegalArgumentException.class, () -> 389 389 new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", "xx")); … … 392 392 393 393 @Test 394 publicvoid testDuplicateShortAlias() {394 void testDuplicateShortAlias() { 395 395 Exception e = assertThrows(IllegalArgumentException.class, () -> 396 396 new OptionParser("test").addFlagParameter("test", this::nop) … … 402 402 403 403 @Test 404 publicvoid testInvalidShortNoLong() {404 void testInvalidShortNoLong() { 405 405 Exception e = assertThrows(IllegalArgumentException.class, () -> 406 406 new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test2", "t")); -
trunk/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java
r16946 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 5 import org.junit.BeforeClass; 6 import org.junit.Rule; 7 import org.junit.Test; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotNull; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 8 import java.awt.Dimension; 9 import java.util.EnumSet; 10 11 import javax.swing.ImageIcon; 12 13 import org.junit.jupiter.api.BeforeAll; 14 import org.junit.jupiter.api.Test; 15 import org.junit.jupiter.api.extension.RegisterExtension; 8 16 import org.openstreetmap.josm.JOSMFixture; 9 17 import org.openstreetmap.josm.data.osm.Node; … … 14 22 import org.openstreetmap.josm.tools.OsmPrimitiveImageProvider.Options; 15 23 16 import java.awt.Dimension; 17 import java.util.EnumSet; 18 19 import static org.junit.Assert.assertEquals; 20 import static org.junit.Assert.assertNotNull; 21 import static org.junit.Assert.assertNull; 22 23 import javax.swing.ImageIcon; 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 24 25 25 26 /** 26 27 * Unit tests of {@link OsmPrimitiveImageProvider} 27 28 */ 28 publicclass OsmPrimitiveImageProviderTest {29 class OsmPrimitiveImageProviderTest { 29 30 30 31 /** 31 32 * Setup test. 32 33 */ 33 @R ule34 @RegisterExtension 34 35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 35 36 public JOSMTestRules test = new JOSMTestRules().mapStyles().presets(); … … 38 39 * Setup test. 39 40 */ 40 @Before Class41 @BeforeAll 41 42 public static void setUp() { 42 43 JOSMFixture.createUnitTestFixture().init(); … … 47 48 */ 48 49 @Test 49 publicvoid testGetResource() {50 void testGetResource() { 50 51 TaggingPresetsTest.waitForIconLoading(TaggingPresets.getTaggingPresets()); 51 52 … … 67 68 */ 68 69 @Test 69 publicvoid testGetResourceNonSquare() {70 void testGetResourceNonSquare() { 70 71 final ImageIcon bankIcon = OsmPrimitiveImageProvider 71 72 .getResource(OsmUtils.createPrimitive("node amenity=bank"), Options.DEFAULT) -
trunk/test/unit/org/openstreetmap/josm/tools/OsmUrlToBoundsTest.java
r12802 r17275 3 3 4 4 import org.junit.Assert; 5 import org.junit. Rule;6 import org.junit.Test; 5 import org.junit.jupiter.api.extension.RegisterExtension; 6 import org.junit.jupiter.api.Test; 7 7 import org.openstreetmap.josm.data.Bounds; 8 8 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 13 13 * Unit tests of {@link OsmUrlToBounds} class. 14 14 */ 15 publicclass OsmUrlToBoundsTest {15 class OsmUrlToBoundsTest { 16 16 17 17 /** 18 18 * Setup test. 19 19 */ 20 @R ule20 @RegisterExtension 21 21 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 22 22 public JOSMTestRules test = new JOSMTestRules(); … … 26 26 */ 27 27 @Test 28 publicvoid testPositionToBounds() {28 void testPositionToBounds() { 29 29 Assert.assertEquals(new Bounds(51.7167359, 8.7573485, 51.720724, 8.7659315), 30 30 OsmUrlToBounds.positionToBounds(51.71873, 8.76164, 17)); … … 91 91 */ 92 92 @Test 93 publicvoid testParse() {93 void testParse() { 94 94 for (ParseTestItem item : parseTestData) { 95 95 Bounds bounds = null; … … 108 108 */ 109 109 @Test 110 publicvoid testGetZoom() {110 void testGetZoom() { 111 111 Assert.assertEquals(4, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(0, 0, 4))); 112 112 Assert.assertEquals(10, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(5, 5, 10))); -
trunk/test/unit/org/openstreetmap/josm/tools/PairTest.java
r13079 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import org.junit.Test; 4 import org.junit.jupiter.api.Test; 5 5 import org.openstreetmap.josm.TestUtils; 6 6 … … 11 11 * Unit tests of {@link Pair} class. 12 12 */ 13 publicclass PairTest {13 class PairTest { 14 14 15 15 /** … … 17 17 */ 18 18 @Test 19 publicvoid testEqualsContract() {19 void testEqualsContract() { 20 20 TestUtils.assumeWorkingEqualsVerifier(); 21 21 EqualsVerifier.forClass(Pair.class).suppress(Warning.NONFINAL_FIELDS).verify(); -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java
r15469 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertNotNull; 7 import static org.junit.Assert.assertTrue; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 import static org.junit.jupiter.api.Assumptions.assumeTrue; 8 9 9 10 import java.io.File; 10 11 import java.io.IOException; 11 12 12 import org.junit.Assume; 13 import org.junit.BeforeClass; 14 import org.junit.Test; 13 import org.junit.jupiter.api.BeforeAll; 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.JOSMFixture; 16 16 import org.openstreetmap.josm.spi.preferences.Config; … … 19 19 * Unit tests of {@link PlatformHookOsx} class. 20 20 */ 21 publicclass PlatformHookOsxTest {21 class PlatformHookOsxTest { 22 22 23 23 static PlatformHookOsx hook; … … 26 26 * Setup test. 27 27 */ 28 @Before Class28 @BeforeAll 29 29 public static void setUp() { 30 30 JOSMFixture.createUnitTestFixture().init(); … … 36 36 */ 37 37 @Test 38 publicvoid testStartupHook() {38 void testStartupHook() { 39 39 hook.startupHook((a, b, c, d) -> System.out.println("callback")); 40 40 } … … 44 44 */ 45 45 @Test 46 publicvoid testAfterPrefStartupHook() {46 void testAfterPrefStartupHook() { 47 47 hook.afterPrefStartupHook(); 48 48 } … … 53 53 */ 54 54 @Test 55 publicvoid testOpenUrl() throws IOException {56 Assume.assumeTrue(PlatformManager.isPlatformOsx());55 void testOpenUrl() throws IOException { 56 assumeTrue(PlatformManager.isPlatformOsx()); 57 57 hook.openUrl(Config.getUrls().getJOSMWebsite()); 58 58 } … … 62 62 */ 63 63 @Test 64 publicvoid testGetDefaultCacheDirectory() {64 void testGetDefaultCacheDirectory() { 65 65 File cache = hook.getDefaultCacheDirectory(); 66 66 assertNotNull(cache); … … 74 74 */ 75 75 @Test 76 publicvoid testGetDefaultPrefDirectory() {76 void testGetDefaultPrefDirectory() { 77 77 File cache = hook.getDefaultPrefDirectory(); 78 78 assertNotNull(cache); … … 86 86 */ 87 87 @Test 88 publicvoid testGetDefaultStyle() {88 void testGetDefaultStyle() { 89 89 assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle()); 90 90 } … … 94 94 */ 95 95 @Test 96 publicvoid testGetOSDescription() {96 void testGetOSDescription() { 97 97 String os = hook.getOSDescription(); 98 98 if (PlatformManager.isPlatformOsx()) { … … 107 107 */ 108 108 @Test 109 publicvoid testInitSystemShortcuts() {109 void testInitSystemShortcuts() { 110 110 hook.initSystemShortcuts(); 111 111 } -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookTestIT.java
r15480 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.io.StringReader; … … 10 10 import javax.json.Json; 11 11 12 import org.junit. Rule;13 import org.junit. Test;12 import org.junit.jupiter.api.Test; 13 import org.junit.jupiter.api.extension.RegisterExtension; 14 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 15 … … 19 19 * Integration tests of {@link PlatformHook} class. 20 20 */ 21 publicclass PlatformHookTestIT {21 class PlatformHookTestIT { 22 22 23 23 /** 24 24 * Setup rule 25 25 */ 26 @R ule26 @RegisterExtension 27 27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 28 28 public JOSMTestRules test = new JOSMTestRules(); … … 33 33 */ 34 34 @Test 35 publicvoid testLatestUbuntuVersion() throws Exception {35 void testLatestUbuntuVersion() throws Exception { 36 36 String latestUbuntuVersion = Json.createReader(new StringReader(HttpClient.create( 37 37 new URL("https://api.launchpad.net/devel/ubuntu/series")).connect().fetchContent())) 38 38 .readObject().getJsonArray("entries").getJsonObject(0).getString("name"); 39 assertEquals(latestUbuntuVersion, HttpURLConnection.HTTP_OK, HttpClient.create( 40 new URL("https://josm.openstreetmap.de/apt/dists/" + latestUbuntuVersion + '/')).connect().getResponseCode()); 39 assertEquals(HttpURLConnection.HTTP_OK, HttpClient.create( 40 new URL("https://josm.openstreetmap.de/apt/dists/" + latestUbuntuVersion + '/')).connect().getResponseCode(), 41 latestUbuntuVersion); 41 42 } 42 43 } -
trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java
r17126 r17275 30 30 * Unit tests of {@link PlatformHookWindows} class. 31 31 */ 32 publicclass PlatformHookWindowsTest {32 class PlatformHookWindowsTest { 33 33 34 34 /** … … 53 53 */ 54 54 @Test 55 publicvoid testStartupHook() {55 void testStartupHook() { 56 56 hook.startupHook((a, b, c, d) -> System.out.println("callback")); 57 57 } … … 62 62 */ 63 63 @Test 64 publicvoid testGetRootKeystore() throws Exception {64 void testGetRootKeystore() throws Exception { 65 65 if (PlatformManager.isPlatformWindows()) { 66 66 assertNotNull(PlatformHookWindows.getRootKeystore()); … … 79 79 */ 80 80 @Test 81 publicvoid testAfterPrefStartupHook() {81 void testAfterPrefStartupHook() { 82 82 hook.afterPrefStartupHook(); 83 83 } … … 89 89 */ 90 90 @Test 91 publicvoid testOpenUrlSuccess(@Mocked final Desktop mockDesktop) throws IOException {91 void testOpenUrlSuccess(@Mocked final Desktop mockDesktop) throws IOException { 92 92 TestUtils.assumeWorkingJMockit(); 93 93 new Expectations() {{ … … 107 107 */ 108 108 @Test 109 publicvoid testOpenUrlFallback(@Mocked final Desktop mockDesktop, @Mocked Runtime anyRuntime) throws IOException {109 void testOpenUrlFallback(@Mocked final Desktop mockDesktop, @Mocked Runtime anyRuntime) throws IOException { 110 110 TestUtils.assumeWorkingJMockit(); 111 111 new Expectations() {{ … … 130 130 */ 131 131 @Test 132 publicvoid testGetAdditionalFonts() {132 void testGetAdditionalFonts() { 133 133 assertFalse(hook.getAdditionalFonts().isEmpty()); 134 134 } … … 138 138 */ 139 139 @Test 140 publicvoid testGetDefaultCacheDirectory() {140 void testGetDefaultCacheDirectory() { 141 141 File cache = hook.getDefaultCacheDirectory(); 142 142 assertNotNull(cache); … … 150 150 */ 151 151 @Test 152 publicvoid testGetDefaultPrefDirectory() {152 void testGetDefaultPrefDirectory() { 153 153 File cache = hook.getDefaultPrefDirectory(); 154 154 assertNotNull(cache); … … 162 162 */ 163 163 @Test 164 publicvoid testGetDefaultStyle() {164 void testGetDefaultStyle() { 165 165 assertEquals("com.sun.java.swing.plaf.windows.WindowsLookAndFeel", hook.getDefaultStyle()); 166 166 } … … 170 170 */ 171 171 @Test 172 publicvoid testGetInstalledFonts() {172 void testGetInstalledFonts() { 173 173 Collection<String> fonts = hook.getInstalledFonts(); 174 174 if (PlatformManager.isPlatformWindows()) { … … 183 183 */ 184 184 @Test 185 publicvoid testGetOSDescription() {185 void testGetOSDescription() { 186 186 String os = hook.getOSDescription(); 187 187 if (PlatformManager.isPlatformWindows()) { … … 196 196 */ 197 197 @Test 198 publicvoid testInitSystemShortcuts() {198 void testInitSystemShortcuts() { 199 199 hook.initSystemShortcuts(); 200 200 } -
trunk/test/unit/org/openstreetmap/josm/tools/RightAndLefthandTrafficTest.java
r16321 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.fail;4 import static org.junit.jupiter.api.Assertions.fail; 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.data.coor.LatLon; 9 9 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 15 15 * Unit tests of {@link RightAndLefthandTraffic} class. 16 16 */ 17 publicclass RightAndLefthandTrafficTest {17 class RightAndLefthandTrafficTest { 18 18 /** 19 19 * Test rules. 20 20 */ 21 @R ule21 @RegisterExtension 22 22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 23 23 public JOSMTestRules rules = new JOSMTestRules().projection().territories(); … … 28 28 */ 29 29 @Test 30 publicvoid testUtilityClass() throws ReflectiveOperationException {30 void testUtilityClass() throws ReflectiveOperationException { 31 31 UtilityClassTestUtil.assertUtilityClassWellDefined(RightAndLefthandTraffic.class); 32 32 } … … 36 36 */ 37 37 @Test 38 publicvoid testIsRightHandTraffic() {38 void testIsRightHandTraffic() { 39 39 check(true, "Paris", 48.8567, 2.3508); 40 40 check(true, "Berlin", 52.5167, 13.383); -
trunk/test/unit/org/openstreetmap/josm/tools/RotationAngleTest.java
r12802 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit.Assert.assertEquals; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertThrows; 5 6 6 import org.junit.Test; 7 import org.junit.jupiter.api.Test; 7 8 8 9 /** 9 10 * Unit tests of {@link RotationAngle} class. 10 11 */ 11 publicclass RotationAngleTest {12 class RotationAngleTest { 12 13 13 14 private static final double EPSILON = 1e-11; … … 17 18 */ 18 19 @Test 19 publicvoid testParseCardinal() {20 void testParseCardinal() { 20 21 assertEquals(Math.PI, RotationAngle.buildStaticRotation("south").getRotationAngle(null), EPSILON); 21 22 assertEquals(Math.PI, RotationAngle.buildStaticRotation("s").getRotationAngle(null), EPSILON); … … 26 27 * Unit test of method {@link RotationAngle#buildStaticRotation} - wrong parameter. 27 28 */ 28 @Test (expected = IllegalArgumentException.class)29 publicvoid testParseFail() {30 RotationAngle.buildStaticRotation("bad"); 29 @Test 30 void testParseFail() { 31 assertThrows(IllegalArgumentException.class, () -> RotationAngle.buildStaticRotation("bad")); 31 32 } 32 33 … … 34 35 * Unit test of method {@link RotationAngle#buildStaticRotation} - null handling. 35 36 */ 36 @Test (expected = NullPointerException.class)37 publicvoid testParseNull() {38 RotationAngle.buildStaticRotation(null); 37 @Test 38 void testParseNull() { 39 assertThrows(NullPointerException.class, () -> RotationAngle.buildStaticRotation(null)); 39 40 } 40 41 } -
trunk/test/unit/org/openstreetmap/josm/tools/SearchCompilerQueryWizardTest.java
r16413 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit.Assert.assertEquals; 5 6 import org.junit.Ignore; 7 import org.junit.Rule; 8 import org.junit.Test; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertThrows; 6 7 import org.junit.jupiter.api.Disabled; 8 import org.junit.jupiter.api.Test; 9 import org.junit.jupiter.api.extension.RegisterExtension; 9 10 import org.openstreetmap.josm.testutils.JOSMTestRules; 10 11 … … 14 15 * Unit tests of {@link SearchCompilerQueryWizard} class. 15 16 */ 16 publicclass SearchCompilerQueryWizardTest {17 class SearchCompilerQueryWizardTest { 17 18 /** 18 19 * Base test environment is enough 19 20 */ 20 @R ule21 @RegisterExtension 21 22 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 22 23 public JOSMTestRules test = new JOSMTestRules().i18n("de"); … … 41 42 */ 42 43 @Test 43 publicvoid testKeyValue() {44 void testKeyValue() { 44 45 assertQueryEquals(" nwr[\"amenity\"=\"drinking_water\"];\n", "amenity=drinking_water"); 45 46 assertQueryEquals(" nwr[\"amenity\"];\n", "amenity=*"); … … 50 51 */ 51 52 @Test 52 publicvoid testKeyNotValue() {53 void testKeyNotValue() { 53 54 assertQueryEquals(" nwr[\"amenity\"!=\"drinking_water\"];\n", "-amenity=drinking_water"); 54 55 assertQueryEquals(" nwr[!\"amenity\"];\n", "-amenity=*"); … … 59 60 */ 60 61 @Test 61 publicvoid testKeyLikeValue() {62 void testKeyLikeValue() { 62 63 assertQueryEquals(" nwr[\"foo\"~\"bar\"];\n", "foo~bar"); 63 64 assertQueryEquals(" nwr[\"foo\"~\"bar\"];\n", "foo~/bar/"); … … 73 74 */ 74 75 @Test 75 publicvoid testOsmBoolean() {76 void testOsmBoolean() { 76 77 assertQueryEquals(" nwr[\"highway\"][\"oneway\"~\"true|yes|1|on\"];\n", "highway=* AND oneway?"); 77 78 assertQueryEquals(" nwr[\"highway\"][\"oneway\"~\"false|no|0|off\"];\n", "highway=* AND -oneway?"); … … 82 83 */ 83 84 @Test 84 publicvoid testBooleanAnd() {85 void testBooleanAnd() { 85 86 assertQueryEquals(" nwr[\"foo\"=\"bar\"][\"baz\"=\"42\"];\n", "foo=bar and baz=42"); 86 87 assertQueryEquals(" nwr[\"foo\"=\"bar\"][\"baz\"=\"42\"];\n", "foo=bar && baz=42"); … … 92 93 */ 93 94 @Test 94 publicvoid testBooleanOr() {95 void testBooleanOr() { 95 96 assertQueryEquals(" nwr[\"foo\"=\"bar\"];\n nwr[\"baz\"=\"42\"];\n", "foo=bar or baz=42"); 96 97 assertQueryEquals(" nwr[\"foo\"=\"bar\"];\n nwr[\"baz\"=\"42\"];\n", "foo=bar | baz=42"); … … 101 102 */ 102 103 @Test 103 publicvoid testBoolean() {104 void testBoolean() { 104 105 assertQueryEquals("" + 105 106 " nwr[\"foo\"][\"baz1\"];\n" + … … 118 119 */ 119 120 @Test 120 publicvoid testType() {121 void testType() { 121 122 assertQueryEquals(" node[\"foo\"=\"bar\"];\n way[\"foo\"=\"bar\"];\n", "foo=bar and (type:node or type:way)"); 122 123 } … … 126 127 */ 127 128 @Test 128 publicvoid testUser() {129 void testUser() { 129 130 assertQueryEquals(" nwr(user:\"foo\");\n nwr(uid:42);\n", "user:foo or user:42"); 130 131 } … … 134 135 */ 135 136 @Test 136 publicvoid testEmpty() {137 void testEmpty() { 137 138 assertQueryEquals(" way[\"foo\"~\"^$\"];\n", "foo=\"\" and type:way"); 138 139 } … … 142 143 */ 143 144 @Test 144 publicvoid testInArea() {145 void testInArea() { 145 146 String query = constructQuery("foo=bar | foo=baz in Innsbruck"); 146 147 assertEquals("" + … … 179 180 */ 180 181 @Test 181 publicvoid testAroundArea() {182 void testAroundArea() { 182 183 final String query = constructQuery("foo=bar | foo=baz around \"Sankt Sigmund im Sellrain\""); 183 184 assertEquals("" + … … 196 197 */ 197 198 @Test 198 publicvoid testGlobal() {199 void testGlobal() { 199 200 final String query = constructQuery("foo=bar global"); 200 201 assertEquals("" + … … 211 212 */ 212 213 @Test 213 publicvoid testInBbox() {214 void testInBbox() { 214 215 assertQueryEquals(" nwr[\"foo\"=\"bar\"];\n", "foo=bar IN BBOX"); 215 216 } … … 219 220 */ 220 221 @Test 221 @ Ignore("preset handling not implemented")222 publicvoid testPreset() {222 @Disabled("preset handling not implemented") 223 void testPreset() { 223 224 assertQueryEquals(" nwr[\"amenity\"=\"hospital\"];\n", "Hospital"); 224 225 } … … 227 228 * Test erroneous value. 228 229 */ 229 @Test (expected = UncheckedParseException.class)230 publicvoid testErroneous() {231 constructQuery("-(foo or bar)"); 230 @Test 231 void testErroneous() { 232 assertThrows(UncheckedParseException.class, () -> constructQuery("-(foo or bar)")); 232 233 } 233 234 … … 236 237 */ 237 238 @Test 238 publicvoid testTicket19151() {239 void testTicket19151() { 239 240 assertQueryEquals(" relation[\"type\"=\"multipolygon\"][!\"landuse\"][!\"area:highway\"];\n", 240 241 "type:relation and type=multipolygon and -landuse=* and -\"area:highway\"=*"); -
trunk/test/unit/org/openstreetmap/josm/tools/ShortcutTest.java
r17180 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 5 6 6 import java.awt.event.InputEvent; … … 9 9 import javax.swing.KeyStroke; 10 10 11 import org.junit. BeforeClass;12 import org.junit.Test; 11 import org.junit.jupiter.api.BeforeAll; 12 import org.junit.jupiter.api.Test; 13 13 import org.openstreetmap.josm.JOSMFixture; 14 14 … … 16 16 * Unit tests of {@link Shortcut} class. 17 17 */ 18 publicclass ShortcutTest {18 class ShortcutTest { 19 19 20 20 /** 21 21 * Setup test. 22 22 */ 23 @Before Class23 @BeforeAll 24 24 public static void setUp() { 25 25 JOSMFixture.createUnitTestFixture().init(); … … 30 30 */ 31 31 @Test 32 publicvoid testMakeTooltip() {32 void testMakeTooltip() { 33 33 final String tooltip = Shortcut.makeTooltip("Foo Bar", KeyStroke.getKeyStroke(KeyEvent.VK_J, InputEvent.SHIFT_DOWN_MASK)); 34 34 if (Platform.determinePlatform() == Platform.OSX) { -
trunk/test/unit/org/openstreetmap/josm/tools/StreamUtilsTest.java
r16182 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import org.junit. Rule;5 import org.junit.Test; 4 import org.junit.jupiter.api.extension.RegisterExtension; 5 import org.junit.jupiter.api.Test; 6 6 import org.openstreetmap.josm.testutils.JOSMTestRules; 7 7 8 import static org.junit. Assert.assertEquals;8 import static org.junit.jupiter.api.Assertions.assertEquals; 9 9 10 10 import java.util.Arrays; … … 17 17 * Unit tests of {@link StreamUtils} class. 18 18 */ 19 publicclass StreamUtilsTest {19 class StreamUtilsTest { 20 20 21 21 /** 22 22 * Setup rule. 23 23 */ 24 @R ule24 @RegisterExtension 25 25 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 26 26 public JOSMTestRules test = new JOSMTestRules(); … … 31 31 */ 32 32 @Test 33 publicvoid testUtilityClass() throws ReflectiveOperationException {33 void testUtilityClass() throws ReflectiveOperationException { 34 34 UtilityClassTestUtil.assertUtilityClassWellDefined(StreamUtils.class); 35 35 } … … 39 39 */ 40 40 @Test 41 publicvoid testReverseStream() {41 void testReverseStream() { 42 42 assertEquals("baz/bar/foo", 43 43 StreamUtils.reversedStream(Arrays.asList("foo", "bar", "baz")).collect(Collectors.joining("/"))); -
trunk/test/unit/org/openstreetmap/josm/tools/StringParserTest.java
r16618 r17275 4 4 import static org.hamcrest.CoreMatchers.is; 5 5 import static org.hamcrest.MatcherAssert.assertThat; 6 import static org.junit.Assert.assertFalse; 7 import static org.junit.Assert.assertTrue; 6 import static org.junit.jupiter.api.Assertions.assertFalse; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 import static org.junit.jupiter.api.Assertions.assertThrows; 8 9 9 10 import java.util.Optional; 10 11 11 import org.junit.Test; 12 import org.junit.jupiter.api.Test; 12 13 13 14 import net.trajano.commons.testing.UtilityClassTestUtil; … … 16 17 * Unit tests of {@link StringParser} class. 17 18 */ 18 publicclass StringParserTest {19 class StringParserTest { 19 20 20 21 /** … … 24 25 */ 25 26 @Test 26 publicvoid testUtilityClass() throws ReflectiveOperationException {27 void testUtilityClass() throws ReflectiveOperationException { 27 28 UtilityClassTestUtil.assertUtilityClassWellDefined(Utils.class); 28 29 } … … 32 33 */ 33 34 @Test 34 publicvoid testParse() {35 void testParse() { 35 36 assertThat(StringParser.DEFAULT.parse(char.class, "josm"), is('j')); 36 37 assertThat(StringParser.DEFAULT.parse(short.class, "123"), is((short) 123)); … … 44 45 * Tests that {@link StringParser#DEFAULT} is immutable. 45 46 */ 46 @Test (expected = UnsupportedOperationException.class)47 publicvoid testDefaultImmutable() {48 StringParser.DEFAULT.registerParser(String.class, String::valueOf); 47 @Test 48 void testDefaultImmutable() { 49 assertThrows(UnsupportedOperationException.class, () -> StringParser.DEFAULT.registerParser(String.class, String::valueOf)); 49 50 } 50 51 … … 53 54 */ 54 55 @Test 55 publicvoid testCopyConstructor() {56 void testCopyConstructor() { 56 57 final StringParser parser = new StringParser(StringParser.DEFAULT).registerParser(boolean.class, "JOSM"::equals); 57 58 assertTrue(StringParser.DEFAULT.parse(boolean.class, "true")); -
trunk/test/unit/org/openstreetmap/josm/tools/Tag2LinkTest.java
r17006 r17275 7 7 8 8 import org.junit.Assert; 9 import org.junit. Rule;10 import org.junit.Test; 9 import org.junit.jupiter.api.extension.RegisterExtension; 10 import org.junit.jupiter.api.Test; 11 11 import org.openstreetmap.josm.testutils.JOSMTestRules; 12 12 … … 16 16 * Test {@link Tag2Link} 17 17 */ 18 publicclass Tag2LinkTest {18 class Tag2LinkTest { 19 19 20 20 List<String> links = new ArrayList<>(); … … 31 31 * Setup test. 32 32 */ 33 @R ule33 @RegisterExtension 34 34 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 35 35 public JOSMTestRules test = new JOSMTestRules().preferences(); … … 39 39 */ 40 40 @Test 41 publicvoid testInitialize() {41 void testInitialize() { 42 42 Tag2Link.initialize(); 43 43 Assert.assertTrue("obtains at least 40 rules", Tag2Link.wikidataRules.size() > 40); … … 48 48 */ 49 49 @Test 50 publicvoid testName() {50 void testName() { 51 51 Tag2Link.getLinksForTag("name", "foobar", this::addLink); 52 52 checkLinks("Search on duckduckgo.com // https://duckduckgo.com/?q=foobar", … … 58 58 */ 59 59 @Test 60 publicvoid testWebsite() {60 void testWebsite() { 61 61 Tag2Link.getLinksForTag("website", "http://www.openstreetmap.org/", this::addLink); 62 62 checkLinks("Open openstreetmap.org // http://www.openstreetmap.org/"); … … 73 73 */ 74 74 @Test 75 publicvoid testWikipedia() {75 void testWikipedia() { 76 76 Tag2Link.getLinksForTag("wikipedia", "de:Wohnhausgruppe Herderstraße", this::addLink); 77 77 checkLinks("View Wikipedia article // https://de.wikipedia.org/wiki/Wohnhausgruppe_Herderstraße"); … … 85 85 */ 86 86 @Test 87 publicvoid testImageCommonsImage() {87 void testImageCommonsImage() { 88 88 Tag2Link.getLinksForTag("image", "File:Witten Brücke Gasstraße.jpg", this::addLink); 89 89 checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File:Witten Brücke Gasstraße.jpg"); … … 99 99 */ 100 100 @Test 101 publicvoid testImageCommonsCategory() {101 void testImageCommonsCategory() { 102 102 Tag2Link.getLinksForTag("image", "category:JOSM", this::addLink); 103 103 checkLinks("View category on Wikimedia Commons // https://commons.wikimedia.org/wiki/category:JOSM"); … … 108 108 */ 109 109 @Test 110 publicvoid testBrandWikidata() {110 void testBrandWikidata() { 111 111 Tag2Link.getLinksForTag("brand:wikidata", "Q259340", this::addLink); 112 112 checkLinks("View Wikidata item // https://www.wikidata.org/wiki/Q259340"); … … 117 117 */ 118 118 @Test 119 publicvoid testArchipelagoWikidata() {119 void testArchipelagoWikidata() { 120 120 Tag2Link.getLinksForTag("archipelago:wikidata", "Q756987;Q756988", this::addLink); 121 121 checkLinks("View Wikidata item // https://www.wikidata.org/wiki/Q756987", -
trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTest.java
r16945 r17275 3 3 4 4 import static java.util.Collections.singleton; 5 import static org.junit. Assert.assertEquals;6 import static org.junit. Assert.assertNull;7 import static org.junit. Assert.assertTrue;5 import static org.junit.jupiter.api.Assertions.assertEquals; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertTrue; 8 8 9 9 import java.util.Arrays; … … 13 13 import java.util.Set; 14 14 15 import org.junit. Rule;16 import org.junit. Test;15 import org.junit.jupiter.api.Test; 16 import org.junit.jupiter.api.extension.RegisterExtension; 17 17 import org.openstreetmap.josm.TestUtils; 18 18 import org.openstreetmap.josm.data.coor.LatLon; … … 25 25 * Unit tests of {@link Territories} class. 26 26 */ 27 publicclass TerritoriesTest {27 class TerritoriesTest { 28 28 /** 29 29 * Test rules. 30 30 */ 31 @R ule31 @RegisterExtension 32 32 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 33 33 public JOSMTestRules rules = new JOSMTestRules().projection().territories(); … … 39 39 */ 40 40 @Test 41 publicvoid testUtilityClass() throws ReflectiveOperationException {41 void testUtilityClass() throws ReflectiveOperationException { 42 42 UtilityClassTestUtil.assertUtilityClassWellDefined(Territories.class); 43 43 } … … 47 47 */ 48 48 @Test 49 publicvoid testIsIso3166Code() {49 void testIsIso3166Code() { 50 50 check("Paris", new LatLon(48.8567, 2.3508), "EU", "FR", "FX"); 51 51 } … … 53 53 private static void check(String name, LatLon ll, String... expectedCodes) { 54 54 for (String e : expectedCodes) { 55 assertTrue( name + " " + e,Territories.isIso3166Code(e, ll));55 assertTrue(Territories.isIso3166Code(e, ll), name + " " + e); 56 56 } 57 57 } … … 61 61 */ 62 62 @Test 63 publicvoid testTaginfoGeofabrik_nominal() {63 void testTaginfoGeofabrik_nominal() { 64 64 Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "/taginfo/geofabrik-index-v1-nogeom.json"); 65 65 Map<String, TaginfoRegionalInstance> cache = Territories.taginfoGeofabrikCache; … … 86 86 */ 87 87 @Test 88 publicvoid testTaginfoGeofabrik_broken() {88 void testTaginfoGeofabrik_broken() { 89 89 Logging.clearLastErrorAndWarnings(); 90 90 Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "taginfo/geofabrik-index-v1-nogeom-broken.json"); … … 92 92 assertTrue(cache.isEmpty()); 93 93 String error = Logging.getLastErrorAndWarnings().get(0); 94 assertTrue(error , error.contains("W: Failed to parse external taginfo data at "));95 assertTrue(error , error.contains(": Invalid token=EOF at (line no=3,"));94 assertTrue(error.contains("W: Failed to parse external taginfo data at "), error); 95 assertTrue(error.contains(": Invalid token=EOF at (line no=3,"), error); 96 96 } 97 97 … … 100 100 */ 101 101 @Test 102 publicvoid testGetCustomTags() {102 void testGetCustomTags() { 103 103 assertNull(Territories.getCustomTags(null)); 104 104 assertNull(Territories.getCustomTags("foo")); -
trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTestIT.java
r16602 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertFalse;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 6 7 7 import java.util.Collections; 8 8 9 import org.junit. Rule;10 import org.junit. Test;9 import org.junit.jupiter.api.Test; 10 import org.junit.jupiter.api.extension.RegisterExtension; 11 11 import org.openstreetmap.josm.testutils.JOSMTestRules; 12 12 … … 16 16 * Integration tests of {@link Territories} class. 17 17 */ 18 publicclass TerritoriesTestIT {18 class TerritoriesTestIT { 19 19 20 20 /** 21 21 * Test rules. 22 22 */ 23 @R ule23 @RegisterExtension 24 24 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 25 25 public JOSMTestRules rules = new JOSMTestRules().projection(); … … 30 30 */ 31 31 @Test 32 publicvoid testUtilityClass() {32 void testUtilityClass() { 33 33 Logging.clearLastErrorAndWarnings(); 34 34 Territories.initialize(); 35 assertEquals( "no errors or warnings",Collections.emptyList(), Logging.getLastErrorAndWarnings());36 assertFalse( "customTagsCache is non empty",Territories.customTagsCache.isEmpty());37 assertFalse( "iso3166Cache is non empty",Territories.iso3166Cache.isEmpty());38 assertFalse( "taginfoCache is non empty",Territories.taginfoCache.isEmpty());39 assertFalse( "taginfoGeofabrikCache is non empty",Territories.taginfoGeofabrikCache.isEmpty());35 assertEquals(Collections.emptyList(), Logging.getLastErrorAndWarnings(), "no errors or warnings"); 36 assertFalse(Territories.customTagsCache.isEmpty(), "customTagsCache is non empty"); 37 assertFalse(Territories.iso3166Cache.isEmpty(), "iso3166Cache is non empty"); 38 assertFalse(Territories.taginfoCache.isEmpty(), "taginfoCache is non empty"); 39 assertFalse(Territories.taginfoGeofabrikCache.isEmpty(), "taginfoGeofabrikCache is non empty"); 40 40 } 41 41 } -
trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java
r16472 r17275 2 2 package org.openstreetmap.josm.tools; 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.ArrayList; … … 11 11 import java.util.Map; 12 12 13 import org.junit. Rule;14 import org.junit.Test; 13 import org.junit.jupiter.api.extension.RegisterExtension; 14 import org.junit.jupiter.api.Test; 15 15 import org.openstreetmap.josm.testutils.JOSMTestRules; 16 16 … … 20 20 * Unit tests of {@link TextTagParser} class. 21 21 */ 22 publicclass TextTagParserTest {22 class TextTagParserTest { 23 23 /** 24 24 * Some of this depends on preferences. 25 25 */ 26 @R ule26 @RegisterExtension 27 27 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 28 28 public JOSMTestRules test = new JOSMTestRules().preferences(); … … 32 32 */ 33 33 @Test 34 publicvoid testUnescape() {34 void testUnescape() { 35 35 String s, s1; 36 36 s = "\"2 3 4\""; … … 55 55 */ 56 56 @Test 57 publicvoid testTNformat() {57 void testTNformat() { 58 58 String txt = " a \t 1 \n\n\n b\t2 \n c \t the value with \"quotes\""; 59 59 Map<String, String> correctTags = new HashMap<String, String>() { { … … 68 68 */ 69 69 @Test 70 publicvoid testEQformat() {70 void testEQformat() { 71 71 String txt = "key1=value key2=\"long value\" tag3=\"hotel \\\"Quote\\\"\""; 72 72 Map<String, String> correctTags = new HashMap<String, String>() { { … … 82 82 */ 83 83 @Test 84 publicvoid testJSONformat() {84 void testJSONformat() { 85 85 String txt; 86 86 Map<String, String> tags, correctTags; … … 105 105 */ 106 106 @Test 107 publicvoid testFreeformat() {107 void testFreeformat() { 108 108 String txt = "a 1 b=2 c=\"hello === \\\"\\\"world\""; 109 109 Map<String, String> correctTags = new HashMap<String, String>() { { … … 118 118 */ 119 119 @Test 120 publicvoid testErrorDetect() {120 void testErrorDetect() { 121 121 String txt = "a=2 b=3 4"; 122 122 Map<String, String> tags = TextTagParser.readTagsFromText(txt); … … 128 128 */ 129 129 @Test 130 publicvoid testTab() {130 void testTab() { 131 131 assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("shop\tjewelry")); 132 132 assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("!shop\tjewelry")); … … 139 139 */ 140 140 @Test 141 publicvoid testTicket16104() {141 void testTicket16104() { 142 142 Map<String, String> expected = new HashMap<>(); 143 143 expected.put("boundary", "national_park"); … … 170 170 */ 171 171 @Test 172 publicvoid testTicket8384Comment58() {172 void testTicket8384Comment58() { 173 173 Map<String, String> expected = new HashMap<>(); 174 174 expected.put("name", "Main street"); … … 181 181 */ 182 182 @Test 183 publicvoid testStableOrder() {183 void testStableOrder() { 184 184 List<String> expected = Arrays.asList("foo4", "foo3", "foo2", "foo1"); 185 185 ArrayList<String> actual = new ArrayList<>(TextTagParser.readTagsByRegexp( -
trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java
r17133 r17275 2 2 package org.openstreetmap.josm.tools; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertNull; 7 import static org.junit.Assert.assertSame; 8 import static org.junit.Assert.assertTrue; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertFalse; 6 import static org.junit.jupiter.api.Assertions.assertNull; 7 import static org.junit.jupiter.api.Assertions.assertSame; 8 import static org.junit.jupiter.api.Assertions.assertThrows; 9 import static org.junit.jupiter.api.Assertions.assertTrue; 9 10 10 11 import java.io.File; … … 21 22 import java.util.regex.Pattern; 22 23 23 import org.junit. Rule;24 import org.junit. Test;24 import org.junit.jupiter.api.Test; 25 import org.junit.jupiter.api.extension.RegisterExtension; 25 26 import org.openstreetmap.josm.testutils.JOSMTestRules; 26 27 … … 31 32 * Unit tests of {@link Utils} class. 32 33 */ 33 publicclass UtilsTest {34 class UtilsTest { 34 35 /** 35 36 * Use default, basic test rules. 36 37 */ 37 @R ule38 @RegisterExtension 38 39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 39 40 public JOSMTestRules rules = new JOSMTestRules(); … … 44 45 */ 45 46 @Test 46 publicvoid testUtilityClass() throws ReflectiveOperationException {47 void testUtilityClass() throws ReflectiveOperationException { 47 48 UtilityClassTestUtil.assertUtilityClassWellDefined(Utils.class); 48 49 } … … 52 53 */ 53 54 @Test 54 publicvoid testStrip() {55 void testStrip() { 55 56 // CHECKSTYLE.OFF: SingleSpaceSeparator 56 57 final String someWhite = … … 107 108 */ 108 109 @Test 109 publicvoid testIsStripEmpty() {110 void testIsStripEmpty() { 110 111 assertTrue(Utils.isStripEmpty(null)); 111 112 assertTrue(Utils.isStripEmpty("")); … … 123 124 */ 124 125 @Test 125 publicvoid testToHexString() {126 void testToHexString() { 126 127 assertEquals("", Utils.toHexString(null)); 127 128 assertEquals("", Utils.toHexString(new byte[0])); … … 137 138 */ 138 139 @Test 139 publicvoid testPositionListString() {140 void testPositionListString() { 140 141 assertEquals("1", Utils.getPositionListString(Arrays.asList(1))); 141 142 assertEquals("1-2", Utils.getPositionListString(Arrays.asList(1, 2))); … … 150 151 */ 151 152 @Test 152 publicvoid testDurationString() {153 void testDurationString() { 153 154 I18n.set("en"); 154 155 assertEquals("0 ms", Utils.getDurationString(0)); … … 169 170 * Test of {@link Utils#getDurationString} method. 170 171 */ 171 @Test (expected = IllegalArgumentException.class)172 publicvoid testDurationStringNegative() {173 Utils.getDurationString(-1); 172 @Test 173 void testDurationStringNegative() { 174 assertThrows(IllegalArgumentException.class, () -> Utils.getDurationString(-1)); 174 175 } 175 176 … … 178 179 */ 179 180 @Test 180 publicvoid testEscapeReservedCharactersHTML() {181 void testEscapeReservedCharactersHTML() { 181 182 assertEquals("foo -> bar -> '&'", Utils.escapeReservedCharactersHTML("foo -> bar -> '&'")); 182 183 } … … 186 187 */ 187 188 @Test 188 publicvoid testShortenString() {189 void testShortenString() { 189 190 assertNull(Utils.shortenString(null, 3)); 190 191 assertEquals("...", Utils.shortenString("123456789", 3)); … … 200 201 * Test of {@link Utils#shortenString} method. 201 202 */ 202 @Test (expected = IllegalArgumentException.class)203 publicvoid testShortenStringTooShort() {204 Utils.shortenString("123456789", 2); 203 @Test 204 void testShortenStringTooShort() { 205 assertThrows(IllegalArgumentException.class, () -> Utils.shortenString("123456789", 2)); 205 206 } 206 207 … … 209 210 */ 210 211 @Test 211 publicvoid testRestrictStringLines() {212 void testRestrictStringLines() { 212 213 assertNull(Utils.restrictStringLines(null, 2)); 213 214 assertEquals("1\n...", Utils.restrictStringLines("1\n2\n3", 2)); … … 220 221 */ 221 222 @Test 222 publicvoid testLimit() {223 void testLimit() { 223 224 assertNull(Utils.limit(null, 2, "...")); 224 225 assertEquals(Arrays.asList("1", "..."), Utils.limit(Arrays.asList("1", "2", "3"), 2, "...")); … … 231 232 */ 232 233 @Test 233 publicvoid testSizeString() {234 void testSizeString() { 234 235 assertEquals("0 B", Utils.getSizeString(0, Locale.ENGLISH)); 235 236 assertEquals("123 B", Utils.getSizeString(123, Locale.ENGLISH)); … … 251 252 * Test of {@link Utils#getSizeString} method. 252 253 */ 253 @Test (expected = IllegalArgumentException.class)254 publicvoid testSizeStringNegative() {255 Utils.getSizeString(-1, Locale.ENGLISH); 254 @Test 255 void testSizeStringNegative() { 256 assertThrows(IllegalArgumentException.class, () -> Utils.getSizeString(-1, Locale.ENGLISH)); 256 257 } 257 258 … … 260 261 */ 261 262 @Test 262 publicvoid testJoinAsHtmlUnorderedList() {263 void testJoinAsHtmlUnorderedList() { 263 264 List<? extends Object> items = Arrays.asList("1", Integer.valueOf(2)); 264 265 assertEquals("<ul><li>1</li><li>2</li></ul>", Utils.joinAsHtmlUnorderedList(items)); … … 270 271 */ 271 272 @Test 272 publicvoid testGetJavaVersion() {273 void testGetJavaVersion() { 273 274 String javaVersion = System.getProperty("java.version"); 274 275 try { … … 302 303 */ 303 304 @Test 304 publicvoid testGetJavaUpdate() {305 void testGetJavaUpdate() { 305 306 String javaVersion = System.getProperty("java.version"); 306 307 try { … … 331 332 */ 332 333 @Test 333 publicvoid testGetJavaBuild() {334 void testGetJavaBuild() { 334 335 String javaVersion = System.getProperty("java.runtime.version"); 335 336 try { … … 363 364 */ 364 365 @Test 365 publicvoid testNullStreamForReadBytesFromStream() throws IOException {366 assertEquals( "Empty on null stream",0, Utils.readBytesFromStream(null).length);366 void testNullStreamForReadBytesFromStream() throws IOException { 367 assertEquals(0, Utils.readBytesFromStream(null).length, "Empty on null stream"); 367 368 } 368 369 … … 371 372 */ 372 373 @Test 373 publicvoid testLevenshteinDistance() {374 void testLevenshteinDistance() { 374 375 assertEquals(0, Utils.getLevenshteinDistance("foo", "foo")); 375 376 assertEquals(3, Utils.getLevenshteinDistance("foo", "bar")); … … 384 385 */ 385 386 @Test 386 publicvoid testIsSimilar() {387 void testIsSimilar() { 387 388 assertFalse(Utils.isSimilar("foo", "foo")); 388 389 assertFalse(Utils.isSimilar("foo", "bar")); … … 396 397 */ 397 398 @Test 398 publicvoid testStripHtml() {399 void testStripHtml() { 399 400 assertEquals("Hoogte 55 m", Utils.stripHtml( 400 401 "<table width=\"100%\"><tr>" + … … 407 408 */ 408 409 @Test 409 publicvoid testFirstNonNull() {410 void testFirstNonNull() { 410 411 assertNull(Utils.firstNonNull()); 411 412 assertNull(Utils.firstNonNull(null, null)); … … 417 418 */ 418 419 @Test 419 publicvoid testGetMatches() {420 void testGetMatches() { 420 421 final Pattern pattern = Pattern.compile("(foo)x(bar)y(baz)"); 421 422 assertNull(Utils.getMatches(pattern.matcher(""))); … … 427 428 */ 428 429 @Test 429 publicvoid testEncodeUrl() {430 void testEncodeUrl() { 430 431 assertEquals("%C3%A4%C3%B6%C3%BC%C3%9F", Utils.encodeUrl("äöüß")); 431 432 } … … 434 435 * Test of {@link Utils#encodeUrl} 435 436 */ 436 @Test (expected = NullPointerException.class)437 publicvoid testEncodeUrlNull() {438 Utils.encodeUrl(null); 437 @Test 438 void testEncodeUrlNull() { 439 assertThrows(NullPointerException.class, () -> Utils.encodeUrl(null)); 439 440 } 440 441 … … 443 444 */ 444 445 @Test 445 publicvoid testDecodeUrl() {446 void testDecodeUrl() { 446 447 assertEquals("äöüß", Utils.decodeUrl("%C3%A4%C3%B6%C3%BC%C3%9F")); 447 448 } … … 450 451 * Test of {@link Utils#decodeUrl} 451 452 */ 452 @Test (expected = NullPointerException.class)453 publicvoid testDecodeUrlNull() {454 Utils.decodeUrl(null); 453 @Test 454 void testDecodeUrlNull() { 455 assertThrows(NullPointerException.class, () -> Utils.decodeUrl(null)); 455 456 } 456 457 … … 459 460 */ 460 461 @Test 461 publicvoid testClamp() {462 void testClamp() { 462 463 assertEquals(3, Utils.clamp(2, 3, 5)); 463 464 assertEquals(3, Utils.clamp(3, 3, 5)); … … 475 476 * Test of {@link Utils#clamp} 476 477 */ 477 @Test (expected = IllegalArgumentException.class)478 publicvoid testClampIAE1() {479 Utils.clamp(0, 5, 4); 478 @Test 479 void testClampIAE1() { 480 assertThrows(IllegalArgumentException.class, () -> Utils.clamp(0, 5, 4)); 480 481 } 481 482 … … 483 484 * Test of {@link Utils#clamp} 484 485 */ 485 @Test (expected = IllegalArgumentException.class)486 publicvoid testClampIAE2() {487 Utils.clamp(0., 5., 4.); 486 @Test 487 void testClampIAE2() { 488 assertThrows(IllegalArgumentException.class, () -> Utils.clamp(0., 5., 4.)); 488 489 } 489 490 … … 492 493 */ 493 494 @Test 494 publicvoid testHasExtension() {495 void testHasExtension() { 495 496 assertFalse(Utils.hasExtension("JOSM.txt")); 496 497 assertFalse(Utils.hasExtension("JOSM.txt", "jpg")); … … 504 505 */ 505 506 @Test 506 publicvoid testToUnmodifiableList() {507 void testToUnmodifiableList() { 507 508 assertSame(Collections.emptyList(), Utils.toUnmodifiableList(null)); 508 509 assertSame(Collections.emptyList(), Utils.toUnmodifiableList(Collections.emptyList())); … … 518 519 */ 519 520 @Test 520 publicvoid testToUnmodifiableMap() {521 void testToUnmodifiableMap() { 521 522 assertSame(Collections.emptyMap(), Utils.toUnmodifiableMap(null)); 522 523 assertSame(Collections.emptyMap(), Utils.toUnmodifiableMap(Collections.emptyMap())); … … 538 539 */ 539 540 @Test 540 publicvoid testExecOutput() throws Exception {541 void testExecOutput() throws Exception { 541 542 final String output = Utils.execOutput(Arrays.asList("echo", "Hello", "World")); 542 543 assertEquals("Hello World", output); -
trunk/test/unit/org/openstreetmap/josm/tools/XmlUtilsTest.java
r16560 r17275 3 3 4 4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 5 import org.junit. Rule;6 import org.junit.Test; 5 import org.junit.jupiter.api.extension.RegisterExtension; 6 import org.junit.jupiter.api.Test; 7 7 import org.openstreetmap.josm.TestUtils; 8 8 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 20 20 import java.io.StringWriter; 21 21 22 import static org.junit. Assert.assertEquals;23 import static org.junit. Assert.assertNotNull;24 import static org.junit. Assert.fail;22 import static org.junit.jupiter.api.Assertions.assertEquals; 23 import static org.junit.jupiter.api.Assertions.assertNotNull; 24 import static org.junit.jupiter.api.Assertions.fail; 25 25 26 26 /** 27 27 * Unit tests of {@link XmlUtils} class. 28 28 */ 29 publicclass XmlUtilsTest {29 class XmlUtilsTest { 30 30 31 31 /** 32 32 * Use default, basic test rules. 33 33 */ 34 @R ule34 @RegisterExtension 35 35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 36 36 public JOSMTestRules rules = new JOSMTestRules(); … … 40 40 41 41 @Test 42 publicvoid testExternalEntitiesParsingDom() throws IOException, ParserConfigurationException {42 void testExternalEntitiesParsingDom() throws IOException, ParserConfigurationException { 43 43 try { 44 44 final String source = TestUtils.getTestDataRoot() + "dom_external_entity.xml"; … … 52 52 53 53 @Test 54 publicvoid testExternalEntitiesTransformer() throws IOException {54 void testExternalEntitiesTransformer() throws IOException { 55 55 try { 56 56 final String source = TestUtils.getTestDataRoot() + "dom_external_entity.xml"; … … 65 65 66 66 @Test 67 publicvoid testExternalEntitiesSaxParser() throws IOException, ParserConfigurationException {67 void testExternalEntitiesSaxParser() throws IOException, ParserConfigurationException { 68 68 try { 69 69 final String source = TestUtils.getTestDataRoot() + "dom_external_entity.xml"; -
trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportExceptionHandlerTest.java
r12802 r17275 4 4 import java.util.concurrent.CountDownLatch; 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 * Unit tests of {@link BugReportExceptionHandler} class. 14 14 */ 15 publicclass BugReportExceptionHandlerTest {15 class BugReportExceptionHandlerTest { 16 16 /** 17 17 * No dependencies 18 18 */ 19 @R ule19 @RegisterExtension 20 20 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 21 21 public JOSMTestRules test = new JOSMTestRules(); … … 26 26 */ 27 27 @Test 28 publicvoid testHandleException() throws InterruptedException {28 void testHandleException() throws InterruptedException { 29 29 CountDownLatch latch = new CountDownLatch(1); 30 30 BugReportQueue.getInstance().addBugReportHandler(e -> { -
trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportTest.java
r14138 r17275 2 2 package org.openstreetmap.josm.tools.bugreport; 3 3 4 import static org.junit. Assert.assertEquals;5 import static org.junit. Assert.assertSame;6 import static org.junit. Assert.assertTrue;4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertSame; 6 import static org.junit.jupiter.api.Assertions.assertTrue; 7 7 8 8 import java.io.IOException; … … 10 10 import java.io.StringWriter; 11 11 12 import org.junit. Rule;13 import org.junit.Test; 12 import org.junit.jupiter.api.extension.RegisterExtension; 13 import org.junit.jupiter.api.Test; 14 14 import org.openstreetmap.josm.actions.ShowStatusReportAction; 15 15 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 21 21 * @author Michael Zangl 22 22 */ 23 publicclass BugReportTest {23 class BugReportTest { 24 24 /** 25 25 * Preferences for the report text 26 26 */ 27 @R ule27 @RegisterExtension 28 28 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 29 29 public JOSMTestRules test = new JOSMTestRules().preferences(); … … 33 33 */ 34 34 @Test 35 publicvoid testReportText() {35 void testReportText() { 36 36 ReportedException e = interceptInChildMethod(new IOException("test-exception-message")); 37 37 e.put("test-key", "test-value"); … … 48 48 */ 49 49 @Test 50 publicvoid testIntercept() {50 void testIntercept() { 51 51 IOException base = new IOException("test"); 52 52 ReportedException intercepted = interceptInChildMethod(base); … … 69 69 */ 70 70 @Test 71 publicvoid testGetCallingMethod() {71 void testGetCallingMethod() { 72 72 assertEquals("BugReportTest#testGetCallingMethod", BugReport.getCallingMethod(1)); 73 73 assertEquals("BugReportTest#testGetCallingMethod", testGetCallingMethod2()); -
trunk/test/unit/org/openstreetmap/josm/tools/bugreport/ReportedExceptionTest.java
r10285 r17275 2 2 package org.openstreetmap.josm.tools.bugreport; 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.Arrays; 7 7 8 import org.junit.Test; 8 import org.junit.jupiter.api.Test; 9 9 10 10 /** … … 13 13 * @since 10285 14 14 */ 15 publicclass ReportedExceptionTest {15 class ReportedExceptionTest { 16 16 private static final class CauseOverwriteException extends RuntimeException { 17 17 private Throwable myCause; … … 31 31 */ 32 32 @Test 33 publicvoid testPutDoesHandleNull() {33 void testPutDoesHandleNull() { 34 34 ReportedException e = new ReportedException(new RuntimeException()); 35 35 e.startSection("test"); … … 45 45 */ 46 46 @Test 47 publicvoid testPutDoesNotThrow() {47 void testPutDoesNotThrow() { 48 48 ReportedException e = new ReportedException(new RuntimeException()); 49 49 e.startSection("test"); … … 65 65 */ 66 66 @Test 67 publicvoid testIsSame() {67 void testIsSame() { 68 68 // Do not break this line! All exceptions need to be created in the same line. 69 69 // CHECKSTYLE.OFF: LineLength … … 78 78 boolean is01 = (i == 0 || i == 1) && (j == 0 || j == 1); 79 79 boolean is23 = (i == 2 || i == 3) && (j == 2 || j == 3); 80 assertEquals(i + ", " + j, is01 || is23 || i == j, testExceptions[i].isSame(testExceptions[j]));80 assertEquals(is01 || is23 || i == j, testExceptions[i].isSame(testExceptions[j]), i + ", " + j); 81 81 } 82 82 } -
trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
r17114 r17275 2 2 package org.openstreetmap.josm.tools.date; 3 3 4 import static org.junit.Assert.assertEquals; 5 import static org.junit.Assert.assertNotEquals; 6 import static org.junit.Assert.assertNotNull; 7 import static org.junit.Assert.assertNotSame; 8 import static org.junit.Assert.assertNull; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertNotEquals; 6 import static org.junit.jupiter.api.Assertions.assertNotNull; 7 import static org.junit.jupiter.api.Assertions.assertNotSame; 8 import static org.junit.jupiter.api.Assertions.assertNull; 9 import static org.junit.jupiter.api.Assertions.assertThrows; 9 10 10 11 import java.text.DateFormat; … … 14 15 import java.util.concurrent.ForkJoinPool; 15 16 16 import org.junit. Ignore;17 import org.junit. Rule;18 import org.junit. Test;17 import org.junit.jupiter.api.Disabled; 18 import org.junit.jupiter.api.Test; 19 import org.junit.jupiter.api.extension.RegisterExtension; 19 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 21 import org.openstreetmap.josm.tools.UncheckedParseException; … … 33 34 * Timeouts need to be disabled because we change the time zone. 34 35 */ 35 @R ule36 @RegisterExtension 36 37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 37 38 public JOSMTestRules test = new JOSMTestRules().i18n().preferences(); … … 42 43 */ 43 44 @Test 44 publicvoid testUtilityClass() throws ReflectiveOperationException {45 void testUtilityClass() throws ReflectiveOperationException { 45 46 UtilityClassTestUtil.assertUtilityClassWellDefined(DateUtils.class); 46 47 } … … 58 59 */ 59 60 @Test 60 publicvoid testMapDate() {61 void testMapDate() { 61 62 assertEquals(1344870637000L, DateUtils.fromString("2012-08-13T15:10:37Z").getTime()); 62 63 } … … 66 67 */ 67 68 @Test 68 publicvoid testNoteDate() {69 void testNoteDate() { 69 70 assertEquals(1417298930000L, DateUtils.fromString("2014-11-29 22:08:50 UTC").getTime()); 70 71 } … … 74 75 */ 75 76 @Test 76 publicvoid testExifDate() {77 void testExifDate() { 77 78 assertEquals(1443038712000L, DateUtils.fromString("2015:09:23 20:05:12").getTime()); 78 79 assertEquals(1443038712888L, DateUtils.fromString("2015:09:23 20:05:12.888").getTime()); … … 83 84 */ 84 85 @Test 85 publicvoid testGPXDate() {86 void testGPXDate() { 86 87 assertEquals(1277465405000L, DateUtils.fromString("2010-06-25T11:30:05.000Z").getTime()); 87 88 } … … 91 92 */ 92 93 @Test 93 publicvoid testRfc3339() {94 void testRfc3339() { 94 95 // examples taken from RFC 95 96 assertEquals(482196050520L, DateUtils.fromString("1985-04-12T23:20:50.52Z").getTime()); … … 105 106 * Verifies that parsing an illegal date throws a {@link UncheckedParseException} 106 107 */ 107 @Test (expected = UncheckedParseException.class)108 publicvoid testIllegalDate() {109 DateUtils.fromString("2014-"); 108 @Test 109 void testIllegalDate() { 110 assertThrows(UncheckedParseException.class, () -> DateUtils.fromString("2014-")); 110 111 } 111 112 … … 114 115 */ 115 116 @Test 116 publicvoid testFormattingMillisecondsDoesNotCauseIncorrectParsing() {117 void testFormattingMillisecondsDoesNotCauseIncorrectParsing() { 117 118 DateUtils.fromDate(new Date(123)); 118 119 assertEquals(1453694709000L, DateUtils.fromString("2016-01-25T04:05:09.000Z").getTime()); … … 125 126 */ 126 127 @Test 127 publicvoid testFromTimestamp() {128 void testFromTimestamp() { 128 129 assertEquals("1970-01-01T00:00:00Z", DateUtils.fromTimestamp(0)); 129 130 assertEquals("2001-09-09T01:46:40Z", DateUtils.fromTimestamp(1000000000)); … … 135 136 */ 136 137 @Test 137 publicvoid testFromDate() {138 void testFromDate() { 138 139 assertEquals("1970-01-01T00:00:00Z", DateUtils.fromDate(new Date(0))); 139 140 assertEquals("1970-01-01T00:00:00.1Z", DateUtils.fromDate(new Date(100))); … … 147 148 */ 148 149 @Test 149 publicvoid testFormatTime() {150 void testFormatTime() { 150 151 assertEquals("12:00 AM", DateUtils.formatTime(new Date(0), DateFormat.SHORT)); 151 152 assertEquals("1:00 AM", DateUtils.formatTime(new Date(60 * 60 * 1000), DateFormat.SHORT)); … … 162 163 */ 163 164 @Test 164 publicvoid testFormatDate() {165 void testFormatDate() { 165 166 assertEquals("1/1/70", DateUtils.formatDate(new Date(123), DateFormat.SHORT)); 166 167 assertEquals("January 1, 1970", DateUtils.formatDate(new Date(123), DateFormat.LONG)); … … 171 172 */ 172 173 @Test 173 publicvoid testTsFromString() {174 void testTsFromString() { 174 175 // UTC times 175 176 assertEquals(1459641600000L, DateUtils.tsFromString("2016-04-03")); … … 204 205 205 206 @Test 206 @ Ignore("slow; use for thread safety testing")207 publicvoid testTsFromString800k() throws Exception {207 @Disabled("slow; use for thread safety testing") 208 void testTsFromString800k() throws Exception { 208 209 new ForkJoinPool(64).submit(() -> new Random() 209 210 .longs(800_000) … … 215 216 * Unit test of {@link DateUtils#tsFromString} method. 216 217 */ 217 @Test (expected = UncheckedParseException.class)218 publicvoid testTsFromStringInvalid1() {219 DateUtils.tsFromString("foobar"); 218 @Test 219 void testTsFromStringInvalid1() { 220 assertThrows(UncheckedParseException.class, () -> DateUtils.tsFromString("foobar")); 220 221 } 221 222 … … 223 224 * Unit test of {@link DateUtils#tsFromString} method. 224 225 */ 225 @Test (expected = UncheckedParseException.class)226 publicvoid testTsFromStringInvalid2() {227 DateUtils.tsFromString("2016/04/03"); 226 @Test 227 void testTsFromStringInvalid2() { 228 assertThrows(UncheckedParseException.class, () -> DateUtils.tsFromString("2016/04/03")); 228 229 } 229 230 … … 232 233 */ 233 234 @Test 234 publicvoid testGetDateFormat() {235 void testGetDateFormat() { 235 236 Boolean iso = DateUtils.PROP_ISO_DATES.get(); 236 237 try { … … 250 251 */ 251 252 @Test 252 publicvoid testTimeFormat() {253 void testTimeFormat() { 253 254 Boolean iso = DateUtils.PROP_ISO_DATES.get(); 254 255 try { … … 265 266 266 267 @Test 267 publicvoid testCloneDate() {268 void testCloneDate() { 268 269 assertNull(DateUtils.cloneDate(null)); 269 270 final Date date = new Date(1453694709000L); -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEntryTest.java
r14100 r17275 5 5 6 6 import org.junit.Assert; 7 import org.junit. Rule;8 import org.junit.Test; 7 import org.junit.jupiter.api.extension.RegisterExtension; 8 import org.junit.jupiter.api.Test; 9 9 import org.openstreetmap.josm.TestUtils; 10 10 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 18 18 * Unit tests of {@link TemplateEntry} class. 19 19 */ 20 publicclass TemplateEntryTest {20 class TemplateEntryTest { 21 21 22 22 /** 23 23 * Setup rule. 24 24 */ 25 @R ule25 @RegisterExtension 26 26 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 27 27 public JOSMTestRules test = new JOSMTestRules(); … … 31 31 */ 32 32 @Test 33 publicvoid testEqualsContract() {33 void testEqualsContract() { 34 34 TestUtils.assumeWorkingEqualsVerifier(); 35 35 Set<Class<? extends TemplateEntry>> templates = TestUtils.getJosmSubtypes(TemplateEntry.class); -
trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java
r14093 r17275 2 2 package org.openstreetmap.josm.tools.template_engine; 3 3 4 import static org.junit.Assert.assertEquals; 4 import static org.junit.jupiter.api.Assertions.assertEquals; 5 import static org.junit.jupiter.api.Assertions.assertThrows; 5 6 6 7 import java.util.Arrays; … … 8 9 9 10 import org.junit.Assert; 10 import org.junit. BeforeClass;11 import org.junit.Test; 11 import org.junit.jupiter.api.BeforeAll; 12 import org.junit.jupiter.api.Test; 12 13 import org.openstreetmap.josm.JOSMFixture; 13 14 import org.openstreetmap.josm.data.osm.Node; … … 22 23 * Unit tests of {@link TemplateParser} class. 23 24 */ 24 publicclass TemplateParserTest {25 class TemplateParserTest { 25 26 26 27 /** 27 28 * Setup test. 28 29 */ 29 @Before Class30 @BeforeAll 30 31 public static void setUp() { 31 32 JOSMFixture.createUnitTestFixture().init(); … … 37 38 */ 38 39 @Test 39 publicvoid testEmpty() throws ParseError {40 void testEmpty() throws ParseError { 40 41 TemplateParser parser = new TemplateParser(""); 41 42 assertEquals(new StaticText(""), parser.parse()); … … 47 48 */ 48 49 @Test 49 publicvoid testVariable() throws ParseError {50 void testVariable() throws ParseError { 50 51 TemplateParser parser = new TemplateParser("abc{var}\\{ef\\$\\{g"); 51 52 assertEquals(CompoundTemplateEntry.fromArray(new StaticText("abc"), … … 58 59 */ 59 60 @Test 60 publicvoid testConditionWhitespace() throws ParseError {61 void testConditionWhitespace() throws ParseError { 61 62 TemplateParser parser = new TemplateParser("?{ '{name} {desc}' | '{name}' | '{desc}' }"); 62 63 Condition condition = new Condition(Arrays.asList( … … 72 73 */ 73 74 @Test 74 publicvoid testConditionNoWhitespace() throws ParseError {75 void testConditionNoWhitespace() throws ParseError { 75 76 TemplateParser parser = new TemplateParser("?{'{name} {desc}'|'{name}'|'{desc}'}"); 76 77 Condition condition = new Condition(Arrays.asList( … … 91 92 */ 92 93 @Test 93 publicvoid testConditionSearchExpression() throws ParseError, SearchParseError {94 void testConditionSearchExpression() throws ParseError, SearchParseError { 94 95 TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | '{admin_level}'}"); 95 96 Condition condition = new Condition(Arrays.asList( … … 139 140 */ 140 141 @Test 141 publicvoid testFilling() throws ParseError {142 void testFilling() throws ParseError { 142 143 TemplateParser parser = new TemplateParser("{name} u{unknown}u i{number}i"); 143 144 TemplateEntry entry = parser.parse(); … … 152 153 */ 153 154 @Test 154 publicvoid testFillingSearchExpression() throws ParseError {155 void testFillingSearchExpression() throws ParseError { 155 156 TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' | '{admin_level}'}"); 156 157 TemplateEntry templateEntry = parser.parse(); … … 173 174 */ 174 175 @Test 175 publicvoid testPrintAll() throws ParseError {176 void testPrintAll() throws ParseError { 176 177 TemplateParser parser = new TemplateParser("{special:everything}"); 177 178 TemplateEntry entry = parser.parse(); … … 187 188 */ 188 189 @Test 189 publicvoid testPrintMultiline() throws ParseError {190 void testPrintMultiline() throws ParseError { 190 191 TemplateParser parser = new TemplateParser("{name}\\n{number}"); 191 192 TemplateEntry entry = parser.parse(); … … 200 201 */ 201 202 @Test 202 publicvoid testSpecialVariable() throws ParseError {203 void testSpecialVariable() throws ParseError { 203 204 TemplateParser parser = new TemplateParser("{name}u{special:localName}u{special:special:key}"); 204 205 TemplateEntry templateEntry = parser.parse(); … … 210 211 211 212 @Test 212 publicvoid testSearchExpression() throws Exception {213 void testSearchExpression() throws Exception { 213 214 compile("(parent type=type1 type=parent1) | (parent type=type2 type=parent2)"); 214 215 //"parent(type=type1,type=parent1) | (parent(type=type2,type=parent2)" … … 221 222 */ 222 223 @Test 223 publicvoid testSwitchContext() throws ParseError {224 void testSwitchContext() throws ParseError { 224 225 TemplateParser parser = new TemplateParser("!{parent() type=parent2 '{name}'}"); 225 226 DatasetFactory ds = new DatasetFactory(); … … 242 243 243 244 @Test 244 publicvoid testSetAnd() throws ParseError {245 void testSetAnd() throws ParseError { 245 246 TemplateParser parser = new TemplateParser("!{(parent(type=child) type=parent) & (parent type=child subtype=parent) '{name}'}"); 246 247 DatasetFactory ds = new DatasetFactory(); … … 261 262 262 263 @Test 263 publicvoid testSetOr() throws ParseError {264 void testSetOr() throws ParseError { 264 265 TemplateParser parser = new TemplateParser("!{(parent(type=type1) type=parent1) | (parent type=type2 type=parent2) '{name}'}"); 265 266 DatasetFactory ds = new DatasetFactory(); … … 288 289 289 290 @Test 290 publicvoid testMultilevel() throws ParseError {291 void testMultilevel() throws ParseError { 291 292 TemplateParser parser = new TemplateParser( 292 293 "!{(parent(parent(type=type1)) type=grandparent) | (parent type=type2 type=parent2) '{name}'}"); … … 320 321 } 321 322 322 @Test (expected = ParseError.class)323 publicvoid testErrorsNot()throws ParseError{323 @Test 324 void testErrorsNot() { 324 325 TemplateParser parser = new TemplateParser("!{-parent() '{name}'}"); 325 parser.parse(); 326 } 327 328 @Test (expected = ParseError.class)329 publicvoid testErrorOr()throws ParseError{326 assertThrows(ParseError.class, () -> parser.parse()); 327 } 328 329 @Test 330 void testErrorOr() { 330 331 TemplateParser parser = new TemplateParser("!{parent() | type=type1 '{name}'}"); 331 parser.parse(); 332 } 333 334 @Test 335 publicvoid testChild() throws ParseError {332 assertThrows(ParseError.class, () -> parser.parse()); 333 } 334 335 @Test 336 void testChild() throws ParseError { 336 337 TemplateParser parser = new TemplateParser("!{((child(type=type1) type=child1) | (child type=type2 type=child2)) type=child2 '{name}'}"); 337 338 DatasetFactory ds = new DatasetFactory(); … … 351 352 parent2.addMember(new RelationMember("", child2)); 352 353 353 354 354 StringBuilder sb = new StringBuilder(); 355 355 TemplateEntry entry = parser.parse(); … … 360 360 361 361 @Test 362 publicvoid testToStringCanBeParsedAgain() throws Exception {362 void testToStringCanBeParsedAgain() throws Exception { 363 363 final String s1 = "?{ '{name} ({desc})' | '{name} ({cmt})' | '{name}' | '{desc}' | '{cmt}' }"; 364 364 final String s2 = new TemplateParser(s1).parse().toString();
Note:
See TracChangeset
for help on using the changeset viewer.