Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (5 years ago)
Author:
Don-vip
Message:

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

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  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.util.Arrays;
     
    88import java.util.List;
    99
    10 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
    1111
    1212/**
    1313 * Unit tests of {@link AlphanumComparator}.
    1414 */
    15 public class AlphanumComparatorTest {
     15class AlphanumComparatorTest {
    1616
    1717    /**
     
    1919     */
    2020    @Test
    21     public void testNumeric() {
     21    void testNumeric() {
    2222        List<String> lst = Arrays.asList("1", "20", "-1", "00999", "100");
    2323        Collections.sort(lst, AlphanumComparator.getInstance());
     
    2929     */
    3030    @Test
    31     public void testMixed() {
     31    void testMixed() {
    3232        List<String> lst = Arrays.asList("b1", "b20", "a5", "a00999", "a100");
    3333        Collections.sort(lst, AlphanumComparator.getInstance());
  • trunk/test/unit/org/openstreetmap/josm/tools/CheckParameterUtilTest.java

    r16182 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import org.junit.Rule;
    5 import org.junit.Test;
     4import org.junit.jupiter.api.extension.RegisterExtension;
     5import org.junit.jupiter.api.Test;
    66import org.openstreetmap.josm.testutils.JOSMTestRules;
    77
     
    1212 * Unit tests of {@link CheckParameterUtil} class.
    1313 */
    14 public class CheckParameterUtilTest {
     14class CheckParameterUtilTest {
    1515
    1616    /**
    1717     * Setup rule.
    1818     */
    19     @Rule
     19    @RegisterExtension
    2020    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2121    public JOSMTestRules test = new JOSMTestRules();
     
    2626     */
    2727    @Test
    28     public void testUtilityClass() throws ReflectiveOperationException {
     28    void testUtilityClass() throws ReflectiveOperationException {
    2929        UtilityClassTestUtil.assertUtilityClassWellDefined(CheckParameterUtil.class);
    3030    }
  • trunk/test/unit/org/openstreetmap/josm/tools/ColorHelperTest.java

    r16319 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
    66
    77import java.awt.Color;
    88
    9 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
    1010
    1111/**
    1212 * Unit tests for class {@link ColorHelper}.
    1313 */
    14 public class ColorHelperTest {
     14class ColorHelperTest {
    1515
    1616    /**
     
    1818     */
    1919    @Test
    20     public void testHtml2color() {
     20    void testHtml2color() {
    2121        assertNull(ColorHelper.html2color(""));
    2222        assertNull(ColorHelper.html2color("xyz"));
     
    3333     */
    3434    @Test
    35     public void testColor2html() {
     35    void testColor2html() {
    3636        assertNull(ColorHelper.color2html(null));
    3737        assertEquals("#FF0000", ColorHelper.color2html(Color.RED));
     
    4646     */
    4747    @Test
    48     public void testGetForegroundColor() {
     48    void testGetForegroundColor() {
    4949        assertNull(ColorHelper.getForegroundColor(null));
    5050        assertEquals(Color.WHITE, ColorHelper.getForegroundColor(Color.BLACK));
     
    5959     */
    6060    @Test
    61     public void testColorFloat2int() {
     61    void testColorFloat2int() {
    6262        assertNull(ColorHelper.float2int(null));
    6363        assertEquals(255, (int) ColorHelper.float2int(-1.0f));
     
    7474     */
    7575    @Test
    76     public void testColorInt2float() {
     76    void testColorInt2float() {
    7777        assertNull(ColorHelper.int2float(null));
    7878        assertEquals(1.0f, ColorHelper.int2float(-1), 1e-3);
     
    8989     */
    9090    @Test
    91     public void testAlphaMultiply() {
     91    void testAlphaMultiply() {
    9292        final Color color = new Color(0x12345678, true);
    9393        assertEquals(new Color(0x12345678, true), ColorHelper.alphaMultiply(color, 1f));
     
    9999     */
    100100    @Test
    101     public void testComplement() {
     101    void testComplement() {
    102102        assertEquals(Color.cyan, ColorHelper.complement(Color.red));
    103103        assertEquals(Color.red, ColorHelper.complement(Color.cyan));
  • trunk/test/unit/org/openstreetmap/josm/tools/ColorScaleTest.java

    r9669 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
    66
    77import java.awt.Color;
    88
    9 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
    1010
    1111/**
    1212 * Unit tests for class {@link ColorScale}.
    1313 */
    14 public class ColorScaleTest {
     14class ColorScaleTest {
    1515
    1616    /**
     
    1818     */
    1919    @Test
    20     public void testHSBScale() {
     20    void testHSBScale() {
    2121        final ColorScale scale = ColorScale.createHSBScale(256);
    2222        assertEquals(new Color(255, 0, 0), scale.getColor(0));
  • trunk/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java

    r16407 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.io.IOException;
     
    1111import java.util.TimeZone;
    1212
    13 import org.junit.Before;
    14 import org.junit.Rule;
    15 import org.junit.Test;
     13import org.junit.jupiter.api.BeforeEach;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
    1616import org.openstreetmap.josm.io.ChangesetClosedException;
    1717import org.openstreetmap.josm.io.IllegalDataException;
     
    3131 * Unit tests of {@link ExceptionUtil} class.
    3232 */
    33 public class ExceptionUtilTest {
     33class ExceptionUtilTest {
    3434
    3535    /**
    3636     * Setup rule.
    3737     */
    38     @Rule
     38    @RegisterExtension
    3939    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4040    public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI();
     
    4949     * @throws Exception in case of error
    5050     */
    51     @Before
     51    @BeforeEach
    5252    public void setUp() throws Exception {
    5353        OsmApi api = OsmApi.getOsmApi();
     
    6363     */
    6464    @Test
    65     public void testExplainBadRequest() {
     65    void testExplainBadRequest() {
    6666        assertEquals("<html>The OSM server '"+baseUrl+"' reported a bad request.<br></html>",
    6767                ExceptionUtil.explainBadRequest(new OsmApiException("")));
     
    9494     */
    9595    @Test
    96     public void testExplainBandwidthLimitExceeded() {
     96    void testExplainBandwidthLimitExceeded() {
    9797        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. "+
    9898                "The server replied<br>the following error code and the following error message:<br>"+
     
    105105     */
    106106    @Test
    107     public void testExplainChangesetClosedException() {
     107    void testExplainChangesetClosedException() {
    108108        assertEquals("<html>Failed to upload to changeset <strong>0</strong><br>because it has already been closed on ?.",
    109109                ExceptionUtil.explainChangesetClosedException(new ChangesetClosedException("")));
     
    117117     */
    118118    @Test
    119     public void testExplainClientTimeout() {
     119    void testExplainClientTimeout() {
    120120        assertEquals("<html>Communication with the OSM server '"+baseUrl+"' timed out. Please retry later.</html>",
    121121                ExceptionUtil.explainClientTimeout(new OsmApiException("")));
     
    126126     */
    127127    @Test
    128     public void testExplainConflict() {
     128    void testExplainConflict() {
    129129        int code = HttpURLConnection.HTTP_CONFLICT;
    130130        assertEquals("<html>The server reported that it has detected a conflict.</html>",
     
    146146     */
    147147    @Test
    148     public void testExplainException() {
     148    void testExplainException() {
    149149        assertEquals("ResponseCode=0",
    150150                ExceptionUtil.explainException(new OsmApiException("")));
     
    161161     */
    162162    @Test
    163     public void testExplainFailedAuthorisation() {
     163    void testExplainFailedAuthorisation() {
    164164        assertEquals("<html>Authorisation at the OSM server failed.<br>The server reported the following error:<br>"+
    165165                "'The server replied an error with code 0.'</html>",
     
    183183     */
    184184    @Test
    185     public void testExplainFailedOAuthAuthorisation() {
     185    void testExplainFailedOAuthAuthorisation() {
    186186        assertEquals("<html>Authorisation at the OSM server with the OAuth token 'null' failed.<br>"+
    187187                "The token is not authorised to access the protected resource<br>'unknown'.<br>"+
     
    198198     */
    199199    @Test
    200     public void testExplainFailedBasicAuthentication() {
     200    void testExplainFailedBasicAuthentication() {
    201201        assertEquals("<html>Authentication at the OSM server with the username '"+user+"' failed.<br>"+
    202202                "Please check the username and the password in the JOSM preferences.</html>",
     
    208208     */
    209209    @Test
    210     public void testExplainFailedOAuthAuthentication() {
     210    void testExplainFailedOAuthAuthentication() {
    211211        assertEquals("<html>Authentication at the OSM server with the OAuth token 'null' failed.<br>"+
    212212                "Please launch the preferences dialog and retrieve another OAuth token.</html>",
     
    218218     */
    219219    @Test
    220     public void testExplainGenericOsmApiException() {
     220    void testExplainGenericOsmApiException() {
    221221        assertEquals("<html>Communication with the OSM server '"+baseUrl+"'failed. The server replied<br>"+
    222222                "the following error code and the following error message:<br><strong>Error code:<strong> 0<br>"+
     
    239239     */
    240240    @Test
    241     public void testExplainGoneForUnknownPrimitive() {
     241    void testExplainGoneForUnknownPrimitive() {
    242242        assertEquals("<html>The server reports that an object is deleted.<br>"+
    243243                "<strong>Uploading failed</strong> if you tried to update or delete this object.<br> "+
     
    251251     */
    252252    @Test
    253     public void testExplainInternalServerError() {
     253    void testExplainInternalServerError() {
    254254        assertEquals("<html>The OSM server<br>'"+baseUrl+"'<br>reported an internal server error.<br>"+
    255255                "This is most likely a temporary problem. Please try again later.</html>",
     
    261261     */
    262262    @Test
    263     public void testExplainMissingOAuthAccessTokenException() {
     263    void testExplainMissingOAuthAccessTokenException() {
    264264        assertEquals("<html>Failed to authenticate at the OSM server 'http://fake.xxx/api'.<br>"+
    265265                "You are using OAuth to authenticate but currently there is no<br>OAuth Access Token configured.<br>"+
     
    272272     */
    273273    @Test
    274     public void testExplainNestedIllegalDataException() {
     274    void testExplainNestedIllegalDataException() {
    275275        assertEquals("<html>Failed to download data. Its format is either unsupported, ill-formed, and/or inconsistent.<br><br>"+
    276276                "Details (untranslated): null</html>",
     
    286286     */
    287287    @Test
    288     public void testExplainNestedIOException() {
     288    void testExplainNestedIOException() {
    289289        assertEquals("<html>Failed to upload data to or download data from<br>'"+baseUrl+"'<br>"+
    290290                "due to a problem with transferring data.<br>Details (untranslated): null</html>",
     
    300300     */
    301301    @Test
    302     public void testExplainNestedSocketException() {
     302    void testExplainNestedSocketException() {
    303303        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
    304304                "Please check your internet connection.</html>",
     
    310310     */
    311311    @Test
    312     public void testExplainNestedUnknownHostException() {
     312    void testExplainNestedUnknownHostException() {
    313313        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'.<br>"+
    314314                "Host name '"+host+"' could not be resolved. <br>"+
     
    321321     */
    322322    @Test
    323     public void testExplainNotFound() {
     323    void testExplainNotFound() {
    324324        assertEquals("<html>The OSM server '"+baseUrl+"' does not know about an object<br>"+
    325325                "you tried to read, update, or delete. Either the respective object<br>"+
     
    333333     */
    334334    @Test
    335     public void testExplainOfflineAccessException() {
     335    void testExplainOfflineAccessException() {
    336336        assertEquals("<html>Failed to download data.<br><br>Details: null</html>",
    337337                ExceptionUtil.explainOfflineAccessException(new OsmApiException("")));
     
    344344     */
    345345    @Test
    346     public void testExplainOsmApiInitializationException() {
     346    void testExplainOsmApiInitializationException() {
    347347        assertEquals("<html>Failed to initialize communication with the OSM server "+serverUrl+".<br>"+
    348348                "Check the server URL in your preferences and your internet connection.</html>",
     
    354354     */
    355355    @Test
    356     public void testExplainOsmTransferException() {
     356    void testExplainOsmTransferException() {
    357357        assertEquals("<html>Failed to open a connection to the remote server<br>'"+baseUrl+"'<br>"+
    358358                "for security reasons. This is most likely because you are running<br>"+
     
    410410     */
    411411    @Test
    412     public void testExplainPreconditionFailed() {
     412    void testExplainPreconditionFailed() {
    413413        int code = HttpURLConnection.HTTP_PRECON_FAILED;
    414414        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  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
    66
    77import java.io.File;
     
    1212import java.util.Date;
    1313
    14 import org.junit.Before;
    15 import org.junit.Rule;
    16 import org.junit.Test;
     14import org.junit.jupiter.api.BeforeEach;
     15import org.junit.jupiter.api.Test;
     16import org.junit.jupiter.api.extension.RegisterExtension;
    1717import org.openstreetmap.josm.TestUtils;
    1818import org.openstreetmap.josm.data.coor.LatLon;
     
    2727 * @since 6209
    2828 */
    29 public class ExifReaderTest {
     29class ExifReaderTest {
    3030    /**
    3131     * Set the timezone and timeout.
    3232     */
    33     @Rule
     33    @RegisterExtension
    3434    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3535    public JOSMTestRules test = new JOSMTestRules();
     
    4040     * Setup test
    4141     */
    42     @Before
     42    @BeforeEach
    4343    public void setUp() {
    4444        directionSampleFile = new File("nodist/data/exif-example_direction.jpg");
     
    5151     */
    5252    @Test
    53     public void testReadTime() throws ParseException {
     53    void testReadTime() throws ParseException {
    5454        Date date = ExifReader.readTime(directionSampleFile);
    5555        doTest("2010-05-15T17:12:05.000", date);
     
    6161     */
    6262    @Test
    63     public void testReadTimeSubSecond1() throws ParseException {
     63    void testReadTimeSubSecond1() throws ParseException {
    6464        Date date = ExifReader.readTime(new File("nodist/data/IMG_20150711_193419.jpg"));
    6565        doTest("2015-07-11T19:34:19.100", date);
     
    7878     */
    7979    @Test
    80     public void testReadOrientation() {
     80    void testReadOrientation() {
    8181        Integer orientation = ExifReader.readOrientation(orientationSampleFile);
    8282        assertEquals(Integer.valueOf(6), orientation);
     
    8787     */
    8888    @Test
    89     public void testReadLatLon() {
     89    void testReadLatLon() {
    9090        LatLon latlon = ExifReader.readLatLon(directionSampleFile);
    9191        assertNotNull(latlon);
     
    9999     */
    100100    @Test
    101     public void testReadDirection() {
     101    void testReadDirection() {
    102102        assertEquals(Double.valueOf(46.5), ExifReader.readDirection(directionSampleFile));
    103103    }
     
    107107     */
    108108    @Test
    109     public void testReadSpeed() {
     109    void testReadSpeed() {
    110110        assertEquals(Double.valueOf(12.3), ExifReader.readSpeed(new File("nodist/data/exif-example_speed_ele.jpg")));
    111111    }
     
    115115     */
    116116    @Test
    117     public void testReadElevation() {
     117    void testReadElevation() {
    118118        assertEquals(Double.valueOf(23.4), ExifReader.readElevation(new File("nodist/data/exif-example_speed_ele.jpg")));
    119119    }
     
    124124     */
    125125    @Test
    126     public void testTicket11685() throws IOException {
     126    void testTicket11685() throws IOException {
    127127        doTestFile("2015-11-08T15:33:27.500", 11685, "2015-11-08_15-33-27-Xiaomi_YI-Y0030832.jpg");
    128128    }
     
    133133     */
    134134    @Test
    135     public void testTicket14209() throws IOException {
     135    void testTicket14209() throws IOException {
    136136        doTestFile("2017-01-16T18:27:00.000", 14209, "0MbEfj1S--.1.jpg");
    137137        doTestFile("2016-08-13T19:51:13.000", 14209, "7VWFOryj--.1.jpg");
  • trunk/test/unit/org/openstreetmap/josm/tools/FontsManagerTest.java

    r16182 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.fail;
    55
    66import java.awt.Font;
    77import java.awt.GraphicsEnvironment;
    88
    9 import org.junit.Rule;
    10 import org.junit.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
     10import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.testutils.JOSMTestRules;
    1212
     
    1717 * Unit tests of {@link FontsManager} class.
    1818 */
    19 public class FontsManagerTest {
     19class FontsManagerTest {
    2020
    2121    /**
    2222     * Setup test.
    2323     */
    24     @Rule
     24    @RegisterExtension
    2525    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2626    public JOSMTestRules test = new JOSMTestRules();
     
    3030     */
    3131    @Test
    32     public void testFontsManager() {
     32    void testFontsManager() {
    3333        FontsManager.initialize();
    3434        boolean found = false;
     
    4949     */
    5050    @Test
    51     public void testUtilityClass() throws ReflectiveOperationException {
     51    void testUtilityClass() throws ReflectiveOperationException {
    5252        UtilityClassTestUtil.assertUtilityClassWellDefined(FontsManager.class);
    5353    }
  • trunk/test/unit/org/openstreetmap/josm/tools/GeoUrlToBoundsTest.java

    r16618 r17275  
    55import static org.hamcrest.MatcherAssert.assertThat;
    66import static org.hamcrest.core.Is.is;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    78
    8 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
    910
    1011/**
    1112 * Unit tests of {@link GeoUrlToBoundsTest} class.
    1213 */
    13 public class GeoUrlToBoundsTest {
     14class GeoUrlToBoundsTest {
    1415
    1516    /**
     
    1718     */
    1819    @Test
    19     public void testParse() {
     20    void testParse() {
    2021        assertThat(
    2122                GeoUrlToBounds.parse("geo:12.34,56.78?z=9"),
     
    2829     */
    2930    @Test
    30     public void testParseWithoutZoom() {
     31    void testParseWithoutZoom() {
    3132        assertThat(
    3233                GeoUrlToBounds.parse("geo:12.34,56.78"),
     
    4344     */
    4445    @Test
    45     public void testParseCrsUncertainty() {
     46    void testParseCrsUncertainty() {
    4647        assertThat(
    4748                GeoUrlToBounds.parse("geo:60.00000,17.000000;crs=wgs84"),
     
    6263     */
    6364    @Test
    64     public void testInvalid() {
     65    void testInvalid() {
    6566        assertThat(GeoUrlToBounds.parse("geo:foo"), nullValue());
    6667        assertThat(GeoUrlToBounds.parse("geo:foo,bar"), nullValue());
     
    7071     * Tests parsing null.
    7172     */
    72     @Test(expected = IllegalArgumentException.class)
    73     public void testNull() {
    74         GeoUrlToBounds.parse(null);
     73    @Test
     74    void testNull() {
     75        assertThrows(IllegalArgumentException.class, () -> GeoUrlToBounds.parse(null));
    7576    }
    7677}
  • trunk/test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    r15069 r17275  
    22package org.openstreetmap.josm.tools;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotEquals;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    99import java.io.InputStream;
     
    1515
    1616import org.junit.Assert;
    17 import org.junit.Rule;
    18 import org.junit.Test;
     17import org.junit.jupiter.api.extension.RegisterExtension;
     18import org.junit.jupiter.api.Test;
    1919import org.openstreetmap.josm.TestUtils;
    2020import org.openstreetmap.josm.data.coor.EastNorth;
     
    3535 * Unit tests of {@link Geometry} class.
    3636 */
    37 public class GeometryTest {
     37class GeometryTest {
    3838    /**
    3939     * Primitives need preferences and projection.
    4040     */
    41     @Rule
     41    @RegisterExtension
    4242    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4343    public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     
    4747     */
    4848    @Test
    49     public void testLineLineIntersection() {
     49    void testLineLineIntersection() {
    5050        EastNorth p1 = new EastNorth(-9477809.106349014, 1.5392960539974203E7);
    5151        EastNorth p2 = new EastNorth(-9477813.789091509, 1.5392954297092048E7);
     
    8181     */
    8282    @Test
    83     public void testClosedWayArea() throws Exception {
     83    void testClosedWayArea() throws Exception {
    8484        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) {
    8585            DataSet ds = OsmReader.parseDataSet(in, null);
     
    9797     */
    9898    @Test
    99     public void testMultipolygonArea() throws Exception {
     99    void testMultipolygonArea() throws Exception {
    100100        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "multipolygon.osm"))) {
    101101            DataSet ds = OsmReader.parseDataSet(in, null);
     
    112112     */
    113113    @Test
    114     public void testAreaAndPerimeter() throws Exception {
     114    void testAreaAndPerimeter() throws Exception {
    115115        try (InputStream in = Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm"))) {
    116116            DataSet ds = OsmReader.parseDataSet(in, null);
     
    127127     */
    128128    @Test
    129     public void testRightAngle() {
     129    void testRightAngle() {
    130130        Node n1 = new Node(1);
    131131        Node n2 = new Node(2);
     
    159159     */
    160160    @Test
    161     public void testCentroidEN() {
     161    void testCentroidEN() {
    162162        EastNorth en1 = new EastNorth(100, 200);
    163163        EastNorth en2 = new EastNorth(150, 400);
     
    173173     */
    174174    @Test
    175     public void testPolygonIntersectionTriangles() {
     175    void testPolygonIntersectionTriangles() {
    176176        Node node1 = new Node(new LatLon(0.0, 1.0));
    177177        Node node2 = new Node(new LatLon(0.0, 2.0));
     
    204204     */
    205205    @Test
    206     public void testPolygonIntersectionVShapes() {
     206    void testPolygonIntersectionVShapes() {
    207207        Node node1 = new Node(new LatLon(1.0, 1.0));
    208208        Node node2 = new Node(new LatLon(2.0, 2.0));
     
    234234     */
    235235    @Test
    236     public void testIsPolygonInsideMultiPolygon() {
     236    void testIsPolygonInsideMultiPolygon() {
    237237        Node node1 = new Node(new LatLon(1.01, 1.0));
    238238        Node node2 = new Node(new LatLon(1.01, 1.1));
     
    268268     */
    269269    @Test
    270     public void testFilterInsideMultiPolygon() {
     270    void testFilterInsideMultiPolygon() {
    271271        Node node1 = new Node(new LatLon(1.01, 1.0));
    272272        Node node2 = new Node(new LatLon(1.01, 1.1));
     
    310310     */
    311311    @Test
    312     public void testGetDistance() {
     312    void testGetDistance() {
    313313        Node node1 = new Node(new LatLon(0, 0));
    314314        Node node2 = new Node(new LatLon(0.1, 1));
     
    361361     */
    362362    @Test
    363     public void testGetClosestPrimitive() {
     363    void testGetClosestPrimitive() {
    364364        Node node1 = new Node(new LatLon(0, 0));
    365365        Node node2 = new Node(new LatLon(0.1, 1));
     
    380380     */
    381381    @Test
    382     public void testGetFurthestPrimitive() {
     382    void testGetFurthestPrimitive() {
    383383        Node node1 = new Node(new LatLon(0, 0));
    384384        Node node2 = new Node(new LatLon(0, 1.1));
     
    407407     */
    408408    @Test
    409     public void testGetClosestWaySegment() {
     409    void testGetClosestWaySegment() {
    410410        Node node1 = new Node(new LatLon(0, 0));
    411411        Node node2 = new Node(new LatLon(0, 1));
     
    423423     */
    424424    @Test
    425     public void testGetDistanceSegmentSegment() {
     425    void testGetDistanceSegmentSegment() {
    426426        Node node1 = new Node(new LatLon(2.0, 2.0));
    427427        Node node2 = new Node(new LatLon(2.0, 3.0));
  • trunk/test/unit/org/openstreetmap/josm/tools/I18nTest.java

    r11404 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.Test;
     6import org.junit.jupiter.api.Test;
    77
    88/**
    99 * Unit tests of {@link I18n}.
    1010 */
    11 public class I18nTest {
     11class I18nTest {
    1212
    1313    /**
     
    1515     */
    1616    @Test
    17     public void testEscape() {
     17    void testEscape() {
    1818        String foobar = "{foo'bar}";
    1919        assertEquals("'{'foo''bar'}'", I18n.escape(foobar));
  • trunk/test/unit/org/openstreetmap/josm/tools/ImageResizeModeTest.java

    r17151 r17275  
    88import java.awt.Dimension;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.extension.RegisterExtension;
     11import org.junit.jupiter.api.Test;
    1212import org.openstreetmap.josm.testutils.JOSMTestRules;
    1313
     
    1717 * Unit tests of {@link ImageResizeMode} class.
    1818 */
    19 public class ImageResizeModeTest {
     19class ImageResizeModeTest {
    2020
    2121    /**
    2222     * Setup test.
    2323     */
    24     @Rule
     24    @RegisterExtension
    2525    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2626    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3333     */
    3434    @Test
    35     public void testComputeDimensionAuto() {
     35    void testComputeDimensionAuto() {
    3636        assertThrows(IllegalArgumentException.class, () -> ImageResizeMode.AUTO.computeDimension(new Dimension(0, 0), image));
    3737        assertEquals(new Dimension(64, 48), ImageResizeMode.AUTO.computeDimension(ImageResource.DEFAULT_DIMENSION, image));
     
    4747     */
    4848    @Test
    49     public void testComputeDimensionBounded() {
     49    void testComputeDimensionBounded() {
    5050        assertEquals(new Dimension(64, 48), ImageResizeMode.BOUNDED.computeDimension(ImageResource.DEFAULT_DIMENSION, image));
    5151        assertEquals(new Dimension(64, 48), ImageResizeMode.BOUNDED.computeDimension(new Dimension(-1, -1), image));
     
    6868     */
    6969    @Test
    70     public void testComputeDimensionPadded() {
     70    void testComputeDimensionPadded() {
    7171        assertThrows(IllegalArgumentException.class, () -> ImageResizeMode.PADDED.computeDimension(new Dimension(0, 0), image));
    7272        assertThrows(IllegalArgumentException.class, () -> ImageResizeMode.PADDED.computeDimension(ImageResource.DEFAULT_DIMENSION, image));
     
    8282     */
    8383    @Test
    84     public void testCacheKey() {
     84    void testCacheKey() {
    8585        assertEquals(0x00180018, ImageResizeMode.AUTO.cacheKey(ImageProvider.ImageSizes.LARGEICON.getImageDimension()));
    8686        assertEquals(0x10180018, ImageResizeMode.BOUNDED.cacheKey(ImageProvider.ImageSizes.LARGEICON.getImageDimension()));
  • trunk/test/unit/org/openstreetmap/josm/tools/JosmDecimalFormatSymbolsProviderTest.java

    r17155 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66import static org.junit.Assume.assumeTrue;
    77
     
    1010import java.util.stream.Stream;
    1111
    12 import org.junit.Rule;
    13 import org.junit.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
     13import org.junit.jupiter.api.Test;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515
     
    1919 * Unit tests of {@link JosmDecimalFormatSymbolsProvider}.
    2020 */
    21 public class JosmDecimalFormatSymbolsProviderTest {
     21class JosmDecimalFormatSymbolsProviderTest {
    2222
    2323    /**
    2424     * Setup rule.
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules();
    2929
    3030    @Test
    31     public void testGroupingSeparator() {
     31    void testGroupingSeparator() {
    3232        System.out.println(Locale.getDefault());
    3333        assumeTrue(Utils.getJavaVersion() >= 9);
     
    4747     */
    4848    @Test
    49     public void testParseDouble() {
     49    void testParseDouble() {
    5050        final Locale defLocale = Locale.getDefault();
    5151        try {
  • trunk/test/unit/org/openstreetmap/josm/tools/KeyboardUtilsTest.java

    r16643 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.awt.event.KeyEvent;
     
    1313import java.util.Map.Entry;
    1414
    15 import org.junit.Rule;
    16 import org.junit.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
     16import org.junit.jupiter.api.Test;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
    1818
     
    2222 * Unit tests of {@link KeyboardUtils} class.
    2323 */
    24 public class KeyboardUtilsTest {
     24class KeyboardUtilsTest {
    2525    /**
    2626     * Initializes test.
    2727     */
    28     @Rule
     28    @RegisterExtension
    2929    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3030    public JOSMTestRules rules = new JOSMTestRules();
     
    3434     */
    3535    @Test
    36     public void testExtendedCharacters() {
     36    void testExtendedCharacters() {
    3737        Map<Integer, Character> map = new LinkedHashMap<>();
    3838        KeyboardUtils.addLatinCharacters(map);
     
    5555     */
    5656    @Test
    57     public void testGetCharactersForKeyE00() {
     57    void testGetCharactersForKeyE00() {
    5858        char deadCircumflex = (char) KeyEvent.VK_DEAD_CIRCUMFLEX;
    5959        char deadCaron = (char) KeyEvent.VK_DEAD_CARON;
  • trunk/test/unit/org/openstreetmap/josm/tools/LanguageInfoTest.java

    r15661 r17275  
    99
    1010import org.junit.Assert;
    11 import org.junit.Rule;
    12 import org.junit.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
     12import org.junit.jupiter.api.Test;
    1313import org.openstreetmap.josm.testutils.JOSMTestRules;
    1414
     
    1818 * Unit tests of {@link LanguageInfo}.
    1919 */
    20 public class LanguageInfoTest {
     20class LanguageInfoTest {
    2121
    2222    /**
    2323     * Setup test.
    2424     */
    25     @Rule
     25    @RegisterExtension
    2626    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2727    public JOSMTestRules test = new JOSMTestRules().i18n("ca@valencia");
     
    4242     */
    4343    @Test
    44     public void testWikiLanguagePrefix() {
     44    void testWikiLanguagePrefix() {
    4545        testGetWikiLanguagePrefixes(LanguageInfo.LocaleType.DEFAULT,
    4646                "En:", "De:", "Pt_BR:", "Ca-Valencia:", "Zh_CN:", "Zh_TW:", "Ast:", "En_GB:", "Ru:", "Nb:");
     
    6666     */
    6767    @Test
    68     public void testGetLocale() {
     68    void testGetLocale() {
    6969        Assert.assertEquals(RU, LanguageInfo.getLocale("ru"));
    7070        Assert.assertEquals(EN_GB, LanguageInfo.getLocale("en_GB"));
     
    7979     */
    8080    @Test
    81     public void testGetJOSMLocaleCode() {
     81    void testGetJOSMLocaleCode() {
    8282        Assert.assertEquals("de", LanguageInfo.getJOSMLocaleCode(DE_DE));
    8383        Assert.assertEquals("pt_BR", LanguageInfo.getJOSMLocaleCode(PT_BR));
     
    8989     */
    9090    @Test
    91     public void testGetJavaLocaleCode() {
     91    void testGetJavaLocaleCode() {
    9292        Assert.assertEquals("ca__valencia", LanguageInfo.getJavaLocaleCode("ca@valencia"));
    9393    }
     
    9797     */
    9898    @Test
    99     public void testGetLanguageCodeXML() {
     99    void testGetLanguageCodeXML() {
    100100        Assert.assertEquals("ca-valencia.", LanguageInfo.getLanguageCodeXML());
    101101    }
     
    105105     */
    106106    @Test
    107     public void testGetLanguageCodeManifest() {
     107    void testGetLanguageCodeManifest() {
    108108        Assert.assertEquals("ca-valencia_", LanguageInfo.getLanguageCodeManifest());
    109109    }
     
    113113     */
    114114    @Test
    115     public void testGetLanguageCodes() {
     115    void testGetLanguageCodes() {
    116116        Assert.assertEquals(Arrays.asList("ca_ES@valencia", "ca@valencia", "ca_ES", "ca"), LanguageInfo.getLanguageCodes(CA_ES_VALENCIA));
    117117    }
  • trunk/test/unit/org/openstreetmap/josm/tools/ListenableWeakReferenceTest.java

    r12181 r17275  
    22package org.openstreetmap.josm.tools;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertSame;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.extension.RegisterExtension;
     11import org.junit.jupiter.api.Test;
    1212import org.openstreetmap.josm.testutils.JOSMTestRules;
    1313
     
    1919 * @since 12181
    2020 */
    21 public class ListenableWeakReferenceTest {
     21class ListenableWeakReferenceTest {
    2222    /**
    2323     * Default test rules.
    2424     */
    25     @Rule
     25    @RegisterExtension
    2626    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2727    public JOSMTestRules test = new JOSMTestRules();
     
    3434     */
    3535    @Test
    36     public void testOnDereference() throws InterruptedException {
     36    void testOnDereference() throws InterruptedException {
    3737        object = new Object();
    3838        called = false;
  • trunk/test/unit/org/openstreetmap/josm/tools/LoggingTest.java

    r16945 r17275  
    22package org.openstreetmap.josm.tools;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertNull;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.io.IOException;
     
    1414import java.util.logging.LogRecord;
    1515
    16 import org.junit.After;
    17 import org.junit.Before;
    18 import org.junit.Test;
     16import org.junit.jupiter.api.AfterEach;
     17import org.junit.jupiter.api.BeforeEach;
     18import org.junit.jupiter.api.Test;
    1919
    2020import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    2424 *
    2525 */
    26 public class LoggingTest {
     26class LoggingTest {
    2727
    2828    private LogRecord captured;
     
    4646     * @throws SecurityException if a security error occurs
    4747     */
    48     @Before
     48    @BeforeEach
    4949    public void setUp() throws SecurityException {
    5050        captured = null;
     
    5555     * @throws SecurityException if a security error occurs
    5656     */
    57     @After
     57    @AfterEach
    5858    public void tearDown() throws SecurityException {
    5959        Logging.getLogger().removeHandler(handler);
     
    6464     */
    6565    @Test
    66     public void testSetLogLevel() {
     66    void testSetLogLevel() {
    6767        Logging.setLogLevel(Logging.LEVEL_DEBUG);
    6868        assertEquals(Logging.LEVEL_DEBUG, Logging.getLogger().getLevel());
     
    9595     */
    9696    @Test
    97     public void testErrorString() {
     97    void testErrorString() {
    9898        testLogCaptured(Logging.LEVEL_ERROR, "test", () -> Logging.error("test"));
    9999    }
     
    103103     */
    104104    @Test
    105     public void testErrorStringObjectArray() {
     105    void testErrorStringObjectArray() {
    106106        testLogCaptured(Logging.LEVEL_ERROR, "test x 1", () -> Logging.error("test {0} {1}", "x", 1));
    107107    }
     
    111111     */
    112112    @Test
    113     public void testWarnString() {
     113    void testWarnString() {
    114114        testLogCaptured(Logging.LEVEL_WARN, "test", () -> Logging.warn("test"));
    115115    }
     
    119119     */
    120120    @Test
    121     public void testWarnStringObjectArray() {
     121    void testWarnStringObjectArray() {
    122122        testLogCaptured(Logging.LEVEL_WARN, "test x 1", () -> Logging.warn("test {0} {1}", "x", 1));
    123123    }
     
    127127     */
    128128    @Test
    129     public void testInfoString() {
     129    void testInfoString() {
    130130        testLogCaptured(Logging.LEVEL_INFO, "test", () -> Logging.info("test"));
    131131    }
     
    135135     */
    136136    @Test
    137     public void testInfoStringObjectArray() {
     137    void testInfoStringObjectArray() {
    138138        testLogCaptured(Logging.LEVEL_INFO, "test x 1", () -> Logging.info("test {0} {1}", "x", 1));
    139139    }
     
    143143     */
    144144    @Test
    145     public void testDebugString() {
     145    void testDebugString() {
    146146        testLogCaptured(Logging.LEVEL_DEBUG, "test", () -> Logging.debug("test"));
    147147    }
     
    151151     */
    152152    @Test
    153     public void testDebugStringObjectArray() {
     153    void testDebugStringObjectArray() {
    154154        testLogCaptured(Logging.LEVEL_DEBUG, "test x 1", () -> Logging.debug("test {0} {1}", "x", 1));
    155155    }
     
    159159     */
    160160    @Test
    161     public void testTraceString() {
     161    void testTraceString() {
    162162        testLogCaptured(Logging.LEVEL_TRACE, "test", () -> Logging.trace("test"));
    163163    }
     
    167167     */
    168168    @Test
    169     public void testTraceStringObjectArray() {
     169    void testTraceStringObjectArray() {
    170170        testLogCaptured(Logging.LEVEL_TRACE, "test x 1", () -> Logging.trace("test {0} {1}", "x", 1));
    171171    }
     
    175175     */
    176176    @Test
    177     public void testLogLevelThrowable() {
     177    void testLogLevelThrowable() {
    178178        testLogCaptured(Logging.LEVEL_ERROR, "java.io.IOException: x", () -> Logging.log(Logging.LEVEL_ERROR, new IOException("x")));
    179179
     
    185185     */
    186186    @Test
    187     public void testLogLevelStringThrowable() {
     187    void testLogLevelStringThrowable() {
    188188        testLogCaptured(Logging.LEVEL_ERROR, "y: java.io.IOException: x", () -> Logging.log(Logging.LEVEL_ERROR, "y", new IOException("x")));
    189189
     
    195195     */
    196196    @Test
    197     public void testLogWithStackTraceLevelThrowable() {
     197    void testLogWithStackTraceLevelThrowable() {
    198198        Consumer<String> test = string -> {
    199199            assertTrue(string.startsWith("java.io.IOException: x"));
     
    215215     */
    216216    @Test
    217     public void testLogWithStackTraceLevelStringThrowable() {
     217    void testLogWithStackTraceLevelStringThrowable() {
    218218        Consumer<String> test = string -> {
    219219            assertTrue(string.startsWith("y: java.io.IOException: x"));
     
    228228     */
    229229    @Test
    230     public void testIsLoggingEnabled() {
     230    void testIsLoggingEnabled() {
    231231        Logging.setLogLevel(Logging.LEVEL_ERROR);
    232232        assertTrue(Logging.isLoggingEnabled(Logging.LEVEL_ERROR));
     
    247247     */
    248248    @Test
    249     public void testClearLastErrorAndWarnings() {
     249    void testClearLastErrorAndWarnings() {
    250250        Logging.setLogLevel(Logging.LEVEL_WARN);
    251251        Logging.clearLastErrorAndWarnings();
     
    261261     */
    262262    @Test
    263     public void testGetLastErrorAndWarnings() {
     263    void testGetLastErrorAndWarnings() {
    264264        Logging.setLogLevel(Logging.LEVEL_WARN);
    265265        Logging.clearLastErrorAndWarnings();
     
    267267
    268268        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);
    270270
    271271        Logging.setLogLevel(Logging.LEVEL_ERROR);
     
    277277
    278278        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);
    281281
    282282        // limit somewhere reasonable
  • trunk/test/unit/org/openstreetmap/josm/tools/MediawikiTest.java

    r16988 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.Test;
     6import org.junit.jupiter.api.Test;
    77
    88/**
    99 * Unit tests of {@link Mediawiki}.
    1010 */
    11 public class MediawikiTest {
     11class MediawikiTest {
    1212
    1313    /**
     
    1515     */
    1616    @Test
    17     public void testImageUrl() {
     17    void testImageUrl() {
    1818        assertEquals("https://upload.wikimedia.org/wikipedia/commons/1/18/OpenJDK_logo.svg",
    1919                Mediawiki.getImageUrl("https://upload.wikimedia.org/wikipedia/commons", "OpenJDK_logo.svg"));
  • trunk/test/unit/org/openstreetmap/josm/tools/MemoryManagerTest.java

    r10717 r17275  
    22package org.openstreetmap.josm.tools;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.fail;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertSame;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
     9import static org.junit.jupiter.api.Assertions.assertTrue;
    910
    1011import java.util.List;
    1112
    12 import org.junit.Rule;
    13 import org.junit.Test;
     13import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.extension.RegisterExtension;
    1415import org.openstreetmap.josm.testutils.JOSMTestRules;
    1516import org.openstreetmap.josm.tools.MemoryManager.MemoryHandle;
     
    2627     * Base test environment
    2728     */
    28     @Rule
     29    @RegisterExtension
    2930    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3031    public JOSMTestRules test = new JOSMTestRules().memoryManagerLeaks();
     
    3536     */
    3637    @Test
    37     public void testUseMemory() throws NotEnoughMemoryException {
     38    void testUseMemory() throws NotEnoughMemoryException {
    3839        MemoryManager manager = MemoryManager.getInstance();
    3940        long available = manager.getAvailableMemory();
     
    5960     * @throws NotEnoughMemoryException if there is not enough memory
    6061     */
    61     @Test(expected = IllegalStateException.class)
    62     public void testUseAfterFree() throws NotEnoughMemoryException {
     62    @Test
     63    void testUseAfterFree() throws NotEnoughMemoryException {
    6364        MemoryManager manager = MemoryManager.getInstance();
    6465        MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new);
    6566        testMemory.free();
    66         testMemory.get();
     67        assertThrows(IllegalStateException.class, () -> testMemory.get());
    6768    }
    6869
     
    7172     * @throws NotEnoughMemoryException if there is not enough memory
    7273     */
    73     @Test(expected = IllegalStateException.class)
    74     public void testFreeAfterFree() throws NotEnoughMemoryException {
     74    @Test
     75    void testFreeAfterFree() throws NotEnoughMemoryException {
    7576        MemoryManager manager = MemoryManager.getInstance();
    7677        MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new);
    7778        testMemory.free();
    78         testMemory.free();
     79        assertThrows(IllegalStateException.class, () -> testMemory.free());
    7980    }
    8081
     
    8384     * @throws NotEnoughMemoryException always
    8485     */
    85     @Test(expected = NotEnoughMemoryException.class)
    86     public void testAllocationFails() throws NotEnoughMemoryException {
     86    @Test
     87    void testAllocationFails() throws NotEnoughMemoryException {
    8788        MemoryManager manager = MemoryManager.getInstance();
    8889        long available = manager.getAvailableMemory();
    8990
    90         manager.allocateMemory("test", available + 1, () -> {
     91        assertThrows(NotEnoughMemoryException.class, () -> manager.allocateMemory("test", available + 1, () -> {
    9192            fail("Should not reach");
    9293            return null;
    93         });
     94        }));
    9495    }
    9596
     
    9899     * @throws NotEnoughMemoryException never
    99100     */
    100     @Test(expected = IllegalArgumentException.class)
    101     public void testSupplierFails() throws NotEnoughMemoryException {
     101    @Test
     102    void testSupplierFails() throws NotEnoughMemoryException {
    102103        MemoryManager manager = MemoryManager.getInstance();
    103104
    104         manager.allocateMemory("test", 1, () -> null);
     105        assertThrows(IllegalArgumentException.class, () -> manager.allocateMemory("test", 1, () -> null));
    105106    }
    106107
     
    109110     */
    110111    @Test
    111     public void testIsAvailable() {
     112    void testIsAvailable() {
    112113        MemoryManager manager = MemoryManager.getInstance();
    113114        assertTrue(manager.isAvailable(10));
     
    120121     * @throws NotEnoughMemoryException never
    121122     */
    122     @Test(expected = IllegalArgumentException.class)
    123     public void testIsAvailableFails() throws NotEnoughMemoryException {
     123    @Test
     124    void testIsAvailableFails() throws NotEnoughMemoryException {
    124125        MemoryManager manager = MemoryManager.getInstance();
    125126
    126         manager.isAvailable(-10);
     127        assertThrows(IllegalArgumentException.class, () -> manager.isAvailable(-10));
    127128    }
    128129
     
    132133     */
    133134    @Test
    134     public void testResetState() throws NotEnoughMemoryException {
     135    void testResetState() throws NotEnoughMemoryException {
    135136        MemoryManager manager = MemoryManager.getInstance();
    136137        assertTrue(manager.resetState().isEmpty());
     
    147148     * @throws NotEnoughMemoryException if there is not enough memory
    148149     */
    149     @Test(expected = IllegalStateException.class)
    150     public void testResetStateUseAfterFree() throws NotEnoughMemoryException {
     150    @Test
     151    void testResetStateUseAfterFree() throws NotEnoughMemoryException {
    151152        MemoryManager manager = MemoryManager.getInstance();
    152153        MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new);
    153154
    154155        assertFalse(manager.resetState().isEmpty());
    155         testMemory.get();
     156        assertThrows(IllegalStateException.class, () -> testMemory.get());
    156157    }
    157158
     
    163164        List<MemoryHandle<?>> hadLeaks = MemoryManager.getInstance().resetState();
    164165        if (!allowMemoryManagerLeaks) {
    165             assertTrue("Memory manager had leaking memory: " + hadLeaks, hadLeaks.isEmpty());
     166            assertTrue(hadLeaks.isEmpty(), "Memory manager had leaking memory: " + hadLeaks);
    166167        }
    167168    }
  • trunk/test/unit/org/openstreetmap/josm/tools/MultiMapTest.java

    r15870 r17275  
    22package org.openstreetmap.josm.tools;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    99import java.util.Arrays;
     
    1313import java.util.Set;
    1414
    15 import org.junit.Test;
     15import org.junit.jupiter.api.Test;
    1616import org.openstreetmap.josm.TestUtils;
    1717
     
    2121 * Unit tests of {@link MultiMap} class.
    2222 */
    23 public class MultiMapTest {
     23class MultiMapTest {
    2424
    2525    /**
     
    2727     */
    2828    @Test
    29     public void testEqualsContract() {
     29    void testEqualsContract() {
    3030        TestUtils.assumeWorkingEqualsVerifier();
    3131        EqualsVerifier.forClass(MultiMap.class).usingGetClass().verify();
     
    3636     */
    3737    @Test
    38     public void testMultiMap() {
     38    void testMultiMap() {
    3939        final MultiMap<String, String> map = new MultiMap<>();
    4040        assertTrue(map.isEmpty());
  • trunk/test/unit/org/openstreetmap/josm/tools/OptionParserTest.java

    r16618 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    77import static org.junit.jupiter.api.Assertions.assertThrows;
    88
     
    1313import java.util.concurrent.atomic.AtomicReference;
    1414
    15 import org.junit.Rule;
    16 import org.junit.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
     16import org.junit.jupiter.api.Test;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
    1818import org.openstreetmap.josm.tools.OptionParser.OptionCount;
     
    2525 * @author Michael Zangl
    2626 */
    27 public class OptionParserTest {
     27class OptionParserTest {
    2828    /**
    2929     * Setup test.
    3030     */
    31     @Rule
     31    @RegisterExtension
    3232    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3333    public JOSMTestRules test = new JOSMTestRules().i18n();
     
    3535    // A reason for moving to jupiter...
    3636    @Test
    37     public void testEmptyParserRejectsLongopt() {
     37    void testEmptyParserRejectsLongopt() {
    3838        Exception e = assertThrows(OptionParseException.class, () ->
    3939                new OptionParser("test").parseOptions(Arrays.asList("--long")));
     
    4242
    4343    @Test
    44     public void testEmptyParserRejectsShortopt() {
     44    void testEmptyParserRejectsShortopt() {
    4545        Exception e = assertThrows(OptionParseException.class, () ->
    4646                new OptionParser("test").parseOptions(Arrays.asList("-s")));
     
    4949
    5050    @Test
    51     public void testParserRejectsWrongShortopt() {
     51    void testParserRejectsWrongShortopt() {
    5252        Exception e = assertThrows(OptionParseException.class, () ->
    5353                new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", "t")
     
    5757
    5858    @Test
    59     public void testParserRejectsWrongLongopt() {
     59    void testParserRejectsWrongLongopt() {
    6060        Exception e = assertThrows(OptionParseException.class, () ->
    6161                new OptionParser("test").addFlagParameter("test", this::nop).parseOptions(Arrays.asList("--wrong")));
     
    6464
    6565    @Test
    66     public void testParserOption() {
     66    void testParserOption() {
    6767        AtomicReference<String> argFound = new AtomicReference<>();
    6868        OptionParser parser = new OptionParser("test")
     
    7474
    7575    @Test
    76     public void testParserOptionFailsIfMissing() {
     76    void testParserOptionFailsIfMissing() {
    7777        AtomicReference<String> argFound = new AtomicReference<>();
    7878        OptionParser parser = new OptionParser("test")
     
    8484
    8585    @Test
    86     public void testParserOptionFailsIfMissingArgument() {
     86    void testParserOptionFailsIfMissingArgument() {
    8787        AtomicReference<String> argFound = new AtomicReference<>();
    8888        OptionParser parser = new OptionParser("test")
     
    9494
    9595    @Test
    96     public void testParserOptionFailsIfMissing2() {
     96    void testParserOptionFailsIfMissing2() {
    9797        AtomicReference<String> argFound = new AtomicReference<>();
    9898        OptionParser parser = new OptionParser("test")
     
    104104
    105105    @Test
    106     public void testParserOptionFailsIfTwice() {
     106    void testParserOptionFailsIfTwice() {
    107107        AtomicReference<String> argFound = new AtomicReference<>();
    108108        OptionParser parser = new OptionParser("test")
     
    114114
    115115    @Test
    116     public void testParserOptionFailsIfTwiceForAlias() {
     116    void testParserOptionFailsIfTwiceForAlias() {
    117117        AtomicReference<String> argFound = new AtomicReference<>();
    118118        OptionParser parser = new OptionParser("test")
     
    125125
    126126    @Test
    127     public void testOptionalOptionFailsIfTwice() {
     127    void testOptionalOptionFailsIfTwice() {
    128128        OptionParser parser = new OptionParser("test")
    129129                .addFlagParameter("test", this::nop);
     
    133133
    134134    @Test
    135     public void testOptionalOptionFailsIfTwiceForAlias() {
     135    void testOptionalOptionFailsIfTwiceForAlias() {
    136136        OptionParser parser = new OptionParser("test")
    137137                .addFlagParameter("test", this::nop)
     
    142142
    143143    @Test
    144     public void testOptionalOptionFailsIfTwiceForAlias2() {
     144    void testOptionalOptionFailsIfTwiceForAlias2() {
    145145        OptionParser parser = new OptionParser("test")
    146146                .addFlagParameter("test", this::nop)
     
    151151
    152152    @Test
    153     public void testLongArgumentsUsingEqualSign() {
     153    void testLongArgumentsUsingEqualSign() {
    154154        AtomicReference<String> argFound = new AtomicReference<>();
    155155        OptionParser parser = new OptionParser("test")
     
    173173
    174174    @Test
    175     public void testLongArgumentsMissingOption() {
     175    void testLongArgumentsMissingOption() {
    176176        OptionParser parser = new OptionParser("test")
    177177                .addArgumentParameter("test", OptionCount.REQUIRED, this::nop);
     
    182182
    183183    @Test
    184     public void testLongArgumentsMissingOption2() {
     184    void testLongArgumentsMissingOption2() {
    185185        OptionParser parser = new OptionParser("test")
    186186                .addArgumentParameter("test", OptionCount.REQUIRED, this::nop);
     
    191191
    192192    @Test
    193     public void testShortArgumentsMissingOption() {
     193    void testShortArgumentsMissingOption() {
    194194        OptionParser parser = new OptionParser("test")
    195195                .addArgumentParameter("test", OptionCount.REQUIRED, this::nop)
     
    201201
    202202    @Test
    203     public void testShortArgumentsMissingOption2() {
     203    void testShortArgumentsMissingOption2() {
    204204        OptionParser parser = new OptionParser("test")
    205205                .addArgumentParameter("test", OptionCount.REQUIRED, this::nop)
     
    211211
    212212    @Test
    213     public void testLongFlagHasOption() {
     213    void testLongFlagHasOption() {
    214214        OptionParser parser = new OptionParser("test")
    215215                .addFlagParameter("test", this::nop);
     
    220220
    221221    @Test
    222     public void testShortFlagHasOption() {
     222    void testShortFlagHasOption() {
    223223        OptionParser parser = new OptionParser("test")
    224224                .addFlagParameter("test", this::nop)
     
    230230
    231231    @Test
    232     public void testShortArgumentsUsingEqualSign() {
     232    void testShortArgumentsUsingEqualSign() {
    233233        AtomicReference<String> argFound = new AtomicReference<>();
    234234        OptionParser parser = new OptionParser("test")
     
    243243
    244244    @Test
    245     public void testMultipleArguments() {
     245    void testMultipleArguments() {
    246246        AtomicReference<String> argFound = new AtomicReference<>();
    247247        List<String> multiFound = new ArrayList<>();
     
    266266
    267267    @Test
    268     public void testUseAlternatives() {
     268    void testUseAlternatives() {
    269269        AtomicReference<String> argFound = new AtomicReference<>();
    270270        AtomicBoolean usedFlag = new AtomicBoolean();
     
    285285
    286286    @Test
    287     public void testAmbiguousAlternatives() {
     287    void testAmbiguousAlternatives() {
    288288        AtomicReference<String> argFound = new AtomicReference<>();
    289289        AtomicBoolean usedFlag = new AtomicBoolean();
     
    300300
    301301    @Test
    302     public void testMultipleShort() {
     302    void testMultipleShort() {
    303303        AtomicReference<String> argFound = new AtomicReference<>();
    304304        AtomicBoolean usedFlag = new AtomicBoolean();
     
    328328
    329329    @Test
    330     public void testIllegalOptionName() {
     330    void testIllegalOptionName() {
    331331        Exception e = assertThrows(IllegalArgumentException.class, () ->
    332332                new OptionParser("test").addFlagParameter("", this::nop));
     
    335335
    336336    @Test
    337     public void testIllegalOptionName2() {
     337    void testIllegalOptionName2() {
    338338        Exception e = assertThrows(IllegalArgumentException.class, () ->
    339339                new OptionParser("test").addFlagParameter("-", this::nop));
     
    342342
    343343    @Test
    344     public void testIllegalOptionName3() {
     344    void testIllegalOptionName3() {
    345345        Exception e = assertThrows(IllegalArgumentException.class, () ->
    346346                new OptionParser("test").addFlagParameter("-test", this::nop));
     
    349349
    350350    @Test
    351     public void testIllegalOptionName4() {
     351    void testIllegalOptionName4() {
    352352        Exception e = assertThrows(IllegalArgumentException.class, () ->
    353353                new OptionParser("test").addFlagParameter("$", this::nop));
     
    356356
    357357    @Test
    358     public void testDuplicateOptionName() {
     358    void testDuplicateOptionName() {
    359359        Exception e = assertThrows(IllegalArgumentException.class, () ->
    360360                new OptionParser("test").addFlagParameter("test", this::nop).addFlagParameter("test", this::nop));
     
    363363
    364364    @Test
    365     public void testDuplicateOptionName2() {
     365    void testDuplicateOptionName2() {
    366366        Exception e = assertThrows(IllegalArgumentException.class, () ->
    367367                new OptionParser("test").addFlagParameter("test", this::nop)
     
    371371
    372372    @Test
    373     public void testInvalidShortAlias() {
     373    void testInvalidShortAlias() {
    374374        Exception e = assertThrows(IllegalArgumentException.class, () ->
    375375                new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", "$"));
     
    378378
    379379    @Test
    380     public void testInvalidShortAlias2() {
     380    void testInvalidShortAlias2() {
    381381        Exception e = assertThrows(IllegalArgumentException.class, () ->
    382382                new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", ""));
     
    385385
    386386    @Test
    387     public void testInvalidShortAlias3() {
     387    void testInvalidShortAlias3() {
    388388        Exception e = assertThrows(IllegalArgumentException.class, () ->
    389389                new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test", "xx"));
     
    392392
    393393    @Test
    394     public void testDuplicateShortAlias() {
     394    void testDuplicateShortAlias() {
    395395        Exception e = assertThrows(IllegalArgumentException.class, () ->
    396396                new OptionParser("test").addFlagParameter("test", this::nop)
     
    402402
    403403    @Test
    404     public void testInvalidShortNoLong() {
     404    void testInvalidShortNoLong() {
    405405        Exception e = assertThrows(IllegalArgumentException.class, () ->
    406406                new OptionParser("test").addFlagParameter("test", this::nop).addShortAlias("test2", "t"));
  • trunk/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java

    r16946 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    5 import org.junit.BeforeClass;
    6 import org.junit.Rule;
    7 import org.junit.Test;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7
     8import java.awt.Dimension;
     9import java.util.EnumSet;
     10
     11import javax.swing.ImageIcon;
     12
     13import org.junit.jupiter.api.BeforeAll;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
    816import org.openstreetmap.josm.JOSMFixture;
    917import org.openstreetmap.josm.data.osm.Node;
     
    1422import org.openstreetmap.josm.tools.OsmPrimitiveImageProvider.Options;
    1523
    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;
     24import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2425
    2526/**
    2627 * Unit tests of {@link OsmPrimitiveImageProvider}
    2728 */
    28 public class OsmPrimitiveImageProviderTest {
     29class OsmPrimitiveImageProviderTest {
    2930
    3031    /**
    3132     * Setup test.
    3233     */
    33     @Rule
     34    @RegisterExtension
    3435    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3536    public JOSMTestRules test = new JOSMTestRules().mapStyles().presets();
     
    3839     * Setup test.
    3940     */
    40     @BeforeClass
     41    @BeforeAll
    4142    public static void setUp() {
    4243        JOSMFixture.createUnitTestFixture().init();
     
    4748     */
    4849    @Test
    49     public void testGetResource() {
     50    void testGetResource() {
    5051        TaggingPresetsTest.waitForIconLoading(TaggingPresets.getTaggingPresets());
    5152
     
    6768     */
    6869    @Test
    69     public void testGetResourceNonSquare() {
     70    void testGetResourceNonSquare() {
    7071        final ImageIcon bankIcon = OsmPrimitiveImageProvider
    7172                .getResource(OsmUtils.createPrimitive("node amenity=bank"), Options.DEFAULT)
  • trunk/test/unit/org/openstreetmap/josm/tools/OsmUrlToBoundsTest.java

    r12802 r17275  
    33
    44import org.junit.Assert;
    5 import org.junit.Rule;
    6 import org.junit.Test;
     5import org.junit.jupiter.api.extension.RegisterExtension;
     6import org.junit.jupiter.api.Test;
    77import org.openstreetmap.josm.data.Bounds;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1313  * Unit tests of {@link OsmUrlToBounds} class.
    1414*/
    15 public class OsmUrlToBoundsTest {
     15class OsmUrlToBoundsTest {
    1616
    1717    /**
    1818     * Setup test.
    1919     */
    20     @Rule
     20    @RegisterExtension
    2121    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2222    public JOSMTestRules test = new JOSMTestRules();
     
    2626     */
    2727    @Test
    28     public void testPositionToBounds() {
     28    void testPositionToBounds() {
    2929        Assert.assertEquals(new Bounds(51.7167359, 8.7573485, 51.720724, 8.7659315),
    3030                OsmUrlToBounds.positionToBounds(51.71873, 8.76164, 17));
     
    9191     */
    9292    @Test
    93     public void testParse() {
     93    void testParse() {
    9494        for (ParseTestItem item : parseTestData) {
    9595            Bounds bounds = null;
     
    108108     */
    109109    @Test
    110     public void testGetZoom() {
     110    void testGetZoom() {
    111111        Assert.assertEquals(4, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(0, 0, 4)));
    112112        Assert.assertEquals(10, OsmUrlToBounds.getZoom(OsmUrlToBounds.positionToBounds(5, 5, 10)));
  • trunk/test/unit/org/openstreetmap/josm/tools/PairTest.java

    r13079 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import org.junit.Test;
     4import org.junit.jupiter.api.Test;
    55import org.openstreetmap.josm.TestUtils;
    66
     
    1111 * Unit tests of {@link Pair} class.
    1212 */
    13 public class PairTest {
     13class PairTest {
    1414
    1515    /**
     
    1717     */
    1818    @Test
    19     public void testEqualsContract() {
     19    void testEqualsContract() {
    2020        TestUtils.assumeWorkingEqualsVerifier();
    2121        EqualsVerifier.forClass(Pair.class).suppress(Warning.NONFINAL_FIELDS).verify();
  • trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookOsxTest.java

    r15469 r17275  
    22package org.openstreetmap.josm.tools;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8import static org.junit.jupiter.api.Assumptions.assumeTrue;
    89
    910import java.io.File;
    1011import java.io.IOException;
    1112
    12 import org.junit.Assume;
    13 import org.junit.BeforeClass;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.BeforeAll;
     14import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.JOSMFixture;
    1616import org.openstreetmap.josm.spi.preferences.Config;
     
    1919 * Unit tests of {@link PlatformHookOsx} class.
    2020 */
    21 public class PlatformHookOsxTest {
     21class PlatformHookOsxTest {
    2222
    2323    static PlatformHookOsx hook;
     
    2626     * Setup test.
    2727     */
    28     @BeforeClass
     28    @BeforeAll
    2929    public static void setUp() {
    3030        JOSMFixture.createUnitTestFixture().init();
     
    3636     */
    3737    @Test
    38     public void testStartupHook() {
     38    void testStartupHook() {
    3939        hook.startupHook((a, b, c, d) -> System.out.println("callback"));
    4040    }
     
    4444     */
    4545    @Test
    46     public void testAfterPrefStartupHook() {
     46    void testAfterPrefStartupHook() {
    4747        hook.afterPrefStartupHook();
    4848    }
     
    5353     */
    5454    @Test
    55     public void testOpenUrl() throws IOException {
    56         Assume.assumeTrue(PlatformManager.isPlatformOsx());
     55    void testOpenUrl() throws IOException {
     56        assumeTrue(PlatformManager.isPlatformOsx());
    5757        hook.openUrl(Config.getUrls().getJOSMWebsite());
    5858    }
     
    6262     */
    6363    @Test
    64     public void testGetDefaultCacheDirectory() {
     64    void testGetDefaultCacheDirectory() {
    6565        File cache = hook.getDefaultCacheDirectory();
    6666        assertNotNull(cache);
     
    7474     */
    7575    @Test
    76     public void testGetDefaultPrefDirectory() {
     76    void testGetDefaultPrefDirectory() {
    7777        File cache = hook.getDefaultPrefDirectory();
    7878        assertNotNull(cache);
     
    8686     */
    8787    @Test
    88     public void testGetDefaultStyle() {
     88    void testGetDefaultStyle() {
    8989        assertEquals("com.apple.laf.AquaLookAndFeel", hook.getDefaultStyle());
    9090    }
     
    9494     */
    9595    @Test
    96     public void testGetOSDescription() {
     96    void testGetOSDescription() {
    9797        String os = hook.getOSDescription();
    9898        if (PlatformManager.isPlatformOsx()) {
     
    107107     */
    108108    @Test
    109     public void testInitSystemShortcuts() {
     109    void testInitSystemShortcuts() {
    110110        hook.initSystemShortcuts();
    111111    }
  • trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookTestIT.java

    r15480 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.io.StringReader;
     
    1010import javax.json.Json;
    1111
    12 import org.junit.Rule;
    13 import org.junit.Test;
     12import org.junit.jupiter.api.Test;
     13import org.junit.jupiter.api.extension.RegisterExtension;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515
     
    1919 * Integration tests of {@link PlatformHook} class.
    2020 */
    21 public class PlatformHookTestIT {
     21class PlatformHookTestIT {
    2222
    2323    /**
    2424     * Setup rule
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules();
     
    3333     */
    3434    @Test
    35     public void testLatestUbuntuVersion() throws Exception {
     35    void testLatestUbuntuVersion() throws Exception {
    3636        String latestUbuntuVersion = Json.createReader(new StringReader(HttpClient.create(
    3737                new URL("https://api.launchpad.net/devel/ubuntu/series")).connect().fetchContent()))
    3838                .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);
    4142    }
    4243}
  • trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java

    r17126 r17275  
    3030 * Unit tests of {@link PlatformHookWindows} class.
    3131 */
    32 public class PlatformHookWindowsTest {
     32class PlatformHookWindowsTest {
    3333
    3434    /**
     
    5353     */
    5454    @Test
    55     public void testStartupHook() {
     55    void testStartupHook() {
    5656        hook.startupHook((a, b, c, d) -> System.out.println("callback"));
    5757    }
     
    6262     */
    6363    @Test
    64     public void testGetRootKeystore() throws Exception {
     64    void testGetRootKeystore() throws Exception {
    6565        if (PlatformManager.isPlatformWindows()) {
    6666            assertNotNull(PlatformHookWindows.getRootKeystore());
     
    7979     */
    8080    @Test
    81     public void testAfterPrefStartupHook() {
     81    void testAfterPrefStartupHook() {
    8282        hook.afterPrefStartupHook();
    8383    }
     
    8989     */
    9090    @Test
    91     public void testOpenUrlSuccess(@Mocked final Desktop mockDesktop) throws IOException {
     91    void testOpenUrlSuccess(@Mocked final Desktop mockDesktop) throws IOException {
    9292        TestUtils.assumeWorkingJMockit();
    9393        new Expectations() {{
     
    107107     */
    108108    @Test
    109     public void testOpenUrlFallback(@Mocked final Desktop mockDesktop, @Mocked Runtime anyRuntime) throws IOException {
     109    void testOpenUrlFallback(@Mocked final Desktop mockDesktop, @Mocked Runtime anyRuntime) throws IOException {
    110110        TestUtils.assumeWorkingJMockit();
    111111        new Expectations() {{
     
    130130     */
    131131    @Test
    132     public void testGetAdditionalFonts() {
     132    void testGetAdditionalFonts() {
    133133        assertFalse(hook.getAdditionalFonts().isEmpty());
    134134    }
     
    138138     */
    139139    @Test
    140     public void testGetDefaultCacheDirectory() {
     140    void testGetDefaultCacheDirectory() {
    141141        File cache = hook.getDefaultCacheDirectory();
    142142        assertNotNull(cache);
     
    150150     */
    151151    @Test
    152     public void testGetDefaultPrefDirectory() {
     152    void testGetDefaultPrefDirectory() {
    153153        File cache = hook.getDefaultPrefDirectory();
    154154        assertNotNull(cache);
     
    162162     */
    163163    @Test
    164     public void testGetDefaultStyle() {
     164    void testGetDefaultStyle() {
    165165        assertEquals("com.sun.java.swing.plaf.windows.WindowsLookAndFeel", hook.getDefaultStyle());
    166166    }
     
    170170     */
    171171    @Test
    172     public void testGetInstalledFonts() {
     172    void testGetInstalledFonts() {
    173173        Collection<String> fonts = hook.getInstalledFonts();
    174174        if (PlatformManager.isPlatformWindows()) {
     
    183183     */
    184184    @Test
    185     public void testGetOSDescription() {
     185    void testGetOSDescription() {
    186186        String os = hook.getOSDescription();
    187187        if (PlatformManager.isPlatformWindows()) {
     
    196196     */
    197197    @Test
    198     public void testInitSystemShortcuts() {
     198    void testInitSystemShortcuts() {
    199199        hook.initSystemShortcuts();
    200200    }
  • trunk/test/unit/org/openstreetmap/josm/tools/RightAndLefthandTrafficTest.java

    r16321 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.fail;
    55
    6 import org.junit.Rule;
    7 import org.junit.Test;
     6import org.junit.jupiter.api.extension.RegisterExtension;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.data.coor.LatLon;
    99import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1515 * Unit tests of {@link RightAndLefthandTraffic} class.
    1616 */
    17 public class RightAndLefthandTrafficTest {
     17class RightAndLefthandTrafficTest {
    1818    /**
    1919     * Test rules.
    2020     */
    21     @Rule
     21    @RegisterExtension
    2222    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2323    public JOSMTestRules rules = new JOSMTestRules().projection().territories();
     
    2828     */
    2929    @Test
    30     public void testUtilityClass() throws ReflectiveOperationException {
     30    void testUtilityClass() throws ReflectiveOperationException {
    3131        UtilityClassTestUtil.assertUtilityClassWellDefined(RightAndLefthandTraffic.class);
    3232    }
     
    3636     */
    3737    @Test
    38     public void testIsRightHandTraffic() {
     38    void testIsRightHandTraffic() {
    3939        check(true, "Paris", 48.8567, 2.3508);
    4040        check(true, "Berlin", 52.5167, 13.383);
  • trunk/test/unit/org/openstreetmap/josm/tools/RotationAngleTest.java

    r12802 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertThrows;
    56
    6 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    78
    89/**
    910 * Unit tests of {@link RotationAngle} class.
    1011 */
    11 public class RotationAngleTest {
     12class RotationAngleTest {
    1213
    1314    private static final double EPSILON = 1e-11;
     
    1718     */
    1819    @Test
    19     public void testParseCardinal() {
     20    void testParseCardinal() {
    2021        assertEquals(Math.PI, RotationAngle.buildStaticRotation("south").getRotationAngle(null), EPSILON);
    2122        assertEquals(Math.PI, RotationAngle.buildStaticRotation("s").getRotationAngle(null), EPSILON);
     
    2627     * Unit test of method {@link RotationAngle#buildStaticRotation} - wrong parameter.
    2728     */
    28     @Test(expected = IllegalArgumentException.class)
    29     public void testParseFail() {
    30         RotationAngle.buildStaticRotation("bad");
     29    @Test
     30    void testParseFail() {
     31        assertThrows(IllegalArgumentException.class, () -> RotationAngle.buildStaticRotation("bad"));
    3132    }
    3233
     
    3435     * Unit test of method {@link RotationAngle#buildStaticRotation} - null handling.
    3536     */
    36     @Test(expected = NullPointerException.class)
    37     public void testParseNull() {
    38         RotationAngle.buildStaticRotation(null);
     37    @Test
     38    void testParseNull() {
     39        assertThrows(NullPointerException.class, () -> RotationAngle.buildStaticRotation(null));
    3940    }
    4041}
  • trunk/test/unit/org/openstreetmap/josm/tools/SearchCompilerQueryWizardTest.java

    r16413 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
    5 
    6 import org.junit.Ignore;
    7 import org.junit.Rule;
    8 import org.junit.Test;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertThrows;
     6
     7import org.junit.jupiter.api.Disabled;
     8import org.junit.jupiter.api.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
    910import org.openstreetmap.josm.testutils.JOSMTestRules;
    1011
     
    1415 * Unit tests of {@link SearchCompilerQueryWizard} class.
    1516 */
    16 public class SearchCompilerQueryWizardTest {
     17class SearchCompilerQueryWizardTest {
    1718    /**
    1819     * Base test environment is enough
    1920     */
    20     @Rule
     21    @RegisterExtension
    2122    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2223    public JOSMTestRules test = new JOSMTestRules().i18n("de");
     
    4142     */
    4243    @Test
    43     public void testKeyValue() {
     44    void testKeyValue() {
    4445        assertQueryEquals("  nwr[\"amenity\"=\"drinking_water\"];\n", "amenity=drinking_water");
    4546        assertQueryEquals("  nwr[\"amenity\"];\n", "amenity=*");
     
    5051     */
    5152    @Test
    52     public void testKeyNotValue() {
     53    void testKeyNotValue() {
    5354        assertQueryEquals("  nwr[\"amenity\"!=\"drinking_water\"];\n", "-amenity=drinking_water");
    5455        assertQueryEquals("  nwr[!\"amenity\"];\n", "-amenity=*");
     
    5960     */
    6061    @Test
    61     public void testKeyLikeValue() {
     62    void testKeyLikeValue() {
    6263        assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo~bar");
    6364        assertQueryEquals("  nwr[\"foo\"~\"bar\"];\n", "foo~/bar/");
     
    7374     */
    7475    @Test
    75     public void testOsmBoolean() {
     76    void testOsmBoolean() {
    7677        assertQueryEquals("  nwr[\"highway\"][\"oneway\"~\"true|yes|1|on\"];\n", "highway=* AND oneway?");
    7778        assertQueryEquals("  nwr[\"highway\"][\"oneway\"~\"false|no|0|off\"];\n", "highway=* AND -oneway?");
     
    8283     */
    8384    @Test
    84     public void testBooleanAnd() {
     85    void testBooleanAnd() {
    8586        assertQueryEquals("  nwr[\"foo\"=\"bar\"][\"baz\"=\"42\"];\n", "foo=bar and baz=42");
    8687        assertQueryEquals("  nwr[\"foo\"=\"bar\"][\"baz\"=\"42\"];\n", "foo=bar && baz=42");
     
    9293     */
    9394    @Test
    94     public void testBooleanOr() {
     95    void testBooleanOr() {
    9596        assertQueryEquals("  nwr[\"foo\"=\"bar\"];\n  nwr[\"baz\"=\"42\"];\n", "foo=bar or baz=42");
    9697        assertQueryEquals("  nwr[\"foo\"=\"bar\"];\n  nwr[\"baz\"=\"42\"];\n", "foo=bar | baz=42");
     
    101102     */
    102103    @Test
    103     public void testBoolean() {
     104    void testBoolean() {
    104105        assertQueryEquals("" +
    105106                "  nwr[\"foo\"][\"baz1\"];\n" +
     
    118119     */
    119120    @Test
    120     public void testType() {
     121    void testType() {
    121122        assertQueryEquals("  node[\"foo\"=\"bar\"];\n  way[\"foo\"=\"bar\"];\n", "foo=bar and (type:node or type:way)");
    122123    }
     
    126127     */
    127128    @Test
    128     public void testUser() {
     129    void testUser() {
    129130        assertQueryEquals("  nwr(user:\"foo\");\n  nwr(uid:42);\n", "user:foo or user:42");
    130131    }
     
    134135     */
    135136    @Test
    136     public void testEmpty() {
     137    void testEmpty() {
    137138        assertQueryEquals("  way[\"foo\"~\"^$\"];\n", "foo=\"\" and type:way");
    138139    }
     
    142143     */
    143144    @Test
    144     public void testInArea() {
     145    void testInArea() {
    145146        String query = constructQuery("foo=bar | foo=baz in Innsbruck");
    146147        assertEquals("" +
     
    179180     */
    180181    @Test
    181     public void testAroundArea() {
     182    void testAroundArea() {
    182183        final String query = constructQuery("foo=bar | foo=baz around \"Sankt Sigmund im Sellrain\"");
    183184        assertEquals("" +
     
    196197     */
    197198    @Test
    198     public void testGlobal() {
     199    void testGlobal() {
    199200        final String query = constructQuery("foo=bar global");
    200201        assertEquals("" +
     
    211212     */
    212213    @Test
    213     public void testInBbox() {
     214    void testInBbox() {
    214215        assertQueryEquals("  nwr[\"foo\"=\"bar\"];\n", "foo=bar IN BBOX");
    215216    }
     
    219220     */
    220221    @Test
    221     @Ignore("preset handling not implemented")
    222     public void testPreset() {
     222    @Disabled("preset handling not implemented")
     223    void testPreset() {
    223224        assertQueryEquals("  nwr[\"amenity\"=\"hospital\"];\n", "Hospital");
    224225    }
     
    227228     * Test erroneous value.
    228229     */
    229     @Test(expected = UncheckedParseException.class)
    230     public void testErroneous() {
    231         constructQuery("-(foo or bar)");
     230    @Test
     231    void testErroneous() {
     232        assertThrows(UncheckedParseException.class, () -> constructQuery("-(foo or bar)"));
    232233    }
    233234
     
    236237     */
    237238    @Test
    238     public void testTicket19151() {
     239    void testTicket19151() {
    239240        assertQueryEquals("  relation[\"type\"=\"multipolygon\"][!\"landuse\"][!\"area:highway\"];\n",
    240241                "type:relation and type=multipolygon and -landuse=* and -\"area:highway\"=*");
  • trunk/test/unit/org/openstreetmap/josm/tools/ShortcutTest.java

    r17180 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.awt.event.InputEvent;
     
    99import javax.swing.KeyStroke;
    1010
    11 import org.junit.BeforeClass;
    12 import org.junit.Test;
     11import org.junit.jupiter.api.BeforeAll;
     12import org.junit.jupiter.api.Test;
    1313import org.openstreetmap.josm.JOSMFixture;
    1414
     
    1616 * Unit tests of {@link Shortcut} class.
    1717 */
    18 public class ShortcutTest {
     18class ShortcutTest {
    1919
    2020    /**
    2121     * Setup test.
    2222     */
    23     @BeforeClass
     23    @BeforeAll
    2424    public static void setUp() {
    2525        JOSMFixture.createUnitTestFixture().init();
     
    3030     */
    3131    @Test
    32     public void testMakeTooltip() {
     32    void testMakeTooltip() {
    3333        final String tooltip = Shortcut.makeTooltip("Foo Bar", KeyStroke.getKeyStroke(KeyEvent.VK_J, InputEvent.SHIFT_DOWN_MASK));
    3434        if (Platform.determinePlatform() == Platform.OSX) {
  • trunk/test/unit/org/openstreetmap/josm/tools/StreamUtilsTest.java

    r16182 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import org.junit.Rule;
    5 import org.junit.Test;
     4import org.junit.jupiter.api.extension.RegisterExtension;
     5import org.junit.jupiter.api.Test;
    66import org.openstreetmap.josm.testutils.JOSMTestRules;
    77
    8 import static org.junit.Assert.assertEquals;
     8import static org.junit.jupiter.api.Assertions.assertEquals;
    99
    1010import java.util.Arrays;
     
    1717 * Unit tests of {@link StreamUtils} class.
    1818 */
    19 public class StreamUtilsTest {
     19class StreamUtilsTest {
    2020
    2121    /**
    2222     * Setup rule.
    2323     */
    24     @Rule
     24    @RegisterExtension
    2525    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2626    public JOSMTestRules test = new JOSMTestRules();
     
    3131     */
    3232    @Test
    33     public void testUtilityClass() throws ReflectiveOperationException {
     33    void testUtilityClass() throws ReflectiveOperationException {
    3434        UtilityClassTestUtil.assertUtilityClassWellDefined(StreamUtils.class);
    3535    }
     
    3939     */
    4040    @Test
    41     public void testReverseStream() {
     41    void testReverseStream() {
    4242        assertEquals("baz/bar/foo",
    4343                StreamUtils.reversedStream(Arrays.asList("foo", "bar", "baz")).collect(Collectors.joining("/")));
  • trunk/test/unit/org/openstreetmap/josm/tools/StringParserTest.java

    r16618 r17275  
    44import static org.hamcrest.CoreMatchers.is;
    55import static org.hamcrest.MatcherAssert.assertThat;
    6 import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertTrue;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
    89
    910import java.util.Optional;
    1011
    11 import org.junit.Test;
     12import org.junit.jupiter.api.Test;
    1213
    1314import net.trajano.commons.testing.UtilityClassTestUtil;
     
    1617 * Unit tests of {@link StringParser} class.
    1718 */
    18 public class StringParserTest {
     19class StringParserTest {
    1920
    2021    /**
     
    2425     */
    2526    @Test
    26     public void testUtilityClass() throws ReflectiveOperationException {
     27    void testUtilityClass() throws ReflectiveOperationException {
    2728        UtilityClassTestUtil.assertUtilityClassWellDefined(Utils.class);
    2829    }
     
    3233     */
    3334    @Test
    34     public void testParse() {
     35    void testParse() {
    3536        assertThat(StringParser.DEFAULT.parse(char.class, "josm"), is('j'));
    3637        assertThat(StringParser.DEFAULT.parse(short.class, "123"), is((short) 123));
     
    4445     * Tests that {@link StringParser#DEFAULT} is immutable.
    4546     */
    46     @Test(expected = UnsupportedOperationException.class)
    47     public void 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));
    4950    }
    5051
     
    5354     */
    5455    @Test
    55     public void testCopyConstructor() {
     56    void testCopyConstructor() {
    5657        final StringParser parser = new StringParser(StringParser.DEFAULT).registerParser(boolean.class, "JOSM"::equals);
    5758        assertTrue(StringParser.DEFAULT.parse(boolean.class, "true"));
  • trunk/test/unit/org/openstreetmap/josm/tools/Tag2LinkTest.java

    r17006 r17275  
    77
    88import org.junit.Assert;
    9 import org.junit.Rule;
    10 import org.junit.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
     10import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.testutils.JOSMTestRules;
    1212
     
    1616 * Test {@link Tag2Link}
    1717 */
    18 public class Tag2LinkTest {
     18class Tag2LinkTest {
    1919
    2020    List<String> links = new ArrayList<>();
     
    3131     * Setup test.
    3232     */
    33     @Rule
     33    @RegisterExtension
    3434    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3535    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3939     */
    4040    @Test
    41     public void testInitialize() {
     41    void testInitialize() {
    4242        Tag2Link.initialize();
    4343        Assert.assertTrue("obtains at least 40 rules", Tag2Link.wikidataRules.size() > 40);
     
    4848     */
    4949    @Test
    50     public void testName() {
     50    void testName() {
    5151        Tag2Link.getLinksForTag("name", "foobar", this::addLink);
    5252        checkLinks("Search on duckduckgo.com // https://duckduckgo.com/?q=foobar",
     
    5858     */
    5959    @Test
    60     public void testWebsite() {
     60    void testWebsite() {
    6161        Tag2Link.getLinksForTag("website", "http://www.openstreetmap.org/", this::addLink);
    6262        checkLinks("Open openstreetmap.org // http://www.openstreetmap.org/");
     
    7373     */
    7474    @Test
    75     public void testWikipedia() {
     75    void testWikipedia() {
    7676        Tag2Link.getLinksForTag("wikipedia", "de:Wohnhausgruppe Herderstraße", this::addLink);
    7777        checkLinks("View Wikipedia article // https://de.wikipedia.org/wiki/Wohnhausgruppe_Herderstraße");
     
    8585     */
    8686    @Test
    87     public void testImageCommonsImage() {
     87    void testImageCommonsImage() {
    8888        Tag2Link.getLinksForTag("image", "File:Witten Brücke Gasstraße.jpg", this::addLink);
    8989        checkLinks("View image on Wikimedia Commons // https://commons.wikimedia.org/wiki/File:Witten Brücke Gasstraße.jpg");
     
    9999     */
    100100    @Test
    101     public void testImageCommonsCategory() {
     101    void testImageCommonsCategory() {
    102102        Tag2Link.getLinksForTag("image", "category:JOSM", this::addLink);
    103103        checkLinks("View category on Wikimedia Commons // https://commons.wikimedia.org/wiki/category:JOSM");
     
    108108     */
    109109    @Test
    110     public void testBrandWikidata() {
     110    void testBrandWikidata() {
    111111        Tag2Link.getLinksForTag("brand:wikidata", "Q259340", this::addLink);
    112112        checkLinks("View Wikidata item // https://www.wikidata.org/wiki/Q259340");
     
    117117     */
    118118    @Test
    119     public void testArchipelagoWikidata() {
     119    void testArchipelagoWikidata() {
    120120        Tag2Link.getLinksForTag("archipelago:wikidata", "Q756987;Q756988", this::addLink);
    121121        checkLinks("View Wikidata item // https://www.wikidata.org/wiki/Q756987",
  • trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTest.java

    r16945 r17275  
    33
    44import 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;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    99import java.util.Arrays;
     
    1313import java.util.Set;
    1414
    15 import org.junit.Rule;
    16 import org.junit.Test;
     15import org.junit.jupiter.api.Test;
     16import org.junit.jupiter.api.extension.RegisterExtension;
    1717import org.openstreetmap.josm.TestUtils;
    1818import org.openstreetmap.josm.data.coor.LatLon;
     
    2525 * Unit tests of {@link Territories} class.
    2626 */
    27 public class TerritoriesTest {
     27class TerritoriesTest {
    2828    /**
    2929     * Test rules.
    3030     */
    31     @Rule
     31    @RegisterExtension
    3232    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3333    public JOSMTestRules rules = new JOSMTestRules().projection().territories();
     
    3939     */
    4040    @Test
    41     public void testUtilityClass() throws ReflectiveOperationException {
     41    void testUtilityClass() throws ReflectiveOperationException {
    4242        UtilityClassTestUtil.assertUtilityClassWellDefined(Territories.class);
    4343    }
     
    4747     */
    4848    @Test
    49     public void testIsIso3166Code() {
     49    void testIsIso3166Code() {
    5050        check("Paris", new LatLon(48.8567, 2.3508), "EU", "FR", "FX");
    5151    }
     
    5353    private static void check(String name, LatLon ll, String... expectedCodes) {
    5454        for (String e : expectedCodes) {
    55             assertTrue(name + " " + e, Territories.isIso3166Code(e, ll));
     55            assertTrue(Territories.isIso3166Code(e, ll), name + " " + e);
    5656        }
    5757    }
     
    6161     */
    6262    @Test
    63     public void testTaginfoGeofabrik_nominal() {
     63    void testTaginfoGeofabrik_nominal() {
    6464        Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "/taginfo/geofabrik-index-v1-nogeom.json");
    6565        Map<String, TaginfoRegionalInstance> cache = Territories.taginfoGeofabrikCache;
     
    8686     */
    8787    @Test
    88     public void testTaginfoGeofabrik_broken() {
     88    void testTaginfoGeofabrik_broken() {
    8989        Logging.clearLastErrorAndWarnings();
    9090        Territories.initializeExternalData("foo", TestUtils.getTestDataRoot() + "taginfo/geofabrik-index-v1-nogeom-broken.json");
     
    9292        assertTrue(cache.isEmpty());
    9393        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);
    9696    }
    9797
     
    100100     */
    101101    @Test
    102     public void testGetCustomTags() {
     102    void testGetCustomTags() {
    103103        assertNull(Territories.getCustomTags(null));
    104104        assertNull(Territories.getCustomTags("foo"));
  • trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTestIT.java

    r16602 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
    66
    77import java.util.Collections;
    88
    9 import org.junit.Rule;
    10 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
     10import org.junit.jupiter.api.extension.RegisterExtension;
    1111import org.openstreetmap.josm.testutils.JOSMTestRules;
    1212
     
    1616 * Integration tests of {@link Territories} class.
    1717 */
    18 public class TerritoriesTestIT {
     18class TerritoriesTestIT {
    1919
    2020    /**
    2121     * Test rules.
    2222     */
    23     @Rule
     23    @RegisterExtension
    2424    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2525    public JOSMTestRules rules = new JOSMTestRules().projection();
     
    3030     */
    3131    @Test
    32     public void testUtilityClass() {
     32    void testUtilityClass() {
    3333        Logging.clearLastErrorAndWarnings();
    3434        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");
    4040    }
    4141}
  • trunk/test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java

    r16472 r17275  
    22package org.openstreetmap.josm.tools;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.util.ArrayList;
     
    1111import java.util.Map;
    1212
    13 import org.junit.Rule;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.extension.RegisterExtension;
     14import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616
     
    2020 * Unit tests of {@link TextTagParser} class.
    2121 */
    22 public class TextTagParserTest {
     22class TextTagParserTest {
    2323    /**
    2424     * Some of this depends on preferences.
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3232     */
    3333    @Test
    34     public void testUnescape() {
     34    void testUnescape() {
    3535        String s, s1;
    3636        s = "\"2 3 4\"";
     
    5555     */
    5656    @Test
    57     public void testTNformat() {
     57    void testTNformat() {
    5858        String txt = "   a  \t  1   \n\n\n  b\t2 \n c \t the value with \"quotes\"";
    5959        Map<String, String> correctTags = new HashMap<String, String>() { {
     
    6868     */
    6969    @Test
    70     public void testEQformat() {
     70    void testEQformat() {
    7171        String txt = "key1=value key2=\"long value\" tag3=\"hotel \\\"Quote\\\"\"";
    7272        Map<String, String> correctTags = new HashMap<String, String>() { {
     
    8282     */
    8383    @Test
    84     public void testJSONformat() {
     84    void testJSONformat() {
    8585        String txt;
    8686        Map<String, String> tags, correctTags;
     
    105105     */
    106106    @Test
    107     public void testFreeformat() {
     107    void testFreeformat() {
    108108        String txt = "a 1 b=2 c=\"hello === \\\"\\\"world\"";
    109109        Map<String, String> correctTags = new HashMap<String, String>() { {
     
    118118     */
    119119    @Test
    120     public void testErrorDetect() {
     120    void testErrorDetect() {
    121121        String txt = "a=2 b=3 4";
    122122        Map<String, String> tags = TextTagParser.readTagsFromText(txt);
     
    128128     */
    129129    @Test
    130     public void testTab() {
     130    void testTab() {
    131131        assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("shop\tjewelry"));
    132132        assertEquals(Collections.singletonMap("shop", "jewelry"), TextTagParser.readTagsFromText("!shop\tjewelry"));
     
    139139     */
    140140    @Test
    141     public void testTicket16104() {
     141    void testTicket16104() {
    142142        Map<String, String> expected = new HashMap<>();
    143143        expected.put("boundary", "national_park");
     
    170170     */
    171171    @Test
    172     public void testTicket8384Comment58() {
     172    void testTicket8384Comment58() {
    173173        Map<String, String> expected = new HashMap<>();
    174174        expected.put("name", "Main street");
     
    181181     */
    182182    @Test
    183     public void testStableOrder() {
     183    void testStableOrder() {
    184184        List<String> expected = Arrays.asList("foo4", "foo3", "foo2", "foo1");
    185185        ArrayList<String> actual = new ArrayList<>(TextTagParser.readTagsByRegexp(
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r17133 r17275  
    22package org.openstreetmap.josm.tools;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertSame;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
     9import static org.junit.jupiter.api.Assertions.assertTrue;
    910
    1011import java.io.File;
     
    2122import java.util.regex.Pattern;
    2223
    23 import org.junit.Rule;
    24 import org.junit.Test;
     24import org.junit.jupiter.api.Test;
     25import org.junit.jupiter.api.extension.RegisterExtension;
    2526import org.openstreetmap.josm.testutils.JOSMTestRules;
    2627
     
    3132 * Unit tests of {@link Utils} class.
    3233 */
    33 public class UtilsTest {
     34class UtilsTest {
    3435    /**
    3536     * Use default, basic test rules.
    3637     */
    37     @Rule
     38    @RegisterExtension
    3839    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3940    public JOSMTestRules rules = new JOSMTestRules();
     
    4445     */
    4546    @Test
    46     public void testUtilityClass() throws ReflectiveOperationException {
     47    void testUtilityClass() throws ReflectiveOperationException {
    4748        UtilityClassTestUtil.assertUtilityClassWellDefined(Utils.class);
    4849    }
     
    5253     */
    5354    @Test
    54     public void testStrip() {
     55    void testStrip() {
    5556        // CHECKSTYLE.OFF: SingleSpaceSeparator
    5657        final String someWhite =
     
    107108     */
    108109    @Test
    109     public void testIsStripEmpty() {
     110    void testIsStripEmpty() {
    110111        assertTrue(Utils.isStripEmpty(null));
    111112        assertTrue(Utils.isStripEmpty(""));
     
    123124     */
    124125    @Test
    125     public void testToHexString() {
     126    void testToHexString() {
    126127        assertEquals("", Utils.toHexString(null));
    127128        assertEquals("", Utils.toHexString(new byte[0]));
     
    137138     */
    138139    @Test
    139     public void testPositionListString() {
     140    void testPositionListString() {
    140141        assertEquals("1", Utils.getPositionListString(Arrays.asList(1)));
    141142        assertEquals("1-2", Utils.getPositionListString(Arrays.asList(1, 2)));
     
    150151     */
    151152    @Test
    152     public void testDurationString() {
     153    void testDurationString() {
    153154        I18n.set("en");
    154155        assertEquals("0 ms", Utils.getDurationString(0));
     
    169170     * Test of {@link Utils#getDurationString} method.
    170171     */
    171     @Test(expected = IllegalArgumentException.class)
    172     public void testDurationStringNegative() {
    173         Utils.getDurationString(-1);
     172    @Test
     173    void testDurationStringNegative() {
     174        assertThrows(IllegalArgumentException.class, () -> Utils.getDurationString(-1));
    174175    }
    175176
     
    178179     */
    179180    @Test
    180     public void testEscapeReservedCharactersHTML() {
     181    void testEscapeReservedCharactersHTML() {
    181182        assertEquals("foo -&gt; bar -&gt; '&amp;'", Utils.escapeReservedCharactersHTML("foo -> bar -> '&'"));
    182183    }
     
    186187     */
    187188    @Test
    188     public void testShortenString() {
     189    void testShortenString() {
    189190        assertNull(Utils.shortenString(null, 3));
    190191        assertEquals("...", Utils.shortenString("123456789", 3));
     
    200201     * Test of {@link Utils#shortenString} method.
    201202     */
    202     @Test(expected = IllegalArgumentException.class)
    203     public void testShortenStringTooShort() {
    204         Utils.shortenString("123456789", 2);
     203    @Test
     204    void testShortenStringTooShort() {
     205        assertThrows(IllegalArgumentException.class, () -> Utils.shortenString("123456789", 2));
    205206    }
    206207
     
    209210     */
    210211    @Test
    211     public void testRestrictStringLines() {
     212    void testRestrictStringLines() {
    212213        assertNull(Utils.restrictStringLines(null, 2));
    213214        assertEquals("1\n...", Utils.restrictStringLines("1\n2\n3", 2));
     
    220221     */
    221222    @Test
    222     public void testLimit() {
     223    void testLimit() {
    223224        assertNull(Utils.limit(null, 2, "..."));
    224225        assertEquals(Arrays.asList("1", "..."), Utils.limit(Arrays.asList("1", "2", "3"), 2, "..."));
     
    231232     */
    232233    @Test
    233     public void testSizeString() {
     234    void testSizeString() {
    234235        assertEquals("0 B", Utils.getSizeString(0, Locale.ENGLISH));
    235236        assertEquals("123 B", Utils.getSizeString(123, Locale.ENGLISH));
     
    251252     * Test of {@link Utils#getSizeString} method.
    252253     */
    253     @Test(expected = IllegalArgumentException.class)
    254     public void testSizeStringNegative() {
    255         Utils.getSizeString(-1, Locale.ENGLISH);
     254    @Test
     255    void testSizeStringNegative() {
     256        assertThrows(IllegalArgumentException.class, () -> Utils.getSizeString(-1, Locale.ENGLISH));
    256257    }
    257258
     
    260261     */
    261262    @Test
    262     public void testJoinAsHtmlUnorderedList() {
     263    void testJoinAsHtmlUnorderedList() {
    263264        List<? extends Object> items = Arrays.asList("1", Integer.valueOf(2));
    264265        assertEquals("<ul><li>1</li><li>2</li></ul>", Utils.joinAsHtmlUnorderedList(items));
     
    270271     */
    271272    @Test
    272     public void testGetJavaVersion() {
     273    void testGetJavaVersion() {
    273274        String javaVersion = System.getProperty("java.version");
    274275        try {
     
    302303     */
    303304    @Test
    304     public void testGetJavaUpdate() {
     305    void testGetJavaUpdate() {
    305306        String javaVersion = System.getProperty("java.version");
    306307        try {
     
    331332     */
    332333    @Test
    333     public void testGetJavaBuild() {
     334    void testGetJavaBuild() {
    334335        String javaVersion = System.getProperty("java.runtime.version");
    335336        try {
     
    363364     */
    364365    @Test
    365     public void 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");
    367368    }
    368369
     
    371372     */
    372373    @Test
    373     public void testLevenshteinDistance() {
     374    void testLevenshteinDistance() {
    374375        assertEquals(0, Utils.getLevenshteinDistance("foo", "foo"));
    375376        assertEquals(3, Utils.getLevenshteinDistance("foo", "bar"));
     
    384385     */
    385386    @Test
    386     public void testIsSimilar() {
     387    void testIsSimilar() {
    387388        assertFalse(Utils.isSimilar("foo", "foo"));
    388389        assertFalse(Utils.isSimilar("foo", "bar"));
     
    396397     */
    397398    @Test
    398     public void testStripHtml() {
     399    void testStripHtml() {
    399400        assertEquals("Hoogte 55 m", Utils.stripHtml(
    400401                "<table width=\"100%\"><tr>" +
     
    407408     */
    408409    @Test
    409     public void testFirstNonNull() {
     410    void testFirstNonNull() {
    410411        assertNull(Utils.firstNonNull());
    411412        assertNull(Utils.firstNonNull(null, null));
     
    417418     */
    418419    @Test
    419     public void testGetMatches() {
     420    void testGetMatches() {
    420421        final Pattern pattern = Pattern.compile("(foo)x(bar)y(baz)");
    421422        assertNull(Utils.getMatches(pattern.matcher("")));
     
    427428     */
    428429    @Test
    429     public void testEncodeUrl() {
     430    void testEncodeUrl() {
    430431        assertEquals("%C3%A4%C3%B6%C3%BC%C3%9F", Utils.encodeUrl("äöüß"));
    431432    }
     
    434435     * Test of {@link Utils#encodeUrl}
    435436     */
    436     @Test(expected = NullPointerException.class)
    437     public void testEncodeUrlNull() {
    438         Utils.encodeUrl(null);
     437    @Test
     438    void testEncodeUrlNull() {
     439        assertThrows(NullPointerException.class, () -> Utils.encodeUrl(null));
    439440    }
    440441
     
    443444     */
    444445    @Test
    445     public void testDecodeUrl() {
     446    void testDecodeUrl() {
    446447        assertEquals("äöüß", Utils.decodeUrl("%C3%A4%C3%B6%C3%BC%C3%9F"));
    447448    }
     
    450451     * Test of {@link Utils#decodeUrl}
    451452     */
    452     @Test(expected = NullPointerException.class)
    453     public void testDecodeUrlNull() {
    454         Utils.decodeUrl(null);
     453    @Test
     454    void testDecodeUrlNull() {
     455        assertThrows(NullPointerException.class, () -> Utils.decodeUrl(null));
    455456    }
    456457
     
    459460     */
    460461    @Test
    461     public void testClamp() {
     462    void testClamp() {
    462463        assertEquals(3, Utils.clamp(2, 3, 5));
    463464        assertEquals(3, Utils.clamp(3, 3, 5));
     
    475476     * Test of {@link Utils#clamp}
    476477     */
    477     @Test(expected = IllegalArgumentException.class)
    478     public void testClampIAE1() {
    479         Utils.clamp(0, 5, 4);
     478    @Test
     479    void testClampIAE1() {
     480        assertThrows(IllegalArgumentException.class, () -> Utils.clamp(0, 5, 4));
    480481    }
    481482
     
    483484     * Test of {@link Utils#clamp}
    484485     */
    485     @Test(expected = IllegalArgumentException.class)
    486     public void testClampIAE2() {
    487         Utils.clamp(0., 5., 4.);
     486    @Test
     487    void testClampIAE2() {
     488        assertThrows(IllegalArgumentException.class, () -> Utils.clamp(0., 5., 4.));
    488489    }
    489490
     
    492493     */
    493494    @Test
    494     public void testHasExtension() {
     495    void testHasExtension() {
    495496        assertFalse(Utils.hasExtension("JOSM.txt"));
    496497        assertFalse(Utils.hasExtension("JOSM.txt", "jpg"));
     
    504505     */
    505506    @Test
    506     public void testToUnmodifiableList() {
     507    void testToUnmodifiableList() {
    507508        assertSame(Collections.emptyList(), Utils.toUnmodifiableList(null));
    508509        assertSame(Collections.emptyList(), Utils.toUnmodifiableList(Collections.emptyList()));
     
    518519     */
    519520    @Test
    520     public void testToUnmodifiableMap() {
     521    void testToUnmodifiableMap() {
    521522        assertSame(Collections.emptyMap(), Utils.toUnmodifiableMap(null));
    522523        assertSame(Collections.emptyMap(), Utils.toUnmodifiableMap(Collections.emptyMap()));
     
    538539     */
    539540    @Test
    540     public void testExecOutput() throws Exception {
     541    void testExecOutput() throws Exception {
    541542        final String output = Utils.execOutput(Arrays.asList("echo", "Hello", "World"));
    542543        assertEquals("Hello World", output);
  • trunk/test/unit/org/openstreetmap/josm/tools/XmlUtilsTest.java

    r16560 r17275  
    33
    44import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    5 import org.junit.Rule;
    6 import org.junit.Test;
     5import org.junit.jupiter.api.extension.RegisterExtension;
     6import org.junit.jupiter.api.Test;
    77import org.openstreetmap.josm.TestUtils;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    2020import java.io.StringWriter;
    2121
    22 import static org.junit.Assert.assertEquals;
    23 import static org.junit.Assert.assertNotNull;
    24 import static org.junit.Assert.fail;
     22import static org.junit.jupiter.api.Assertions.assertEquals;
     23import static org.junit.jupiter.api.Assertions.assertNotNull;
     24import static org.junit.jupiter.api.Assertions.fail;
    2525
    2626/**
    2727 * Unit tests of {@link XmlUtils} class.
    2828 */
    29 public class XmlUtilsTest {
     29class XmlUtilsTest {
    3030
    3131    /**
    3232     * Use default, basic test rules.
    3333     */
    34     @Rule
     34    @RegisterExtension
    3535    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3636    public JOSMTestRules rules = new JOSMTestRules();
     
    4040
    4141    @Test
    42     public void testExternalEntitiesParsingDom() throws IOException, ParserConfigurationException {
     42    void testExternalEntitiesParsingDom() throws IOException, ParserConfigurationException {
    4343        try {
    4444            final String source = TestUtils.getTestDataRoot() + "dom_external_entity.xml";
     
    5252
    5353    @Test
    54     public void testExternalEntitiesTransformer() throws IOException {
     54    void testExternalEntitiesTransformer() throws IOException {
    5555        try {
    5656            final String source = TestUtils.getTestDataRoot() + "dom_external_entity.xml";
     
    6565
    6666    @Test
    67     public void testExternalEntitiesSaxParser() throws IOException, ParserConfigurationException {
     67    void testExternalEntitiesSaxParser() throws IOException, ParserConfigurationException {
    6868        try {
    6969            final String source = TestUtils.getTestDataRoot() + "dom_external_entity.xml";
  • trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportExceptionHandlerTest.java

    r12802 r17275  
    44import java.util.concurrent.CountDownLatch;
    55
    6 import org.junit.Rule;
    7 import org.junit.Test;
     6import org.junit.jupiter.api.extension.RegisterExtension;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
     
    1313 * Unit tests of {@link BugReportExceptionHandler} class.
    1414 */
    15 public class BugReportExceptionHandlerTest {
     15class BugReportExceptionHandlerTest {
    1616    /**
    1717     * No dependencies
    1818     */
    19     @Rule
     19    @RegisterExtension
    2020    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2121    public JOSMTestRules test = new JOSMTestRules();
     
    2626     */
    2727    @Test
    28     public void testHandleException() throws InterruptedException {
     28    void testHandleException() throws InterruptedException {
    2929        CountDownLatch latch = new CountDownLatch(1);
    3030        BugReportQueue.getInstance().addBugReportHandler(e -> {
  • trunk/test/unit/org/openstreetmap/josm/tools/bugreport/BugReportTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.tools.bugreport;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertSame;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertSame;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    88import java.io.IOException;
     
    1010import java.io.StringWriter;
    1111
    12 import org.junit.Rule;
    13 import org.junit.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
     13import org.junit.jupiter.api.Test;
    1414import org.openstreetmap.josm.actions.ShowStatusReportAction;
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    2121 * @author Michael Zangl
    2222 */
    23 public class BugReportTest {
     23class BugReportTest {
    2424    /**
    2525     * Preferences for the report text
    2626     */
    27     @Rule
     27    @RegisterExtension
    2828    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2929    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3333     */
    3434    @Test
    35     public void testReportText() {
     35    void testReportText() {
    3636        ReportedException e = interceptInChildMethod(new IOException("test-exception-message"));
    3737        e.put("test-key", "test-value");
     
    4848     */
    4949    @Test
    50     public void testIntercept() {
     50    void testIntercept() {
    5151        IOException base = new IOException("test");
    5252        ReportedException intercepted = interceptInChildMethod(base);
     
    6969     */
    7070    @Test
    71     public void testGetCallingMethod() {
     71    void testGetCallingMethod() {
    7272        assertEquals("BugReportTest#testGetCallingMethod", BugReport.getCallingMethod(1));
    7373        assertEquals("BugReportTest#testGetCallingMethod", testGetCallingMethod2());
  • trunk/test/unit/org/openstreetmap/josm/tools/bugreport/ReportedExceptionTest.java

    r10285 r17275  
    22package org.openstreetmap.josm.tools.bugreport;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.util.Arrays;
    77
    8 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    99
    1010/**
     
    1313 * @since 10285
    1414 */
    15 public class ReportedExceptionTest {
     15class ReportedExceptionTest {
    1616    private static final class CauseOverwriteException extends RuntimeException {
    1717        private Throwable myCause;
     
    3131     */
    3232    @Test
    33     public void testPutDoesHandleNull() {
     33    void testPutDoesHandleNull() {
    3434        ReportedException e = new ReportedException(new RuntimeException());
    3535        e.startSection("test");
     
    4545     */
    4646    @Test
    47     public void testPutDoesNotThrow() {
     47    void testPutDoesNotThrow() {
    4848        ReportedException e = new ReportedException(new RuntimeException());
    4949        e.startSection("test");
     
    6565     */
    6666    @Test
    67     public void testIsSame() {
     67    void testIsSame() {
    6868        // Do not break this line! All exceptions need to be created in the same line.
    6969        // CHECKSTYLE.OFF: LineLength
     
    7878                boolean is01 = (i == 0 || i == 1) && (j == 0 || j == 1);
    7979                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);
    8181            }
    8282        }
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r17114 r17275  
    22package org.openstreetmap.josm.tools.date;
    33
    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;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotEquals;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertNotSame;
     8import static org.junit.jupiter.api.Assertions.assertNull;
     9import static org.junit.jupiter.api.Assertions.assertThrows;
    910
    1011import java.text.DateFormat;
     
    1415import java.util.concurrent.ForkJoinPool;
    1516
    16 import org.junit.Ignore;
    17 import org.junit.Rule;
    18 import org.junit.Test;
     17import org.junit.jupiter.api.Disabled;
     18import org.junit.jupiter.api.Test;
     19import org.junit.jupiter.api.extension.RegisterExtension;
    1920import org.openstreetmap.josm.testutils.JOSMTestRules;
    2021import org.openstreetmap.josm.tools.UncheckedParseException;
     
    3334     * Timeouts need to be disabled because we change the time zone.
    3435     */
    35     @Rule
     36    @RegisterExtension
    3637    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3738    public JOSMTestRules test = new JOSMTestRules().i18n().preferences();
     
    4243     */
    4344    @Test
    44     public void testUtilityClass() throws ReflectiveOperationException {
     45    void testUtilityClass() throws ReflectiveOperationException {
    4546        UtilityClassTestUtil.assertUtilityClassWellDefined(DateUtils.class);
    4647    }
     
    5859     */
    5960    @Test
    60     public void testMapDate() {
     61    void testMapDate() {
    6162        assertEquals(1344870637000L, DateUtils.fromString("2012-08-13T15:10:37Z").getTime());
    6263    }
     
    6667     */
    6768    @Test
    68     public void testNoteDate() {
     69    void testNoteDate() {
    6970        assertEquals(1417298930000L, DateUtils.fromString("2014-11-29 22:08:50 UTC").getTime());
    7071    }
     
    7475     */
    7576    @Test
    76     public void testExifDate() {
     77    void testExifDate() {
    7778        assertEquals(1443038712000L, DateUtils.fromString("2015:09:23 20:05:12").getTime());
    7879        assertEquals(1443038712888L, DateUtils.fromString("2015:09:23 20:05:12.888").getTime());
     
    8384     */
    8485    @Test
    85     public void testGPXDate() {
     86    void testGPXDate() {
    8687        assertEquals(1277465405000L, DateUtils.fromString("2010-06-25T11:30:05.000Z").getTime());
    8788    }
     
    9192     */
    9293    @Test
    93     public void testRfc3339() {
     94    void testRfc3339() {
    9495        // examples taken from RFC
    9596        assertEquals(482196050520L, DateUtils.fromString("1985-04-12T23:20:50.52Z").getTime());
     
    105106     * Verifies that parsing an illegal date throws a {@link UncheckedParseException}
    106107     */
    107     @Test(expected = UncheckedParseException.class)
    108     public void testIllegalDate() {
    109         DateUtils.fromString("2014-");
     108    @Test
     109    void testIllegalDate() {
     110        assertThrows(UncheckedParseException.class, () -> DateUtils.fromString("2014-"));
    110111    }
    111112
     
    114115     */
    115116    @Test
    116     public void testFormattingMillisecondsDoesNotCauseIncorrectParsing() {
     117    void testFormattingMillisecondsDoesNotCauseIncorrectParsing() {
    117118        DateUtils.fromDate(new Date(123));
    118119        assertEquals(1453694709000L, DateUtils.fromString("2016-01-25T04:05:09.000Z").getTime());
     
    125126     */
    126127    @Test
    127     public void testFromTimestamp() {
     128    void testFromTimestamp() {
    128129        assertEquals("1970-01-01T00:00:00Z", DateUtils.fromTimestamp(0));
    129130        assertEquals("2001-09-09T01:46:40Z", DateUtils.fromTimestamp(1000000000));
     
    135136     */
    136137    @Test
    137     public void testFromDate() {
     138    void testFromDate() {
    138139        assertEquals("1970-01-01T00:00:00Z", DateUtils.fromDate(new Date(0)));
    139140        assertEquals("1970-01-01T00:00:00.1Z", DateUtils.fromDate(new Date(100)));
     
    147148     */
    148149    @Test
    149     public void testFormatTime() {
     150    void testFormatTime() {
    150151        assertEquals("12:00 AM", DateUtils.formatTime(new Date(0), DateFormat.SHORT));
    151152        assertEquals("1:00 AM", DateUtils.formatTime(new Date(60 * 60 * 1000), DateFormat.SHORT));
     
    162163     */
    163164    @Test
    164     public void testFormatDate() {
     165    void testFormatDate() {
    165166        assertEquals("1/1/70", DateUtils.formatDate(new Date(123), DateFormat.SHORT));
    166167        assertEquals("January 1, 1970", DateUtils.formatDate(new Date(123), DateFormat.LONG));
     
    171172     */
    172173    @Test
    173     public void testTsFromString() {
     174    void testTsFromString() {
    174175        // UTC times
    175176        assertEquals(1459641600000L, DateUtils.tsFromString("2016-04-03"));
     
    204205
    205206    @Test
    206     @Ignore("slow; use for thread safety testing")
    207     public void testTsFromString800k() throws Exception {
     207    @Disabled("slow; use for thread safety testing")
     208    void testTsFromString800k() throws Exception {
    208209        new ForkJoinPool(64).submit(() -> new Random()
    209210                .longs(800_000)
     
    215216     * Unit test of {@link DateUtils#tsFromString} method.
    216217     */
    217     @Test(expected = UncheckedParseException.class)
    218     public void testTsFromStringInvalid1() {
    219         DateUtils.tsFromString("foobar");
     218    @Test
     219    void testTsFromStringInvalid1() {
     220        assertThrows(UncheckedParseException.class, () -> DateUtils.tsFromString("foobar"));
    220221    }
    221222
     
    223224     * Unit test of {@link DateUtils#tsFromString} method.
    224225     */
    225     @Test(expected = UncheckedParseException.class)
    226     public void testTsFromStringInvalid2() {
    227         DateUtils.tsFromString("2016/04/03");
     226    @Test
     227    void testTsFromStringInvalid2() {
     228        assertThrows(UncheckedParseException.class, () -> DateUtils.tsFromString("2016/04/03"));
    228229    }
    229230
     
    232233     */
    233234    @Test
    234     public void testGetDateFormat() {
     235    void testGetDateFormat() {
    235236        Boolean iso = DateUtils.PROP_ISO_DATES.get();
    236237        try {
     
    250251     */
    251252    @Test
    252     public void testTimeFormat() {
     253    void testTimeFormat() {
    253254        Boolean iso = DateUtils.PROP_ISO_DATES.get();
    254255        try {
     
    265266
    266267    @Test
    267     public void testCloneDate() {
     268    void testCloneDate() {
    268269        assertNull(DateUtils.cloneDate(null));
    269270        final Date date = new Date(1453694709000L);
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateEntryTest.java

    r14100 r17275  
    55
    66import org.junit.Assert;
    7 import org.junit.Rule;
    8 import org.junit.Test;
     7import org.junit.jupiter.api.extension.RegisterExtension;
     8import org.junit.jupiter.api.Test;
    99import org.openstreetmap.josm.TestUtils;
    1010import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1818 * Unit tests of {@link TemplateEntry} class.
    1919 */
    20 public class TemplateEntryTest {
     20class TemplateEntryTest {
    2121
    2222    /**
    2323     * Setup rule.
    2424     */
    25     @Rule
     25    @RegisterExtension
    2626    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2727    public JOSMTestRules test = new JOSMTestRules();
     
    3131     */
    3232    @Test
    33     public void testEqualsContract() {
     33    void testEqualsContract() {
    3434        TestUtils.assumeWorkingEqualsVerifier();
    3535        Set<Class<? extends TemplateEntry>> templates = TestUtils.getJosmSubtypes(TemplateEntry.class);
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java

    r14093 r17275  
    22package org.openstreetmap.josm.tools.template_engine;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertThrows;
    56
    67import java.util.Arrays;
     
    89
    910import org.junit.Assert;
    10 import org.junit.BeforeClass;
    11 import org.junit.Test;
     11import org.junit.jupiter.api.BeforeAll;
     12import org.junit.jupiter.api.Test;
    1213import org.openstreetmap.josm.JOSMFixture;
    1314import org.openstreetmap.josm.data.osm.Node;
     
    2223 * Unit tests of {@link TemplateParser} class.
    2324 */
    24 public class TemplateParserTest {
     25class TemplateParserTest {
    2526
    2627    /**
    2728     * Setup test.
    2829     */
    29     @BeforeClass
     30    @BeforeAll
    3031    public static void setUp() {
    3132        JOSMFixture.createUnitTestFixture().init();
     
    3738     */
    3839    @Test
    39     public void testEmpty() throws ParseError {
     40    void testEmpty() throws ParseError {
    4041        TemplateParser parser = new TemplateParser("");
    4142        assertEquals(new StaticText(""), parser.parse());
     
    4748     */
    4849    @Test
    49     public void testVariable() throws ParseError {
     50    void testVariable() throws ParseError {
    5051        TemplateParser parser = new TemplateParser("abc{var}\\{ef\\$\\{g");
    5152        assertEquals(CompoundTemplateEntry.fromArray(new StaticText("abc"),
     
    5859     */
    5960    @Test
    60     public void testConditionWhitespace() throws ParseError {
     61    void testConditionWhitespace() throws ParseError {
    6162        TemplateParser parser = new TemplateParser("?{ '{name} {desc}' | '{name}' | '{desc}'    }");
    6263        Condition condition = new Condition(Arrays.asList(
     
    7273     */
    7374    @Test
    74     public void testConditionNoWhitespace() throws ParseError {
     75    void testConditionNoWhitespace() throws ParseError {
    7576        TemplateParser parser = new TemplateParser("?{'{name} {desc}'|'{name}'|'{desc}'}");
    7677        Condition condition = new Condition(Arrays.asList(
     
    9192     */
    9293    @Test
    93     public void testConditionSearchExpression() throws ParseError, SearchParseError {
     94    void testConditionSearchExpression() throws ParseError, SearchParseError {
    9495        TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' |  '{admin_level}'}");
    9596        Condition condition = new Condition(Arrays.asList(
     
    139140     */
    140141    @Test
    141     public void testFilling() throws ParseError {
     142    void testFilling() throws ParseError {
    142143        TemplateParser parser = new TemplateParser("{name} u{unknown}u i{number}i");
    143144        TemplateEntry entry = parser.parse();
     
    152153     */
    153154    @Test
    154     public void testFillingSearchExpression() throws ParseError {
     155    void testFillingSearchExpression() throws ParseError {
    155156        TemplateParser parser = new TemplateParser("?{ admin_level = 2 'NUTS 1' | admin_level = 4 'NUTS 2' |  '{admin_level}'}");
    156157        TemplateEntry templateEntry = parser.parse();
     
    173174     */
    174175    @Test
    175     public void testPrintAll() throws ParseError {
     176    void testPrintAll() throws ParseError {
    176177        TemplateParser parser = new TemplateParser("{special:everything}");
    177178        TemplateEntry entry = parser.parse();
     
    187188     */
    188189    @Test
    189     public void testPrintMultiline() throws ParseError {
     190    void testPrintMultiline() throws ParseError {
    190191        TemplateParser parser = new TemplateParser("{name}\\n{number}");
    191192        TemplateEntry entry = parser.parse();
     
    200201     */
    201202    @Test
    202     public void testSpecialVariable() throws ParseError {
     203    void testSpecialVariable() throws ParseError {
    203204        TemplateParser parser = new TemplateParser("{name}u{special:localName}u{special:special:key}");
    204205        TemplateEntry templateEntry = parser.parse();
     
    210211
    211212    @Test
    212     public void testSearchExpression() throws Exception {
     213    void testSearchExpression() throws Exception {
    213214        compile("(parent type=type1 type=parent1) | (parent type=type2 type=parent2)");
    214215        //"parent(type=type1,type=parent1) | (parent(type=type2,type=parent2)"
     
    221222     */
    222223    @Test
    223     public void testSwitchContext() throws ParseError {
     224    void testSwitchContext() throws ParseError {
    224225        TemplateParser parser = new TemplateParser("!{parent() type=parent2 '{name}'}");
    225226        DatasetFactory ds = new DatasetFactory();
     
    242243
    243244    @Test
    244     public void testSetAnd() throws ParseError {
     245    void testSetAnd() throws ParseError {
    245246        TemplateParser parser = new TemplateParser("!{(parent(type=child) type=parent) & (parent type=child subtype=parent) '{name}'}");
    246247        DatasetFactory ds = new DatasetFactory();
     
    261262
    262263    @Test
    263     public void testSetOr() throws ParseError {
     264    void testSetOr() throws ParseError {
    264265        TemplateParser parser = new TemplateParser("!{(parent(type=type1) type=parent1) | (parent type=type2 type=parent2) '{name}'}");
    265266        DatasetFactory ds = new DatasetFactory();
     
    288289
    289290    @Test
    290     public void testMultilevel() throws ParseError {
     291    void testMultilevel() throws ParseError {
    291292        TemplateParser parser = new TemplateParser(
    292293                "!{(parent(parent(type=type1)) type=grandparent) | (parent type=type2 type=parent2) '{name}'}");
     
    320321    }
    321322
    322     @Test(expected = ParseError.class)
    323     public void testErrorsNot() throws ParseError {
     323    @Test
     324    void testErrorsNot() {
    324325        TemplateParser parser = new TemplateParser("!{-parent() '{name}'}");
    325         parser.parse();
    326     }
    327 
    328     @Test(expected = ParseError.class)
    329     public void testErrorOr() throws ParseError {
     326        assertThrows(ParseError.class, () -> parser.parse());
     327    }
     328
     329    @Test
     330    void testErrorOr() {
    330331        TemplateParser parser = new TemplateParser("!{parent() | type=type1 '{name}'}");
    331         parser.parse();
    332     }
    333 
    334     @Test
    335     public void testChild() throws ParseError {
     332        assertThrows(ParseError.class, () -> parser.parse());
     333    }
     334
     335    @Test
     336    void testChild() throws ParseError {
    336337        TemplateParser parser = new TemplateParser("!{((child(type=type1) type=child1) | (child type=type2 type=child2)) type=child2 '{name}'}");
    337338        DatasetFactory ds = new DatasetFactory();
     
    351352        parent2.addMember(new RelationMember("", child2));
    352353
    353 
    354354        StringBuilder sb = new StringBuilder();
    355355        TemplateEntry entry = parser.parse();
     
    360360
    361361    @Test
    362     public void testToStringCanBeParsedAgain() throws Exception {
     362    void testToStringCanBeParsedAgain() throws Exception {
    363363        final String s1 = "?{ '{name} ({desc})' | '{name} ({cmt})' | '{name}' | '{desc}' | '{cmt}' }";
    364364        final String s2 = new TemplateParser(s1).parse().toString();
Note: See TracChangeset for help on using the changeset viewer.