Changeset 17275 in josm for trunk/test/unit


Ignore:
Timestamp:
2020-10-28T20:41:00+01:00 (12 months 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
Files:
538 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/CustomMatchers.java

    r16634 r17275  
    1212import org.hamcrest.Matcher;
    1313import org.hamcrest.TypeSafeMatcher;
    14 import org.junit.Ignore;
     14import org.junit.jupiter.api.Disabled;
    1515import org.openstreetmap.josm.data.Bounds;
    1616import org.openstreetmap.josm.data.coor.EastNorth;
     
    2020 * Custom matchers for unit tests.
    2121 */
    22 @Ignore("no test")
     22@Disabled("no test")
    2323public final class CustomMatchers {
    2424
  • trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java

    r15233 r17275  
    22package org.openstreetmap.josm;
    33
    4 import static org.junit.Assert.assertNull;
    5 import static org.junit.Assert.assertTrue;
    6 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertNull;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6import static org.junit.jupiter.api.Assertions.fail;
    77
    88import java.io.File;
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r17198 r17275  
    22package org.openstreetmap.josm;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertTrue;
    7 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
     7import static org.junit.jupiter.api.Assertions.fail;
     8import static org.junit.jupiter.api.Assumptions.assumeFalse;
    89
    910import java.awt.Component;
     
    3435import java.util.stream.Stream;
    3536
    36 import org.junit.Assert;
    37 import org.junit.Assume;
     37import org.junit.jupiter.api.Assertions;
    3838import org.openstreetmap.josm.command.Command;
    3939import org.openstreetmap.josm.data.osm.DataSet;
     
    447447     * Use to assume that EqualsVerifier is working with the current JVM.
    448448     */
     449    @SuppressWarnings("null")
    449450    public static void assumeWorkingEqualsVerifier() {
    450451        if (Utils.getJavaVersion() >= 16) {
     
    457458            nl.jqno.equalsverifier.internal.lib.bytebuddy.ClassFileVersion.ofThisVm();
    458459        } catch (IllegalArgumentException e) {
    459             Assume.assumeNoException(e);
     460            assumeFalse(e != null);
    460461        }
    461462    }
     
    464465     * Use to assume that JMockit is working with the current JVM.
    465466     */
     467    @SuppressWarnings("null")
    466468    public static void assumeWorkingJMockit() {
    467469        try {
     
    471473            new JOptionPaneSimpleMocker();
    472474        } catch (UnsupportedOperationException e) {
    473             Assume.assumeNoException(e);
     475            assumeFalse(e != null);
    474476        } finally {
    475477            TestRunnerDecorator.cleanUpAllMocks();
     
    546548    /**
    547549     * Replaces {@linkplain System#lineSeparator() system dependent line separators} with {@code \n}
    548      * and calls {@link Assert#assertEquals(java.lang.Object, java.lang.Object)}.
     550     * and calls {@link Assertions#assertEquals(java.lang.Object, java.lang.Object)}.
    549551     * @param expected expected value
    550552     * @param actual the value to check against <code>expected</code>
  • trunk/test/unit/org/openstreetmap/josm/actions/AboutActionTest.java

    r14822 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
    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 for class {@link AboutAction}.
    1414 */
    15 public final class AboutActionTest {
     15final class AboutActionTest {
    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().main();
     
    2626     */
    2727    @Test
    28     public void testBuildAboutPanel() {
     28    void testBuildAboutPanel() {
    2929        assertNotNull(new AboutAction().buildAboutPanel());
    3030    }
  • trunk/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java

    r13108 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
    7 
    8 import org.junit.Before;
    9 import org.junit.Rule;
    10 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;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
     8
     9import org.junit.jupiter.api.BeforeEach;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
    1112import org.openstreetmap.josm.actions.AlignInLineAction.InvalidSelection;
    1213import org.openstreetmap.josm.actions.AlignInLineAction.Line;
     
    2425 * Unit tests for class {@link AlignInLineAction}.
    2526 */
    26 public final class AlignInLineActionTest {
     27final class AlignInLineActionTest {
    2728
    2829    /**
    2930     * Setup test.
    3031     */
    31     @Rule
     32    @RegisterExtension
    3233    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3334    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    3940     * Setup test.
    4041     */
    41     @Before
     42    @BeforeEach
    4243    public void setUp() {
    4344        // Enable "Align in line" feature.
     
    5455     */
    5556    @Test
    56     public void testNodesOpenWay() throws InvalidSelection {
     57    void testNodesOpenWay() throws InvalidSelection {
    5758        DataSet dataSet = new DataSet();
    5859
     
    8687     */
    8788    @Test
    88     public void testNodesClosedWay() throws InvalidSelection {
     89    void testNodesClosedWay() throws InvalidSelection {
    8990        DataSet dataSet = new DataSet();
    9091
     
    119120     */
    120121    @Test
    121     public void testNodesOpenWays() throws InvalidSelection {
     122    void testNodesOpenWays() throws InvalidSelection {
    122123        DataSet dataSet = new DataSet();
    123124
     
    153154     */
    154155    @Test
    155     public void testSimpleWay() throws InvalidSelection {
     156    void testSimpleWay() throws InvalidSelection {
    156157        DataSet dataSet = new DataSet();
    157158
     
    200201    private void assertCoordEq(Node node, double x, double y) {
    201202        EastNorth coordinate = node.getEastNorth();
    202         assertEquals("Wrong x coordinate.", x, coordinate.getX(), LatLon.MAX_SERVER_PRECISION);
    203         assertEquals("Wrong y coordinate.", y, coordinate.getY(), LatLon.MAX_SERVER_PRECISION);
     203        assertEquals(x, coordinate.getX(), LatLon.MAX_SERVER_PRECISION, "Wrong x coordinate.");
     204        assertEquals(y, coordinate.getY(), LatLon.MAX_SERVER_PRECISION, "Wrong y coordinate.");
    204205    }
    205206
     
    209210     */
    210211    @Test
    211     public void testLineDifferentCoordinates() throws InvalidSelection {
     212    void testLineDifferentCoordinates() throws InvalidSelection {
    212213        assertNotNull(new Line(new Node(new EastNorth(0, 1)),
    213214                               new Node(new EastNorth(0, 2))));
     
    222223     * @throws InvalidSelection always
    223224     */
    224     @Test(expected = InvalidSelection.class)
    225     public void testLineSameCoordinates1() throws InvalidSelection {
    226         new Line(new Node(new EastNorth(0, 1)),
    227                  new Node(new EastNorth(0, 1)));
     225    @Test
     226    void testLineSameCoordinates1() throws InvalidSelection {
     227        assertThrows(InvalidSelection.class, () -> new Line(new Node(new EastNorth(0, 1)),
     228                 new Node(new EastNorth(0, 1))));
    228229    }
    229230
     
    232233     * @throws InvalidSelection always
    233234     */
    234     @Test(expected = InvalidSelection.class)
    235     public void testLineSameCoordinates2() throws InvalidSelection {
    236         new Line(new Node(new EastNorth(0, 1)),
    237                  new Node(new EastNorth(0+1e-175, 1+1e-175)));
     235    @Test
     236    void testLineSameCoordinates2() throws InvalidSelection {
     237        assertThrows(InvalidSelection.class, () -> new Line(new Node(new EastNorth(0, 1)),
     238                 new Node(new EastNorth(0+1e-175, 1+1e-175))));
    238239    }
    239240}
  • trunk/test/unit/org/openstreetmap/josm/actions/CombineWayActionTest.java

    r16438 r17275  
    22package org.openstreetmap.josm.actions;
    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.io.IOException;
     
    1515import java.util.Set;
    1616
    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.osm.DataSet;
     
    3232 * Unit tests for class {@link CombineWayAction}.
    3333 */
    34 public class CombineWayActionTest {
     34class CombineWayActionTest {
    3535
    3636    /**
    3737     * Setup test.
    3838     */
    39     @Rule
     39    @RegisterExtension
    4040    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4141    public JOSMTestRules test = new JOSMTestRules();
     
    4747     */
    4848    @Test
    49     public void testTicket11957() throws IOException, IllegalDataException {
     49    void testTicket11957() throws IOException, IllegalDataException {
    5050        try (InputStream is = TestUtils.getRegressionDataStream(11957, "data.osm")) {
    5151            DataSet ds = OsmReader.parseDataSet(is, null);
     
    6868     */
    6969    @Test
    70     public void testTicket18385() throws IOException, IllegalDataException {
     70    void testTicket18385() throws IOException, IllegalDataException {
    7171        try (InputStream is = TestUtils.getRegressionDataStream(18385, "data.osm")) {
    7272            DataSet ds = OsmReader.parseDataSet(is, null);
     
    8282     */
    8383    @Test
    84     public void testTicket18387() throws IOException, IllegalDataException {
     84    void testTicket18387() throws IOException, IllegalDataException {
    8585        try (InputStream is = TestUtils.getRegressionDataStream(18387, "data.osm")) {
    8686            DataSet ds = OsmReader.parseDataSet(is, null);
     
    104104     */
    105105    @Test
    106     public void testTicket18367() throws IOException, IllegalDataException {
     106    void testTicket18367() throws IOException, IllegalDataException {
    107107        try (InputStream is = TestUtils.getRegressionDataStream(18367, "nocombine.osm")) {
    108108            DataSet ds = OsmReader.parseDataSet(is, null);
     
    125125     */
    126126    @Test
    127     public void testTicket18367NeedsSplit() throws IOException, IllegalDataException {
     127    void testTicket18367NeedsSplit() throws IOException, IllegalDataException {
    128128        try (InputStream is = TestUtils.getRegressionDataStream(18367, "split-and-reverse.osm")) {
    129129            DataSet ds = OsmReader.parseDataSet(is, null);
     
    149149     */
    150150    @Test
    151     public void testDetectReversedWays() throws IOException, IllegalDataException {
     151    void testDetectReversedWays() throws IOException, IllegalDataException {
    152152        try (InputStream is = TestUtils.getRegressionDataStream(18367, "silent-revert.osm")) {
    153153            DataSet ds = OsmReader.parseDataSet(is, null);
     
    175175     */
    176176    @Test
    177     public void testEqualsContract() {
     177    void testEqualsContract() {
    178178        TestUtils.assumeWorkingEqualsVerifier();
    179179        EqualsVerifier.forClass(NodePair.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/actions/CopyActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    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;
    8 import static org.junit.Assert.fail;
     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.Assertions.fail;
    99
    1010import java.awt.datatransfer.Clipboard;
     
    1515import java.util.Arrays;
    1616
    17 import org.junit.Rule;
    18 import org.junit.Test;
     17import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.extension.RegisterExtension;
    1919import org.openstreetmap.josm.data.coor.LatLon;
    2020import org.openstreetmap.josm.data.osm.DataSet;
     
    3232 * Unit tests for class {@link CopyAction}.
    3333 */
    34 public class CopyActionTest {
     34class CopyActionTest {
    3535    private static final class CapturingCopyAction extends CopyAction {
    3636        private boolean warningShown;
     
    4545     * We need prefs for this.
    4646     */
    47     @Rule
     47    @RegisterExtension
    4848    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4949    public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI();
     
    5555     */
    5656    @Test
    57     public void testWarnOnEmpty() throws UnsupportedFlavorException, IOException {
     57    void testWarnOnEmpty() throws UnsupportedFlavorException, IOException {
    5858        Clipboard clipboard = ClipboardUtils.getClipboard();
    5959        clipboard.setContents(new StringSelection("test"), null);
     
    8282     */
    8383    @Test
    84     public void testCopySinglePrimitive() throws Exception {
     84    void testCopySinglePrimitive() throws Exception {
    8585        DataSet data = new DataSet();
    8686
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java

    r14977 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertSame;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertSame;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    77import java.lang.reflect.Field;
     
    99import java.util.Collection;
    1010
    11 import org.junit.Rule;
    12 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
    1313import org.openstreetmap.josm.data.coor.EastNorth;
    1414import org.openstreetmap.josm.data.coor.LatLon;
     
    2929 * Unit tests for class {@link CreateCircleAction}.
    3030 */
    31 public final class CreateCircleActionTest {
     31final class CreateCircleActionTest {
    3232
    3333    /**
    3434     * Setup test.
    3535     */
    36     @Rule
     36    @RegisterExtension
    3737    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3838    public JOSMTestRules test = new JOSMTestRules().projection();
     
    4545     */
    4646    @Test
    47     public void testTicket7421case0() throws ReflectiveOperationException {
     47    void testTicket7421case0() throws ReflectiveOperationException {
    4848        DataSet dataSet = new DataSet();
    4949
     
    6565        // Expected result: Dataset contain one closed way, clockwise
    6666        Collection<Way> resultingWays = dataSet.getWays();
    67         assertSame(String.format("Expect one way after perform action. %d found", resultingWays.size()),
    68                    resultingWays.size(), 1);
     67        assertSame(1, resultingWays.size(), String.format("Expect one way after perform action. %d found", resultingWays.size()));
    6968        Way resultingWay = resultingWays.iterator().next();
    70         assertTrue("Resulting way is not closed",
    71                    resultingWay.isClosed());
    72         assertTrue("Found anti-clockwize circle while way was clockwize",
    73                    Geometry.isClockwise(resultingWay));
     69        assertTrue(resultingWay.isClosed(), "Resulting way is not closed");
     70        assertTrue(Geometry.isClockwise(resultingWay), "Found anti-clockwise circle while way was clockwise");
    7471    }
    7572
     
    10299     */
    103100    @Test
    104     public void testTicket7421case1() throws ReflectiveOperationException {
     101    void testTicket7421case1() throws ReflectiveOperationException {
    105102        DataSet dataSet = new DataSet();
    106103
     
    127124            // Expected result: Dataset contain one closed way, clockwise
    128125            Collection<Way> resultingWays = dataSet.getWays();
    129             assertSame(String.format("Expect one way after perform action. %d found", resultingWays.size()),
    130                        resultingWays.size(), 1);
     126            assertSame(1, resultingWays.size(), String.format("Expect one way after perform action. %d found", resultingWays.size()));
    131127            Way resultingWay = resultingWays.iterator().next();
    132             assertTrue("Resulting way is not closed",
    133                        resultingWay.isClosed());
    134             assertTrue("Found anti-clockwise way while traffic is left hand.",
    135                        Geometry.isClockwise(resultingWay));
     128            assertTrue(resultingWay.isClosed(), "Resulting way is not closed");
     129            assertTrue(Geometry.isClockwise(resultingWay), "Found anti-clockwise way while traffic is left hand.");
    136130        } finally {
    137131            // Restore left/right hand traffic database
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    r15162 r17275  
    22package org.openstreetmap.josm.actions;
    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;
    77
    88import java.nio.file.Files;
     
    1212import java.util.TreeMap;
    1313
    14 import org.junit.Rule;
    15 import org.junit.Test;
     14import org.junit.jupiter.api.extension.RegisterExtension;
     15import org.junit.jupiter.api.Test;
    1616import org.openstreetmap.josm.TestUtils;
    1717import org.openstreetmap.josm.command.SequenceCommand;
     
    3737 * Unit test of {@link CreateMultipolygonAction}
    3838 */
    39 public class CreateMultipolygonActionTest {
     39class CreateMultipolygonActionTest {
    4040
    4141    /**
    4242     * Setup test.
    4343     */
    44     @Rule
     44    @RegisterExtension
    4545    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4646    public JOSMTestRules test = new JOSMTestRules().projection().main().preferences();
     
    8080
    8181    @Test
    82     public void testCreate1() throws Exception {
     82    void testCreate1() throws Exception {
    8383        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    8484        Pair<SequenceCommand, Relation> mp = CreateMultipolygonAction.createMultipolygonCommand(ds.getWays(), null);
     
    8888
    8989    @Test
    90     public void testCreate2() throws Exception {
     90    void testCreate2() throws Exception {
    9191        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    9292        Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.", null, true);
     
    9595
    9696    @Test
    97     public void testUpdate1() throws Exception {
     97    void testUpdate1() throws Exception {
    9898        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    9999        Relation mp = createMultipolygon(ds.getWays(), "ref=\".*1$\"", null, true);
     
    106106
    107107    @Test
    108     public void testUpdate2() throws Exception {
     108    void testUpdate2() throws Exception {
    109109        DataSet ds = OsmReader.parseDataSet(Files.newInputStream(Paths.get(TestUtils.getTestDataRoot(), "create_multipolygon.osm")), null);
    110110        Relation mp = createMultipolygon(ds.getWays(), "ref=1 OR ref:1.1.1", null, true);
     
    119119     */
    120120    @Test
    121     public void testTicket17767() throws Exception {
     121    void testTicket17767() throws Exception {
    122122        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(17767, "upd-mp.osm"), null);
    123123        Layer layer = new OsmDataLayer(ds, null, null);
     
    141141     */
    142142    @Test
    143     public void testTicket17768() throws Exception {
     143    void testTicket17768() throws Exception {
    144144        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(17768, "dupmem.osm"), null);
    145145        Layer layer = new OsmDataLayer(ds, null, null);
  • trunk/test/unit/org/openstreetmap/josm/actions/DeleteLayerActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertNotNull;
    5 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
     5import static org.junit.jupiter.api.Assertions.assertNull;
    66
    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.data.osm.DataSet;
    1010import org.openstreetmap.josm.gui.MainApplication;
     
    1717 * Unit tests for class {@link DeleteLayerAction}.
    1818 */
    19 public final class DeleteLayerActionTest {
     19final class DeleteLayerActionTest {
    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 testActionPerformed() {
     32    void testActionPerformed() {
    3333        DeleteLayerAction action = new DeleteLayerAction();
    3434        // No layer
  • trunk/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertTrue;
    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.junit.contrib.java.lang.system.ExpectedSystemExit;
    99import org.openstreetmap.josm.TestUtils;
     
    2222 * Unit tests for class {@link ExitAction}.
    2323 */
    24 public final class ExitActionTest {
     24final class ExitActionTest {
    2525
    2626    /**
    2727     * Setup test.
    2828     */
    29     @Rule
     29    @RegisterExtension
    3030    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3131    public JOSMTestRules test = new JOSMTestRules().main();
     
    3434     * System.exit rule
    3535     */
    36     @Rule
     36    @RegisterExtension
    3737    public final ExpectedSystemExit exit = ExpectedSystemExit.none();
    3838
     
    4141     */
    4242    @Test
    43     public void testActionPerformed() {
     43    void testActionPerformed() {
    4444        TestUtils.assumeWorkingJMockit();
    4545        exit.expectSystemExitWithStatus(0);
  • trunk/test/unit/org/openstreetmap/josm/actions/ExpertToggleActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertFalse;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    77import java.util.concurrent.atomic.AtomicBoolean;
     
    99import javax.swing.JPanel;
    1010
    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.actions.ExpertToggleAction.ExpertModeChangeListener;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    2121 * @since 11224
    2222 */
    23 public class ExpertToggleActionTest {
     23class ExpertToggleActionTest {
    2424    /**
    2525     * We need prefs to store expert mode state.
    2626     */
    27     @Rule
     27    @RegisterExtension
    2828    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2929    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3434     */
    3535    @Test
    36     public void testVisibilitySwitcher() {
     36    void testVisibilitySwitcher() {
    3737        ExpertToggleAction.getInstance().setExpert(false);
    3838        JPanel c = new JPanel();
     
    5858     */
    5959    @Test
    60     public void testExpertModeListener() {
     60    void testExpertModeListener() {
    6161        AtomicBoolean value = new AtomicBoolean(false);
    6262        ExpertToggleAction.getInstance().setExpert(true);
  • trunk/test/unit/org/openstreetmap/josm/actions/ExtensionFileFilterTest.java

    r13352 r17275  
    22package org.openstreetmap.josm.actions;
    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;
    77import org.openstreetmap.josm.TestUtils;
    88import org.openstreetmap.josm.actions.ExtensionFileFilter.AddArchiveExtension;
     
    1313 * Unit tests for class {@link ExtensionFileFilter}.
    1414 */
    15 public class ExtensionFileFilterTest {
     15class ExtensionFileFilterTest {
    1616
    1717    private static void test(String extensions, String defaultExtension, String description, boolean addArchiveExtensionsToDescription,
     
    2828     */
    2929    @Test
    30     public void testNewFilterWithArchiveExtensions() {
     30    void testNewFilterWithArchiveExtensions() {
    3131        test("ext1", "ext1", "description", true,
    3232                "ext1,ext1.gz,ext1.bz,ext1.bz2,ext1.xz,ext1.zip",
     
    4747     */
    4848    @Test
    49     public void testEqualsContract() {
     49    void testEqualsContract() {
    5050        TestUtils.assumeWorkingEqualsVerifier();
    5151        EqualsVerifier.forClass(ExtensionFileFilter.class).usingGetClass()
     
    5757     */
    5858    @Test
    59     public void testEnumAddArchiveExtension() {
     59    void testEnumAddArchiveExtension() {
    6060        TestUtils.superficialEnumCodeCoverage(AddArchiveExtension.class);
    6161    }
  • trunk/test/unit/org/openstreetmap/josm/actions/FullscreenToggleActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    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
     
    1111 * Test {@link FullscreenToggleAction}
    1212 */
    13 public class FullscreenToggleActionTest {
     13class FullscreenToggleActionTest {
    1414    /**
    1515     * Setup test.
    1616     */
    17     @Rule
     17    @RegisterExtension
    1818    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    1919    public JOSMTestRules test = new JOSMTestRules().main();
     
    2323     */
    2424    @Test
    25     public void testFullscreenToggleAction() {
     25    void testFullscreenToggleAction() {
    2626        FullscreenToggleAction action = new FullscreenToggleAction();
    2727        // Cannot really test it in headless mode, but at least check we can toggle the action without error
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r16438 r17275  
    22package org.openstreetmap.josm.actions;
    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;
    66
    77import java.io.IOException;
     
    1515import java.util.Set;
    1616
    17 import org.junit.Rule;
    18 import org.junit.Test;
     17import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.extension.RegisterExtension;
    1919import org.openstreetmap.josm.TestUtils;
    2020import org.openstreetmap.josm.actions.search.SearchAction;
     
    4444 * Unit tests of {@link JoinAreasAction} class.
    4545 */
    46 public class JoinAreasActionTest {
     46class JoinAreasActionTest {
    4747
    4848    /**
    4949     * Setup test.
    5050     */
    51     @Rule
     51    @RegisterExtension
    5252    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    5353    public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
     
    5959     */
    6060    @Test
    61     public void testTicket9599() throws IOException, IllegalDataException {
     61    void testTicket9599() throws IOException, IllegalDataException {
    6262        try (InputStream is = TestUtils.getRegressionDataStream(9599, "ex5.osm")) {
    6363            DataSet ds = OsmReader.parseDataSet(is, null);
     
    8282     */
    8383    @Test
    84     public void testTicket9599Simple() throws IOException, IllegalDataException {
     84    void testTicket9599Simple() throws IOException, IllegalDataException {
    8585        try (InputStream is = TestUtils.getRegressionDataStream(9599, "three_old.osm")) {
    8686            DataSet ds = OsmReader.parseDataSet(is, null);
     
    106106     */
    107107    @Test
    108     public void testTicket10511() throws IOException, IllegalDataException {
     108    void testTicket10511() throws IOException, IllegalDataException {
    109109        try (InputStream is = TestUtils.getRegressionDataStream(10511, "10511_mini.osm")) {
    110110            DataSet ds = OsmReader.parseDataSet(is, null);
     
    128128     */
    129129    @Test
    130     public void testTicket11992() throws IOException, IllegalDataException {
     130    void testTicket11992() throws IOException, IllegalDataException {
    131131        try (InputStream is = TestUtils.getRegressionDataStream(11992, "shapes.osm")) {
    132132            DataSet ds = OsmReader.parseDataSet(is, null);
     
    154154     */
    155155    @Test
    156     public void testTicket18744() throws IOException, IllegalDataException {
     156    void testTicket18744() throws IOException, IllegalDataException {
    157157        try (InputStream is = TestUtils.getRegressionDataStream(18744, "18744-sample.osm")) {
    158158            DataSet ds = OsmReader.parseDataSet(is, null);
     
    179179    @Test
    180180    @SuppressWarnings({ "rawtypes", "unchecked" })
    181     public void testExamples() throws Exception {
     181    void testExamples() throws Exception {
    182182        DataSet dsToJoin, dsExpected;
    183183        try (InputStream is = Files.newInputStream(Paths.get("nodist/data/Join_Areas_Tests.osm"))) {
     
    199199            Collection<OsmPrimitive> primitives = tests.get(test);
    200200            for (OsmPrimitive osm : primitives) {
    201                 assertTrue(test + "; expected way, but got: " + osm, osm instanceof Way);
     201                assertTrue(osm instanceof Way, test + "; expected way, but got: " + osm);
    202202            }
    203203            new JoinAreasAction(false).join((Collection) primitives);
    204204            Collection<OsmPrimitive> joinedCol = dsToJoin.getPrimitives(osm -> !osm.isDeleted() && Objects.equals(osm.get("test"), test));
    205             assertEquals("in test " + test + ":", 1, joinedCol.size());
     205            assertEquals(1, joinedCol.size(), "in test " + test + ":");
    206206            Collection<OsmPrimitive> expectedCol = dsExpected.getPrimitives(osm -> !osm.isDeleted() && Objects.equals(osm.get("test"), test));
    207             assertEquals("in test " + test + ":", 1, expectedCol.size());
     207            assertEquals(1, expectedCol.size(), "in test " + test + ":");
    208208            OsmPrimitive osmJoined = joinedCol.iterator().next();
    209209            OsmPrimitive osmExpected = expectedCol.iterator().next();
    210             assertTrue("difference in test " + test, isSemanticallyEqual(osmExpected, osmJoined));
     210            assertTrue(isSemanticallyEqual(osmExpected, osmJoined), "difference in test " + test);
    211211        }
    212212    }
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java

    r16202 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    57
    68import java.awt.Rectangle;
     
    1012import java.util.stream.Collectors;
    1113
    12 import org.junit.Rule;
    13 import org.junit.Test;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
    1416import org.openstreetmap.josm.TestUtils;
    1517import org.openstreetmap.josm.data.coor.EastNorth;
     
    3335 * Unit tests for class {@link JoinNodeWayAction}.
    3436 */
    35 public final class JoinNodeWayActionTest {
     37final class JoinNodeWayActionTest {
    3638    /**
    3739     * Setup test.
    3840     */
    39     @Rule
     41    @RegisterExtension
    4042    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4143    public JOSMTestRules test = new JOSMTestRules().projection().main().preferences();
     
    6163     */
    6264    @Test
    63     public void testTicket18189() throws Exception {
     65    void testTicket18189() throws Exception {
    6466        DataSet dataSet = new DataSet();
    6567        OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
     
    9395            action.actionPerformed(null);
    9496            // Make sure the node was only moved once
    95             assertTrue("Node n5 wasn't added to way w1.", w1.containsNode(n5));
    96             assertTrue("Node n5 wasn't added to way w2.", w2.containsNode(n5));
    97             assertTrue("Node was moved to an unexpected position", n5.getEastNorth().equalsEpsilon(expected, 1e-7));
     97            assertTrue(w1.containsNode(n5), "Node n5 wasn't added to way w1.");
     98            assertTrue(w2.containsNode(n5), "Node n5 wasn't added to way w2.");
     99            assertTrue(n5.getEastNorth().equalsEpsilon(expected, 1e-7), "Node was moved to an unexpected position");
    98100        } finally {
    99101            MainApplication.getLayerManager().removeLayer(layer);
     
    106108     */
    107109    @Test
    108     public void testTicket11508() throws Exception {
     110    void testTicket11508() throws Exception {
    109111        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(11508, "11508_example.osm"), null);
    110112        Layer layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null);
     
    113115            List<Node> nodesToMove = ds.getNodes().stream().filter(n -> n.hasTag("name", "select me and press N"))
    114116                    .collect(Collectors.toList());
    115             assertTrue(nodesToMove.size() == 1);
     117            assertEquals(1, nodesToMove.size());
    116118            Node toMove = nodesToMove.iterator().next();
    117119            Node expected = new Node(new LatLon(47.56331849690742, 8.800789259499311));
     
    122124            action.actionPerformed(null);
    123125
    124             assertTrue("Node was moved to an unexpected position", toMove.getEastNorth().equalsEpsilon(expected.getEastNorth(), 1e-7));
    125             assertTrue("Node was not added to expected number of ways", toMove.getParentWays().size() == 2);
     126            assertTrue(toMove.getEastNorth().equalsEpsilon(expected.getEastNorth(), 1e-7), "Node was moved to an unexpected position");
     127            assertEquals(2, toMove.getParentWays().size(), "Node was not added to expected number of ways");
    126128        } finally {
    127129            MainApplication.getLayerManager().removeLayer(layer);
     
    134136     */
    135137    @Test
    136     public void testTicket18189Crossing() throws Exception {
     138    void testTicket18189Crossing() throws Exception {
    137139        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(18189, "moveontocrossing.osm"), null);
    138140        Layer layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null);
     
    144146            List<Node> nodesToMove = ds.getNodes().stream().filter(n -> n.hasTag("name", "select me and press N"))
    145147                    .collect(Collectors.toList());
    146             assertTrue(nodesToMove.size() == 1);
     148            assertEquals(1, nodesToMove.size());
    147149            Node toMove = nodesToMove.iterator().next();
    148150            ds.setSelected(toMove);
     
    159161     */
    160162    @Test
    161     public void testTicket18189ThreeWays() throws Exception {
     163    void testTicket18189ThreeWays() throws Exception {
    162164        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(18189, "data.osm"), null);
    163165        Layer layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null);
     
    169171            List<Node> nodesToMove = ds.getNodes().stream().filter(n -> n.hasTag("name", "select me and press N"))
    170172                    .collect(Collectors.toList());
    171             assertTrue(nodesToMove.size() == 1);
     173            assertEquals(1, nodesToMove.size());
    172174            Node toMove = nodesToMove.iterator().next();
    173175            Node expected = new Node(new LatLon(-21.088998104148224, -50.38629102179512));
    174176            ds.setSelected(toMove);
    175177            action.actionPerformed(null);
    176             assertTrue("Node was moved to an unexpected position", toMove.getEastNorth().equalsEpsilon(expected.getEastNorth(), 1e-7));
    177             assertTrue("Node was not added to expected number of ways", toMove.getParentWays().size() == 4);
    178 
     178            assertTrue(toMove.getEastNorth().equalsEpsilon(expected.getEastNorth(), 1e-7), "Node was moved to an unexpected position");
     179            assertEquals(4, toMove.getParentWays().size(), "Node was not added to expected number of ways");
    179180        } finally {
    180181            MainApplication.getLayerManager().removeLayer(layer);
     
    187188     */
    188189    @Test
    189     public void testTicket18420() throws Exception {
     190    void testTicket18420() throws Exception {
    190191        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(18420, "user-sample.osm"), null);
    191192        Layer layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null);
     
    193194        try {
    194195            List<Node> nodesToMove = ds.getNodes().stream().filter(n -> n.hasTag("name")).collect(Collectors.toList());
    195             assertTrue(nodesToMove.size() == 2);
     196            assertEquals(2, nodesToMove.size());
    196197            Node n = nodesToMove.iterator().next();
    197198            if (!n.hasTag("name", "select me 1st"))
     
    206207            action.setEnabled(true);
    207208            action.actionPerformed(null);
    208             assertTrue("Node was moved to an unexpected position", toMove1.getEastNorth().equalsEpsilon(expected1.getEastNorth(), 1e-7));
    209             assertTrue("Node was moved to an unexpected position", toMove2.getEastNorth().equalsEpsilon(expected2.getEastNorth(), 1e-7));
    210             assertTrue("Node was not added to expected number of ways", toMove1.getParentWays().size() == 2);
    211             assertTrue("Node was not added to expected number of ways", toMove2.getParentWays().size() == 2);
     209            assertTrue(toMove1.getEastNorth().equalsEpsilon(expected1.getEastNorth(), 1e-7), "Node was moved to an unexpected position");
     210            assertTrue(toMove2.getEastNorth().equalsEpsilon(expected2.getEastNorth(), 1e-7), "Node was moved to an unexpected position");
     211            assertEquals(2, toMove1.getParentWays().size(), "Node was not added to expected number of ways");
     212            assertEquals(2, toMove2.getParentWays().size(), "Node was not added to expected number of ways");
    212213        } finally {
    213214            MainApplication.getLayerManager().removeLayer(layer);
     
    220221     */
    221222    @Test
    222     public void testTicket18990() throws Exception {
     223    void testTicket18990() throws Exception {
    223224        DataSet ds = OsmReader.parseDataSet(TestUtils.getRegressionDataStream(18990, "18990-sample.osm"), null);
    224225        Layer layer = new OsmDataLayer(ds, OsmDataLayer.createNewName(), null);
     
    226227        try {
    227228            Node toMove = (Node) ds.getPrimitiveById(new SimplePrimitiveId(7018586511L, OsmPrimitiveType.NODE));
    228             assertTrue(toMove != null);
     229            assertNotNull(toMove);
    229230            Node expected = new Node(new LatLon(43.48582074476985, -96.76897750613033));
    230231
     
    234235            action.setEnabled(true);
    235236            action.actionPerformed(null);
    236             assertTrue("Node was moved to an unexpected position", toMove.getEastNorth().equalsEpsilon(expected.getEastNorth(), 1e-7));
    237             assertTrue("Node was not added to expected way", toMove.getParentWays().size() == 1);
    238             assertTrue("Node was not added to expected way segment",
    239                     toMove.getParentWays().iterator().next().getNodes().indexOf(toMove) == 2);
     237            assertTrue(toMove.getEastNorth().equalsEpsilon(expected.getEastNorth(), 1e-7), "Node was moved to an unexpected position");
     238            assertEquals(1, toMove.getParentWays().size(), "Node was not added to expected way");
     239            assertEquals(2, toMove.getParentWays().iterator().next().getNodes().indexOf(toMove), "Node was not added to expected way segment");
    240240        } finally {
    241241            MainApplication.getLayerManager().removeLayer(layer);
  • trunk/test/unit/org/openstreetmap/josm/actions/MergeLayerActionTest.java

    r16159 r17275  
    22package org.openstreetmap.josm.actions;
    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.util.Collections;
     
    1010import javax.swing.JPanel;
    1111
    12 import org.junit.Before;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.extension.RegisterExtension;
    1515import org.openstreetmap.josm.TestUtils;
    1616import org.openstreetmap.josm.data.osm.DataSet;
     
    3434     * Setup test.
    3535     */
    36     @Rule
     36    @RegisterExtension
    3737    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3838    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    5858     * Setup test.
    5959     */
    60     @Before
     60    @BeforeEach
    6161    public void setUp() {
    6262        if (action == null) {
     
    7272     */
    7373    @Test
    74     public void testMergeNoSourceLayer() {
     74    void testMergeNoSourceLayer() {
    7575        assertNull(MainApplication.getLayerManager().getActiveLayer());
    7676        action.actionPerformed(null);
     
    8282     */
    8383    @Test
    84     public void testMergeNoTargetLayer() {
     84    void testMergeNoTargetLayer() {
    8585        TestUtils.assumeWorkingJMockit();
    8686        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(
     
    105105     */
    106106    @Test
    107     public void testMergeTwoEmptyLayers() throws Exception {
     107    void testMergeTwoEmptyLayers() throws Exception {
    108108        TestUtils.assumeWorkingJMockit();
    109109        final MergeLayerExtendedDialogMocker edMocker = new MergeLayerExtendedDialogMocker();
  • trunk/test/unit/org/openstreetmap/josm/actions/MergeNodesActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    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;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67
    78import java.util.Arrays;
    89import java.util.Collections;
    910
    10 import org.junit.Rule;
    11 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
    1213import org.openstreetmap.josm.data.coor.LatLon;
    1314import org.openstreetmap.josm.data.osm.DataSet;
     
    2122 * Unit tests for class {@link MergeNodesAction}.
    2223 */
    23 public class MergeNodesActionTest {
     24class MergeNodesActionTest {
    2425
    2526    /**
    2627     * Setup test.
    2728     */
    28     @Rule
     29    @RegisterExtension
    2930    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3031    public JOSMTestRules test = new JOSMTestRules().projection();
     
    3334     * Unit test of {@link MergeNodesAction#selectTargetLocationNode} - empty list
    3435     */
    35     @Test(expected = IllegalArgumentException.class)
    36     public void testSelectTargetLocationNodeEmpty() {
    37         MergeNodesAction.selectTargetLocationNode(Collections.emptyList());
     36    @Test
     37    void testSelectTargetLocationNodeEmpty() {
     38        assertThrows(IllegalArgumentException.class, () -> MergeNodesAction.selectTargetLocationNode(Collections.emptyList()));
    3839    }
    3940
     
    4142     * Unit test of {@link MergeNodesAction#selectTargetLocationNode} - invalid mode
    4243     */
    43     @Test(expected = IllegalStateException.class)
    44     public void testSelectTargetLocationNodeInvalidMode() {
     44    @Test
     45    void testSelectTargetLocationNodeInvalidMode() {
    4546        Config.getPref().putInt("merge-nodes.mode", -1);
    46         MergeNodesAction.selectTargetLocationNode(Arrays.asList(new Node(0), new Node(1)));
     47        assertThrows(IllegalStateException.class, () -> MergeNodesAction.selectTargetLocationNode(Arrays.asList(new Node(0), new Node(1))));
    4748    }
    4849
     
    5152     */
    5253    @Test
    53     public void testSelectTargetLocationNode() {
     54    void testSelectTargetLocationNode() {
    5455        Config.getPref().putInt("merge-nodes.mode", 0);
    5556        assertEquals(1, MergeNodesAction.selectTargetLocationNode(Arrays.asList(new Node(0), new Node(1))).getId());
     
    6869     */
    6970    @Test
    70     public void testSelectTargetNode() {
     71    void testSelectTargetNode() {
    7172        assertNull(MergeNodesAction.selectTargetNode(Collections.emptyList()));
    7273        DataSet ds = new DataSet();
  • trunk/test/unit/org/openstreetmap/josm/actions/MoveActionTest.java

    r11978 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import org.junit.Test;
     4import org.junit.jupiter.api.Test;
    55import org.openstreetmap.josm.TestUtils;
    66import org.openstreetmap.josm.actions.MoveAction.Direction;
     
    99 * Unit tests for class {@link ExtensionFileFilter}.
    1010 */
    11 public class MoveActionTest {
     11class MoveActionTest {
    1212
    1313    /**
     
    1515     */
    1616    @Test
    17     public void testEnumDirection() {
     17    void testEnumDirection() {
    1818        TestUtils.superficialEnumCodeCoverage(Direction.class);
    1919    }
  • trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java

    r16182 r17275  
    22package org.openstreetmap.josm.actions;
    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.io.InputStream;
     
    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;
    1516import org.openstreetmap.josm.actions.OrthogonalizeAction.Direction;
     
    3233 * Unit tests for class {@link OrthogonalizeAction}.
    3334 */
    34 public class OrthogonalizeActionTest {
     35class OrthogonalizeActionTest {
    3536
    3637    /**
    3738     * Setup test.
    3839     */
    39     @Rule
     40    @RegisterExtension
    4041    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4142    public JOSMTestRules test = new JOSMTestRules().projection();
    4243
    43     @Test(expected = OrthogonalizeAction.InvalidUserInputException.class)
    44     public void testNoSelection() throws Exception {
    45         performTest("nothing selected");
     44    @Test
     45    void testNoSelection() throws Exception {
     46        assertThrows(OrthogonalizeAction.InvalidUserInputException.class, () -> performTest("nothing selected"));
    4647    }
    4748
    4849    @Test
    49     public void testClosedWay() throws Exception {
     50    void testClosedWay() throws Exception {
    5051        final DataSet ds = performTest("name=ClosedWay");
    5152        final Way way = ds.getSelectedWays().iterator().next();
     
    5859
    5960    @Test
    60     public void testTwoWaysFormingClosedWay() throws Exception {
     61    void testTwoWaysFormingClosedWay() throws Exception {
    6162        performTest("name=TwoWaysFormingClosedWay");
    6263    }
    6364
    6465    @Test
    65     public void testTwoRingsAtOnce() throws Exception {
     66    void testTwoRingsAtOnce() throws Exception {
    6667        performTest("name=ClosedWay OR name=TwoWaysFormingClosedWay");
    6768    }
    6869
    6970    @Test
    70     public void testClosedWayWithReferenceNodes() throws Exception {
     71    void testClosedWayWithReferenceNodes() throws Exception {
    7172        final DataSet ds = performTest("name=ClosedWayWithReferenceNodes");
    7273        final Way way = ds.getSelectedWays().iterator().next();
     
    7980
    8081    @Test
    81     public void testFourNodes() throws Exception {
     82    void testFourNodes() throws Exception {
    8283        final DataSet ds = performTest(
    8384                "name=NodeToRectify-01", "name=NodeToRectify-02", "name=NodeToRectify-03", "name=NodeToRectify-04");
     
    9495     */
    9596    @Test
    96     public void testUtilityClass() throws ReflectiveOperationException {
     97    void testUtilityClass() throws ReflectiveOperationException {
    9798        UtilityClassTestUtil.assertUtilityClassWellDefined(OrthogonalizeAction.EN.class);
    9899    }
     
    122123     */
    123124    @Test
    124     public void testEnumDirection() {
     125    void testEnumDirection() {
    125126        TestUtils.superficialEnumCodeCoverage(Direction.class);
    126127    }
  • trunk/test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    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;
    66
    77import java.io.FileNotFoundException;
     
    99import java.io.InputStream;
    1010
    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;
    1414import org.openstreetmap.josm.data.osm.DataSet;
     
    2525 * Unit tests for class {@link PurgeAction}.
    2626 */
    27 public class PurgeActionTest {
     27class PurgeActionTest {
    2828
    2929    /**
    3030     * Setup test.
    3131     */
    32     @Rule
     32    @RegisterExtension
    3333    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3434    public JOSMTestRules test = new JOSMTestRules().main();
     
    4141     */
    4242    @Test
    43     public void testCopyStringWayRelation() throws FileNotFoundException, IOException, IllegalDataException {
     43    void testCopyStringWayRelation() throws FileNotFoundException, IOException, IllegalDataException {
    4444        try (InputStream is = TestUtils.getRegressionDataStream(12038, "data.osm")) {
    4545            DataSet ds = OsmReader.parseDataSet(is, null);
  • trunk/test/unit/org/openstreetmap/josm/actions/SelectAllActionTest.java

    r13938 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    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.osm.DataSet;
    99import org.openstreetmap.josm.gui.MainApplication;
     
    1515 * Unit tests for class {@link SelectAllAction}.
    1616 */
    17 public final class SelectAllActionTest {
     17final class SelectAllActionTest {
    1818
    1919    /**
    2020     * Setup test.
    2121     */
    22     @Rule
     22    @RegisterExtension
    2323    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2424    public JOSMTestRules rules = new JOSMTestRules().preferences().projection().main();
     
    2828     */
    2929    @Test
    30     public void testActionPerformed() {
     30    void testActionPerformed() {
    3131        SelectByInternalPointActionTest.initDataSet();
    3232        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
  • trunk/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java

    r16182 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    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.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    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.data.coor.EastNorth;
    1212import org.openstreetmap.josm.data.osm.DataSet;
     
    2626 * Unit tests for class {@link SelectByInternalPointAction}.
    2727 */
    28 public final class SelectByInternalPointActionTest {
     28final class SelectByInternalPointActionTest {
    2929
    3030    /**
    3131     * Setup test.
    3232     */
    33     @Rule
     33    @RegisterExtension
    3434    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3535    public JOSMTestRules rules = new JOSMTestRules().preferences().projection().main();
     
    4040     */
    4141    @Test
    42     public void testUtilityClass() throws ReflectiveOperationException {
     42    void testUtilityClass() throws ReflectiveOperationException {
    4343        UtilityClassTestUtil.assertUtilityClassWellDefined(SelectByInternalPointAction.class);
    4444    }
     
    4848     */
    4949    @Test
    50     public void testNoDataSet() {
     50    void testNoDataSet() {
    5151        assertNull(MainApplication.getLayerManager().getEditDataSet());
    5252        assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(null).size());
     
    8585     */
    8686    @Test
    87     public void testGetSurroundingObjects() {
     87    void testGetSurroundingObjects() {
    8888        initDataSet();
    8989        assertEquals(0, SelectByInternalPointAction.getSurroundingObjects(null).size());
     
    9797     */
    9898    @Test
    99     public void testGetSmallestSurroundingObject() {
     99    void testGetSmallestSurroundingObject() {
    100100        initDataSet();
    101101        assertNull(SelectByInternalPointAction.getSmallestSurroundingObject(null));
     
    107107     */
    108108    @Test
    109     public void testPerformSelection() {
     109    void testPerformSelection() {
    110110        initDataSet();
    111111        DataSet ds = MainApplication.getLayerManager().getEditDataSet();
  • trunk/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java

    r15070 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertFalse;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
    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.imagery.ImageryInfo;
    99import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
     
    1616 * Unit tests for class {@link SessionLoadAction}.
    1717 */
    18 public class SessionLoadActionTest {
     18class SessionLoadActionTest {
    1919
    2020    /**
    2121     * Setup test.
    2222     */
    23     @Rule
     23    @RegisterExtension
    2424    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2525    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    2929     */
    3030    @Test
    31     public void testTicket17702() {
     31    void testTicket17702() {
    3232        assertFalse(SessionLoadAction.Loader.addLayer(new TMSLayer(new ImageryInfo(
    3333                "Bing Карта (GLOBALCITY)",
  • trunk/test/unit/org/openstreetmap/josm/actions/SessionSaveAsActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertFalse;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
    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 for class {@link SessionSaveAsAction}.
    1414 */
    15 public class SessionSaveAsActionTest {
     15class SessionSaveAsActionTest {
    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 testSessionSaveAsAction() {
     28    void testSessionSaveAsAction() {
    2929        SessionSaveAsAction action = new SessionSaveAsAction();
    3030        assertFalse(action.isEnabled());
  • trunk/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java

    r15432 r17275  
    22package org.openstreetmap.josm.actions;
    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.IOException;
     
    1616import java.util.stream.Stream;
    1717
    18 import org.junit.Before;
    19 import org.junit.Rule;
    20 import org.junit.Test;
     18import org.junit.jupiter.api.BeforeEach;
     19import org.junit.jupiter.api.Test;
     20import org.junit.jupiter.api.extension.RegisterExtension;
    2121import org.openstreetmap.josm.TestUtils;
    2222import org.openstreetmap.josm.command.DeleteCommand;
     
    3737 * Unit tests for class {@link SimplifyWayAction}.
    3838 */
    39 public final class SimplifyWayActionTest {
     39final class SimplifyWayActionTest {
    4040
    4141    /** Class under test. */
     
    4545     * Setup test.
    4646     */
    47     @Rule
     47    @RegisterExtension
    4848    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4949    public JOSMTestRules test = new JOSMTestRules().main();
     
    5252     * Setup test.
    5353     */
    54     @Before
     54    @BeforeEach
    5555    public void setUp() {
    5656        if (action == null) {
     
    6969     */
    7070    @Test
    71     public void testSimplify() throws Exception {
     71    void testSimplify() throws Exception {
    7272        DataSet DsSimplify = getDs("tracks");
    7373        DataSet DsExpected = getDs("tracks-simplify15");
     
    9191     */
    9292    @Test
    93     public void testSimplifyFirstNode() {
     93    void testSimplifyFirstNode() {
    9494        final DataSet ds = new DataSet();
    9595        final Node n1 = new Node(new LatLon(47.26269614984, 11.34044231149));
  • trunk/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java

    r15728 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertSame;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertSame;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    77import java.util.Arrays;
    88
    9 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    109import org.junit.Assert;
    11 import org.junit.Rule;
    12 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
    1312import org.openstreetmap.josm.TestUtils;
    1413import org.openstreetmap.josm.data.coor.EastNorth;
     
    2120import org.openstreetmap.josm.testutils.JOSMTestRules;
    2221
     22import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     23
    2324/**
    2425 * Unit tests for class {@link SplitWayAction}.
    2526 */
    26 public final class SplitWayActionTest {
     27final class SplitWayActionTest {
    2728
    2829    /**
    2930     * Setup test.
    3031     */
    31     @Rule
     32    @RegisterExtension
    3233    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3334    public JOSMTestRules test = new JOSMTestRules().projection();
     
    4546     */
    4647    @Test
    47     public void testTicket11184() {
     48    void testTicket11184() {
    4849        Node n1 = addNode(0, 0);
    4950        Node n2 = addNode(-1, 1);
     
    6869
    6970        // Ensures 3 ways.
    70         assertSame(String.format("Found %d ways after split action instead of 3.", dataSet.getWays().size()),
    71                    dataSet.getWays().size(), 3);
     71        assertSame(3, dataSet.getWays().size(), String.format("Found %d ways after split action instead of 3.", dataSet.getWays().size()));
    7272
    7373        // Ensures way w1 is unchanged.
    74         assertTrue("Unselected ways disappear during split action.",
    75                    dataSet.getWays().contains(w1));
    76         assertSame("Unselected way seems to have change during split action.",
    77                    w1.getNodesCount(), 3);
     74        assertTrue(dataSet.getWays().contains(w1), "Unselected ways disappear during split action.");
     75        assertSame(3, w1.getNodesCount(), "Unselected way seems to have change during split action.");
    7876        for (int i = 0; i < 3; i++) {
    79             assertSame("Node change in unselected way during split action.",
    80                        w1.getNode(i), w1NodesArray[i]);
     77            assertSame(w1.getNode(i), w1NodesArray[i], "Node change in unselected way during split action.");
    8178        }
    8279    }
     
    8885     */
    8986    @Test
    90     public void testTicket17810() {
     87    void testTicket17810() {
    9188        DataSet dataSet = new DataSet();
    9289        Way from = TestUtils.newWay("highway=residential", new Node(new LatLon(0.0, 0.0)),
     
    122119     */
    123120    @Test
    124     public void testTicket18477() {
     121    void testTicket18477() {
    125122        final Node n10 = addNode(1, 0);
    126123        final Node n21 = addNode(2, 1);
     
    133130        dataSet.setSelected(n10, n21);
    134131        SplitWayAction.runOn(dataSet);
    135         assertSame(String.format("Found %d ways after split action instead of 4.", dataSet.getWays().size()),
    136                 dataSet.getWays().size(), 4);
     132        assertSame(4, dataSet.getWays().size(), String.format("Found %d ways after split action instead of 4.", dataSet.getWays().size()));
    137133    }
    138134}
  • trunk/test/unit/org/openstreetmap/josm/actions/UnGlueActionTest.java

    r16300 r17275  
    22package org.openstreetmap.josm.actions;
    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;
    66
    7 import org.junit.Before;
    8 import org.junit.Rule;
    9 import org.junit.Test;
     7import org.junit.jupiter.api.BeforeEach;
     8import org.junit.jupiter.api.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
    1010import org.openstreetmap.josm.data.coor.LatLon;
    1111import org.openstreetmap.josm.data.osm.DataSet;
     
    2121 * Unit tests for class {@link UnGlueAction}.
    2222 */
    23 public final class UnGlueActionTest {
     23final class UnGlueActionTest {
    2424
    2525    /** Class under test. */
     
    2929     * Setup test.
    3030     */
    31     @Rule
     31    @RegisterExtension
    3232    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3333    public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
     
    3636     * Setup test.
    3737     */
    38     @Before
     38    @BeforeEach
    3939    public void setUp() {
    4040        if (action == null) {
     
    4848     */
    4949    @Test
    50     public void testSelectionEmpty() {
     50    void testSelectionEmpty() {
    5151        DataSet ds = new DataSet();
    5252        OsmDataLayer layer = new OsmDataLayer(ds, "", null);
     
    6666     */
    6767    @Test
    68     public void testSingleNodeNotInWay() {
     68    void testSingleNodeNotInWay() {
    6969        DataSet ds = new DataSet();
    7070        Node n = new Node(LatLon.ZERO);
     
    8787     */
    8888    @Test
    89     public void testSingleNodeInSingleWay() {
     89    void testSingleNodeInSingleWay() {
    9090        DataSet ds = new DataSet();
    9191        Node n1 = new Node(LatLon.ZERO);
     
    114114     */
    115115    @Test
    116     public void testSingleNodeInTwoWays() {
     116    void testSingleNodeInTwoWays() {
    117117        DataSet ds = new DataSet();
    118118        Node n1 = new Node(LatLon.ZERO);
  • trunk/test/unit/org/openstreetmap/josm/actions/UnJoinNodeWayActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions;
    33
    4 import static org.junit.Assert.assertFalse;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
    55
    66import java.util.Arrays;
    77
    8 import org.junit.Rule;
    9 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
    1010import org.openstreetmap.josm.data.coor.EastNorth;
    1111import org.openstreetmap.josm.data.osm.DataSet;
     
    2121 * Unit tests for class {@link UnJoinNodeWayAction}.
    2222 */
    23 public final class UnJoinNodeWayActionTest {
     23final class UnJoinNodeWayActionTest {
    2424
    2525    /**
     
    4040     * Setup test.
    4141     */
    42     @Rule
     42    @RegisterExtension
    4343    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4444    public JOSMTestRules test = new JOSMTestRules();
     
    5151     */
    5252    @Test
    53     public void testTicket10396() {
     53    void testTicket10396() {
    5454        DataSet dataSet = new DataSet();
    5555        OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
     
    8383
    8484        // Ensures node n2 remove from w
    85         assertFalse("Node n2 wasn't removed from way w.", w.containsNode(n2));
     85        assertFalse(w.containsNode(n2), "Node n2 wasn't removed from way w.");
    8686    }
    8787}
  • trunk/test/unit/org/openstreetmap/josm/actions/corrector/ReverseWayNoTagCorrectorTest.java

    r17023 r17275  
    22package org.openstreetmap.josm.actions.corrector;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    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.osm.Tag;
    99import org.openstreetmap.josm.data.osm.Tagged;
     
    1616 * Unit tests of {@link ReverseWayNoTagCorrector} class.
    1717 */
    18 public class ReverseWayNoTagCorrectorTest {
     18class ReverseWayNoTagCorrectorTest {
    1919
    2020    /**
    2121     * Setup test.
    2222     */
    23     @Rule
     23    @RegisterExtension
    2424    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2525    public JOSMTestRules test = new JOSMTestRules();
     
    2929     */
    3030    @Test
    31     public void testDirectionalTags() {
     31    void testDirectionalTags() {
    3232        assertEquals(1, ReverseWayNoTagCorrector.getDirectionalTags(new Tag("waterway", "drain")).size());
    3333        assertEquals(1, ReverseWayNoTagCorrector.getDirectionalTags(new Tag("man_made", "embankment")).size());
  • trunk/test/unit/org/openstreetmap/josm/actions/corrector/ReverseWayTagCorrectorTest.java

    r16771 r17275  
    88
    99import org.junit.Assert;
    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.data.correction.TagCorrection;
    1313import org.openstreetmap.josm.data.osm.Node;
     
    2424 * Unit tests of {@link ReverseWayTagCorrector} class.
    2525 */
    26 public class ReverseWayTagCorrectorTest {
     26class ReverseWayTagCorrectorTest {
    2727
    2828    /**
    2929     * Setup test.
    3030     */
    31     @Rule
     31    @RegisterExtension
    3232    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3333    public JOSMTestRules test = new JOSMTestRules();
     
    3838     */
    3939    @Test
    40     public void testUtilityClass() throws ReflectiveOperationException {
     40    void testUtilityClass() throws ReflectiveOperationException {
    4141        UtilityClassTestUtil.assertUtilityClassWellDefined(ReverseWayTagCorrector.TagSwitcher.class);
    4242    }
     
    4646     */
    4747    @Test
    48     public void testTagSwitch() {
     48    void testTagSwitch() {
    4949        // oneway
    5050        assertSwitch(new Tag("oneway", "yes"), new Tag("oneway", "-1"));
     
    121121     */
    122122    @Test
    123     public void testSwitchingWayNodes() {
     123    void testSwitchingWayNodes() {
    124124        final Map<OsmPrimitive, List<TagCorrection>> tagCorrections = getTagCorrectionsForWay("direction=forward");
    125125        Assert.assertEquals(1, tagCorrections.size());
     
    132132     */
    133133    @Test
    134     public void testNotSwitchingWayNodes() {
     134    void testNotSwitchingWayNodes() {
    135135        Assert.assertEquals(0, getTagCorrectionsForWay("direction=SSW").size());
    136136        Assert.assertEquals(0, getTagCorrectionsForWay("direction=145").size());
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/ChangesetContentDownloadTaskTest.java

    r10945 r17275  
    22package org.openstreetmap.josm.actions.downloadtasks;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
     5import static org.junit.jupiter.api.Assertions.assertThrows;
    56
    67import java.awt.Component;
    78import java.util.Arrays;
    89
    9 import org.junit.Rule;
    10 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
    1112import org.openstreetmap.josm.testutils.JOSMTestRules;
    1213
     
    1617 * Unit tests for class {@link ChangesetContentDownloadTask}.
    1718 */
    18 public class ChangesetContentDownloadTaskTest {
     19class ChangesetContentDownloadTaskTest {
    1920
    2021    /**
    2122     * Setup test.
    2223     */
    23     @Rule
     24    @RegisterExtension
    2425    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2526    public JOSMTestRules test = new JOSMTestRules();
     
    2930     */
    3031    @Test
    31     public void testChangesetContentDownloadTask() {
     32    void testChangesetContentDownloadTask() {
    3233        Component parent = new Component() {
    3334            // empty component
     
    4142     * Unit test of {@code ChangesetContentDownloadTask#ChangesetContentDownloadTask} - invalid changeset id.
    4243     */
    43     @Test(expected = IllegalArgumentException.class)
    44     public void testChangesetContentDownloadTaskInvalidId() {
    45         new ChangesetContentDownloadTask(0);
     44    @Test
     45    void testChangesetContentDownloadTaskInvalidId() {
     46        assertThrows(IllegalArgumentException.class, () -> new ChangesetContentDownloadTask(0));
    4647    }
    4748
     
    4950     * Unit test of {@code ChangesetContentDownloadTask#ChangesetContentDownloadTask} - null parent.
    5051     */
    51     @Test(expected = IllegalArgumentException.class)
    52     public void testChangesetContentDownloadTaskNullParent1() {
    53         new ChangesetContentDownloadTask(1);
     52    @Test
     53    void testChangesetContentDownloadTaskNullParent1() {
     54        assertThrows(IllegalArgumentException.class, () -> new ChangesetContentDownloadTask(1));
    5455    }
    5556
     
    5758     * Unit test of {@code ChangesetContentDownloadTask#ChangesetContentDownloadTask} - null parent.
    5859     */
    59     @Test(expected = IllegalArgumentException.class)
    60     public void testChangesetContentDownloadTaskNullParent2() {
    61         new ChangesetContentDownloadTask(Arrays.asList(1, 2));
     60    @Test
     61    void testChangesetContentDownloadTaskNullParent2() {
     62        assertThrows(IllegalArgumentException.class, () -> new ChangesetContentDownloadTask(Arrays.asList(1, 2)));
    6263    }
    6364}
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/ChangesetHeaderDownloadTaskTest.java

    r15153 r17275  
    22package org.openstreetmap.josm.actions.downloadtasks;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
     5import static org.junit.jupiter.api.Assertions.assertThrows;
    56
    67import java.awt.Component;
    78import java.util.Collections;
    89
    9 import org.junit.Rule;
    10 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
    1112import org.openstreetmap.josm.data.osm.Changeset;
    1213import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1718 * Unit tests for class {@link ChangesetHeaderDownloadTask}.
    1819 */
    19 public class ChangesetHeaderDownloadTaskTest {
     20class ChangesetHeaderDownloadTaskTest {
    2021
    2122    /**
    2223     * Setup test.
    2324     */
    24     @Rule
     25    @RegisterExtension
    2526    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2627    public JOSMTestRules test = new JOSMTestRules();
     
    3031     */
    3132    @Test
    32     public void testBuildTaskForChangesets() {
     33    void testBuildTaskForChangesets() {
    3334        Component parent = new Component() {
    3435            // empty component
     
    4243     * Unit test of {@code ChangesetHeaderDownloadTask#buildTaskForChangesets} - null parent.
    4344     */
    44     @Test(expected = NullPointerException.class)
    45     public void testBuildTaskForChangesetsNullParent() {
    46         ChangesetHeaderDownloadTask.buildTaskForChangesets(Collections.singleton(new Changeset(1)));
     45    @Test
     46    void testBuildTaskForChangesetsNullParent() {
     47        assertThrows(NullPointerException.class,
     48                () -> ChangesetHeaderDownloadTask.buildTaskForChangesets(Collections.singleton(new Changeset(1))));
    4749    }
    4850}
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/ChangesetQueryTaskTest.java

    r10945 r17275  
    22package org.openstreetmap.josm.actions.downloadtasks;
    33
    4 import static org.junit.Assert.assertNotNull;
     4import static org.junit.jupiter.api.Assertions.assertNotNull;
     5import static org.junit.jupiter.api.Assertions.assertThrows;
    56
    67import java.awt.Component;
    78
    8 import org.junit.Rule;
    9 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
     10import org.junit.jupiter.api.extension.RegisterExtension;
    1011import org.openstreetmap.josm.io.ChangesetQuery;
    1112import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1617 * Unit tests for class {@link ChangesetQueryTask}.
    1718 */
    18 public class ChangesetQueryTaskTest {
     19class ChangesetQueryTaskTest {
    1920
    2021    /**
    2122     * Setup test.
    2223     */
    23     @Rule
     24    @RegisterExtension
    2425    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2526    public JOSMTestRules test = new JOSMTestRules();
     
    2930     */
    3031    @Test
    31     public void testChangesetQueryTask() {
     32    void testChangesetQueryTask() {
    3233        Component parent = new Component() {
    3334            // empty component
     
    3940     * Unit test of {@code ChangesetQueryTask#ChangesetQueryTask} - null parent.
    4041     */
    41     @Test(expected = IllegalArgumentException.class)
    42     public void testChangesetQueryTaskNullParent() {
    43         new ChangesetQueryTask(new ChangesetQuery());
     42    @Test
     43    void testChangesetQueryTaskNullParent() {
     44        assertThrows(IllegalArgumentException.class, () -> new ChangesetQueryTask(new ChangesetQuery()));
    4445    }
    4546}
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadReferrersTaskTest.java

    r10945 r17275  
    22package org.openstreetmap.josm.actions.downloadtasks;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.fail;
    77
    8 import org.junit.Rule;
    9 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
    1010import org.openstreetmap.josm.data.coor.LatLon;
    1111import org.openstreetmap.josm.data.osm.DataSet;
     
    2020 * Unit tests for class {@link DownloadReferrersTask}.
    2121 */
    22 public class DownloadReferrersTaskTest {
     22class DownloadReferrersTaskTest {
    2323
    2424    /**
    2525     * Setup test.
    2626     */
    27     @Rule
     27    @RegisterExtension
    2828    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2929    public JOSMTestRules test = new JOSMTestRules();
     
    3333     */
    3434    @Test
    35     public void testDownloadReferrersTask() {
     35    void testDownloadReferrersTask() {
    3636        DataSet ds = new DataSet();
    3737        Node n1 = (Node) OsmPrimitiveType.NODE.newInstance(-1, true);
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskListTest.java

    r15216 r17275  
    22package org.openstreetmap.josm.actions.downloadtasks;
    33
    4 import static org.junit.Assert.assertNull;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertTrue;
     5import static org.junit.jupiter.api.Assertions.assertNull;
    66
    77import java.awt.geom.Area;
    88import java.util.Collections;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
    1212import org.openstreetmap.josm.data.Bounds;
    1313import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
     
    1919 * Unit tests for class {@link DownloadTaskList}.
    2020 */
    21 public class DownloadTaskListTest {
     21class DownloadTaskListTest {
    2222
    2323    /**
    2424     * Setup test.
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules();
     
    3232     */
    3333    @Test
    34     public void testDownloadTaskList() {
     34    void testDownloadTaskList() {
    3535        assertTrue(new DownloadTaskList().getDownloadedPrimitives().isEmpty());
    3636    }
     
    4141     */
    4242    @Test
    43     public void testDownloadAreaEmpty() throws Exception {
     43    void testDownloadAreaEmpty() throws Exception {
    4444        DownloadTaskList list = new DownloadTaskList();
    4545        assertNull(list.download(false,
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/PostDownloadHandlerTest.java

    r16945 r17275  
    22package org.openstreetmap.josm.actions.downloadtasks;
    33
    4 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertTrue;
    55
    66import java.net.URL;
     
    1313import java.util.concurrent.TimeoutException;
    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.data.Bounds;
    1818import org.openstreetmap.josm.gui.progress.ProgressMonitor;
     
    2525 * Unit tests for class {@link PostDownloadHandler}.
    2626 */
    27 public class PostDownloadHandlerTest {
     27class PostDownloadHandlerTest {
    2828
    2929    /**
    3030     * Setup test.
    3131     */
    32     @Rule
     32    @RegisterExtension
    3333    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3434    public JOSMTestRules test = new JOSMTestRules();
     
    124124     */
    125125    @Test
    126     public void testRunExceptionFuture() {
     126    void testRunExceptionFuture() {
    127127        Logging.clearLastErrorAndWarnings();
    128128        new PostDownloadHandler(null, newFuture("testRunExceptionFuture")).run();
    129         assertTrue(Logging.getLastErrorAndWarnings().toString(),
     129        assertTrue(
    130130                Logging.getLastErrorAndWarnings().stream()
    131                         .anyMatch(e -> e.endsWith("E: java.util.concurrent.ExecutionException: testRunExceptionFuture")));
     131                        .anyMatch(e -> e.endsWith("E: java.util.concurrent.ExecutionException: testRunExceptionFuture")),
     132                        Logging.getLastErrorAndWarnings().toString());
    132133    }
    133134
     
    136137     */
    137138    @Test
    138     public void testRunNoError() {
     139    void testRunNoError() {
    139140        Logging.clearLastErrorAndWarnings();
    140141        new PostDownloadHandler(newTask(Collections.emptyList()), newFuture(null)).run();
    141         assertTrue(Logging.getLastErrorAndWarnings().toString(), Logging.getLastErrorAndWarnings().isEmpty());
     142        assertTrue(Logging.getLastErrorAndWarnings().isEmpty(), Logging.getLastErrorAndWarnings().toString());
    142143    }
    143144
     
    146147     */
    147148    @Test
    148     public void testRunOneError() {
     149    void testRunOneError() {
    149150        Logging.clearLastErrorAndWarnings();
    150151        new PostDownloadHandler(newTask(Collections.singletonList(new Object())), newFuture(null)).run();
    151         assertTrue(Logging.getLastErrorAndWarnings().toString(), Logging.getLastErrorAndWarnings().isEmpty());
     152        assertTrue(Logging.getLastErrorAndWarnings().isEmpty(), Logging.getLastErrorAndWarnings().toString());
    152153    }
    153154
     
    156157     */
    157158    @Test
    158     public void testRunMultipleErrors() {
     159    void testRunMultipleErrors() {
    159160        Logging.clearLastErrorAndWarnings();
    160161        new PostDownloadHandler(newTask(Arrays.asList("foo", new Exception("bar"), new Object())), newFuture(null)).run();
    161         assertTrue(Logging.getLastErrorAndWarnings().toString(),
     162        assertTrue(
    162163                Logging.getLastErrorAndWarnings().stream()
    163                         .anyMatch(e -> e.endsWith("E: java.lang.Exception: bar")));
     164                        .anyMatch(e -> e.endsWith("E: java.lang.Exception: bar")), Logging.getLastErrorAndWarnings().toString());
    164165    }
    165166}
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/AddNoteActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    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;
    66
    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.data.osm.DataSet;
    1010import org.openstreetmap.josm.data.osm.NoteData;
     
    1919 * Unit tests for class {@link AddNoteAction}.
    2020 */
    21 public class AddNoteActionTest {
     21class AddNoteActionTest {
    2222
    2323    /**
    2424     * Setup test.
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    3232     */
    3333    @Test
    34     public void testMode() {
     34    void testMode() {
    3535        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    3636        try {
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    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;
    66
    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.actions.mapmode.DeleteAction.DeleteMode;
     
    2020 * Unit tests for class {@link DeleteAction}.
    2121 */
    22 public class DeleteActionTest {
     22class DeleteActionTest {
    2323
    2424    /**
    2525     * Setup test.
    2626     */
    27     @Rule
     27    @RegisterExtension
    2828    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2929    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    3333     */
    3434    @Test
    35     public void testMode() {
     35    void testMode() {
    3636        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    3737        try {
     
    5252     */
    5353    @Test
    54     public void testEnumDeleteMode() {
     54    void testEnumDeleteMode() {
    5555        TestUtils.superficialEnumCodeCoverage(DeleteMode.class);
    5656    }
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    88import java.awt.event.InputEvent;
     
    1414import javax.swing.JList;
    1515
    16 import org.junit.Rule;
    17 import org.junit.Test;
     16import org.junit.jupiter.api.extension.RegisterExtension;
     17import org.junit.jupiter.api.Test;
    1818import org.openstreetmap.josm.data.UndoRedoHandler;
    1919import org.openstreetmap.josm.data.coor.EastNorth;
     
    3333 * Unit tests for class {@link DrawAction}.
    3434 */
    35 public class DrawActionTest {
     35class DrawActionTest {
    3636
    3737    /**
    3838     * Setup test.
    3939     */
    40     @Rule
     40    @RegisterExtension
    4141    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4242    public JOSMTestRules test = new JOSMTestRules().main().projection().timeout(20000);
     
    5151     */
    5252    @Test
    53     public void testTicket12011() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
     53    void testTicket12011() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException {
    5454        DataSet dataSet = new DataSet();
    5555        OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    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;
    66
    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.actions.mapmode.ExtrudeAction.Mode;
     
    2020 * Unit tests for class {@link ExtrudeAction}.
    2121 */
    22 public class ExtrudeActionTest {
     22class ExtrudeActionTest {
    2323
    2424    /**
    2525     * Setup test.
    2626     */
    27     @Rule
     27    @RegisterExtension
    2828    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2929    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    3333     */
    3434    @Test
    35     public void testMode() {
     35    void testMode() {
    3636        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    3737        try {
     
    5252     */
    5353    @Test
    54     public void testEnumMode() {
     54    void testEnumMode() {
    5555        TestUtils.superficialEnumCodeCoverage(Mode.class);
    5656    }
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    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;
    66
    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.actions.mapmode.ImproveWayAccuracyAction.State;
     
    2020 * Unit tests for class {@link ImproveWayAccuracyAction}.
    2121 */
    22 public class ImproveWayAccuracyActionTest {
     22class ImproveWayAccuracyActionTest {
    2323
    2424    /**
    2525     * Setup test.
    2626     */
    27     @Rule
     27    @RegisterExtension
    2828    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2929    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    3333     */
    3434    @Test
    35     public void testMode() {
     35    void testMode() {
    3636        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    3737        try {
     
    5252     */
    5353    @Test
    54     public void testEnumState() {
     54    void testEnumState() {
    5555        TestUtils.superficialEnumCodeCoverage(State.class);
    5656    }
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    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;
    66
    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.actions.mapmode.ParallelWayAction.Mode;
     
    2121 * Unit tests for class {@link ParallelWayAction}.
    2222 */
    23 public class ParallelWayActionTest {
     23class ParallelWayActionTest {
    2424
    2525    /**
    2626     * Setup test.
    2727     */
    28     @Rule
     28    @RegisterExtension
    2929    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3030    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    3434     */
    3535    @Test
    36     public void testMode() {
     36    void testMode() {
    3737        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    3838        try {
     
    5353     */
    5454    @Test
    55     public void testEnumMode() {
     55    void testEnumMode() {
    5656        TestUtils.superficialEnumCodeCoverage(Mode.class);
    5757    }
     
    6161     */
    6262    @Test
    63     public void testEnumModifier() {
     63    void testEnumModifier() {
    6464        TestUtils.superficialEnumCodeCoverage(Modifier.class);
    6565    }
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/PlayHeadDragModeTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    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;
    66
    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.data.osm.DataSet;
    1010import org.openstreetmap.josm.gui.MainApplication;
     
    1919 * Unit tests for class {@link PlayHeadDragMode}.
    2020 */
    21 public class PlayHeadDragModeTest {
     21class PlayHeadDragModeTest {
    2222
    2323    /**
    2424     * Setup test.
    2525     */
    26     @Rule
     26    @RegisterExtension
    2727    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2828    public JOSMTestRules test = new JOSMTestRules().main().projection();
     
    3232     */
    3333    @Test
    34     public void testMode() {
     34    void testMode() {
    3535        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "", null);
    3636        try {
  • trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java

    r14977 r17275  
    22package org.openstreetmap.josm.actions.mapmode;
    33
    4 import static org.junit.Assert.assertFalse;
    5 import static org.junit.Assert.assertSame;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertSame;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    88import java.awt.event.InputEvent;
     
    1212import java.util.Collection;
    1313
    14 import org.junit.Rule;
    15 import org.junit.Test;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
    1616import org.openstreetmap.josm.TestUtils;
    1717import org.openstreetmap.josm.actions.mapmode.SelectAction.Mode;
     
    3434 * Unit tests for class {@link SelectAction}.
    3535 */
    36 public class SelectActionTest {
     36class SelectActionTest {
    3737
    3838    boolean nodesMerged;
     
    4949        public void mergeNodes(OsmDataLayer layer, Collection<Node> nodes,
    5050                               Node targetLocationNode) {
    51             assertSame(String.format("Should merge two nodes, %d found", nodes.size()),
    52                        nodes.size(), 2);
     51            assertSame(2, nodes.size(), String.format("Should merge two nodes, %d found", nodes.size()));
    5352            nodesMerged = true;
    5453        }
     
    5857     * Setup test.
    5958     */
    60     @Rule
     59    @RegisterExtension
    6160    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    6261    public JOSMTestRules test = new JOSMTestRules().projection().main();
     
    7069    @Test
    7170    @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD")
    72     public void testTicket10748() throws ReflectiveOperationException {
     71    void testTicket10748() throws ReflectiveOperationException {
    7372        DataSet dataSet = new DataSet();
    7473        OsmDataLayer layer = new OsmDataLayer(dataSet, OsmDataLayer.createNewName(), null);
     
    125124
    126125            // As result of test, we must find a 2 nodes way, from EN(0, 0) to EN(100, 0)
    127             assertTrue("Nodes are not merged", nodesMerged);
    128             assertSame(String.format("Expect exactly one way, found %d%n", dataSet.getWays().size()),
    129                        dataSet.getWays().size(), 1);
     126            assertTrue(nodesMerged, "Nodes are not merged");
     127            assertSame(1, dataSet.getWays().size(), String.format("Expect exactly one way, found %d%n", dataSet.getWays().size()));
    130128            Way rw = dataSet.getWays().iterator().next();
    131             assertFalse("Way shouldn't be deleted\n", rw.isDeleted());
    132             assertSame(String.format("Way shouldn't have 2 nodes, %d found%n", w.getNodesCount()),
    133                        rw.getNodesCount(), 2);
     129            assertFalse(rw.isDeleted(), "Way shouldn't be deleted\n");
     130            assertSame(2, rw.getNodesCount(), String.format("Way shouldn't have 2 nodes, %d found%n", w.getNodesCount()));
    134131            Node r1 = rw.firstNode();
    135132            Node r2 = rw.lastNode();
     
    139136                r2 = tmp;
    140137            }
    141             assertSame(String.format("East should be 0, found %f%n", r1.getEastNorth().east()),
    142                        Double.compare(r1.getEastNorth().east(), 0), 0);
    143             assertSame(String.format("East should be 100, found %f%n", r2.getEastNorth().east()),
    144                        Double.compare(r2.getEastNorth().east(), 100), 0);
     138            assertSame(0, Double.compare(r1.getEastNorth().east(), 0),
     139                    String.format("East should be 0, found %f%n", r1.getEastNorth().east()));
     140            assertSame(0, Double.compare(r2.getEastNorth().east(), 100),
     141                    String.format("East should be 100, found %f%n", r2.getEastNorth().east()));
    145142        } finally {
    146143            // Ensure we clean the place before leaving, even if test fails.
     
    153150     */
    154151    @Test
    155     public void testEnumMode() {
     152    void testEnumMode() {
    156153        TestUtils.superficialEnumCodeCoverage(Mode.class);
    157154    }
     
    161158     */
    162159    @Test
    163     public void testEnumSelectActionCursor() {
     160    void testEnumSelectActionCursor() {
    164161        TestUtils.superficialEnumCodeCoverage(SelectActionCursor.class);
    165162    }
  • trunk/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java

    r16577 r17275  
    22package org.openstreetmap.josm.actions.upload;
    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;
    88
    99import java.util.Arrays;
    1010import java.util.Collection;
    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.command.PseudoCommand;
    1515import org.openstreetmap.josm.command.SequenceCommand;
     
    2727 * Unit tests for class {@link FixDataHook}.
    2828 */
    29 public class FixDataHookTest {
     29class FixDataHookTest {
    3030
    3131    /**
    3232     * Setup test.
    3333     */
    34     @Rule
     34    @RegisterExtension
    3535    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3636    public JOSMTestRules test = new JOSMTestRules().main();
     
    4040     */
    4141    @Test
    42     public void testCheckUpload() {
     42    void testCheckUpload() {
    4343        // Empty data set
    4444        UndoRedoHandler.getInstance().clean();
     
    8585        assertEquals(9, prims.size());
    8686        for (OsmPrimitive o : Arrays.asList(w1, w2, w3, w4, w5, w6, w7, r1, r2)) {
    87             assertTrue(o.toString(), prims.contains(o));
     87            assertTrue(prims.contains(o), o.toString());
    8888        }
    8989        Collection<PseudoCommand> cmds = seq.getChildren();
  • trunk/test/unit/org/openstreetmap/josm/actions/upload/ValidateUploadHookTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.actions.upload;
    33
    4 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertTrue;
    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.APIDataSet;
    99import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1414 * Unit tests for class {@link ValidateUploadHook}.
    1515 */
    16 public class ValidateUploadHookTest {
     16class ValidateUploadHookTest {
    1717
    1818    /**
    1919     * Setup test.
    2020     */
    21     @Rule
     21    @RegisterExtension
    2222    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2323    public JOSMTestRules test = new JOSMTestRules().fakeAPI().timeout(30000);
     
    2727     */
    2828    @Test
    29     public void testCheckUpload() {
     29    void testCheckUpload() {
    3030        assertTrue(new ValidateUploadHook().checkUpload(new APIDataSet()));
    3131    }
  • trunk/test/unit/org/openstreetmap/josm/command/AddCommandTest.java

    r13079 r17275  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    77import java.util.ArrayList;
    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;
    1212import org.openstreetmap.josm.data.coor.LatLon;
     
    2727 * Unit tests of {@link AddCommand} class.
    2828 */
    29 public class AddCommandTest {
     29class AddCommandTest {
    3030
    3131    /**
    3232     * We need prefs for nodes.
    3333     */
    34     @Rule
     34    @RegisterExtension
    3535    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3636    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4040     */
    4141    @Test
    42     public void testAdd() {
     42    void testAdd() {
    4343        DataSet ds = new DataSet();
    4444        assertArrayEquals(new Object[0], ds.allPrimitives().toArray());
     
    5656     */
    5757    @Test
    58     public void testAddToLayer() {
     58    void testAddToLayer() {
    5959        DataSet ds1 = new DataSet();
    6060        DataSet ds2 = new DataSet();
     
    7171     */
    7272    @Test
    73     public void testUndo() {
     73    void testUndo() {
    7474        Node osm = new Node(LatLon.ZERO);
    7575        DataSet ds = new DataSet(osm);
     
    8686     */
    8787    @Test
    88     public void testParticipatingPrimitives() {
     88    void testParticipatingPrimitives() {
    8989        Node osm = new Node(LatLon.ZERO);
    9090
     
    9696     */
    9797    @Test
    98     public void testFillModifiedData() {
     98    void testFillModifiedData() {
    9999        Node osm = new Node(LatLon.ZERO);
    100100
     
    112112     */
    113113    @Test
    114     public void testDescription() {
     114    void testDescription() {
    115115        Node node = new Node(LatLon.ZERO);
    116116        node.put("name", "xy");
     
    131131     */
    132132    @Test
    133     public void testEqualsContract() {
     133    void testEqualsContract() {
    134134        TestUtils.assumeWorkingEqualsVerifier();
    135135        EqualsVerifier.forClass(AddCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/AddPrimitivesCommandTest.java

    r17240 r17275  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertSame;
    7 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertSame;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    99import java.util.ArrayList;
     
    1212import java.util.List;
    1313
    14 import org.junit.Rule;
    15 import org.junit.Test;
     14import org.junit.jupiter.api.extension.RegisterExtension;
     15import org.junit.jupiter.api.Test;
    1616import org.openstreetmap.josm.TestUtils;
    1717import org.openstreetmap.josm.data.coor.LatLon;
     
    3434 * Unit tests of {@link AddPrimitivesCommand} class.
    3535 */
    36 public class AddPrimitivesCommandTest {
     36class AddPrimitivesCommandTest {
    3737
    3838    /**
    3939     * We need prefs for nodes.
    4040     */
    41     @Rule
     41    @RegisterExtension
    4242    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4343    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4747     */
    4848    @Test
    49     public void testAdd() {
     49    void testAdd() {
    5050        DataSet ds = new DataSet();
    5151
     
    6161     */
    6262    @Test
    63     public void testAddSetSelection() {
     63    void testAddSetSelection() {
    6464        DataSet ds = new DataSet();
    6565
     
    7777     */
    7878    @Test
    79     public void testAddToLayer() {
     79    void testAddToLayer() {
    8080        DataSet ds1 = new DataSet();
    8181        DataSet ds2 = new DataSet();
     
    9595     */
    9696    @Test
    97     public void testAddIgnoresExisting() {
     97    void testAddIgnoresExisting() {
    9898        DataSet ds = new DataSet();
    9999
     
    114114     */
    115115    @Test
    116     public void testDescription() {
     116    void testDescription() {
    117117        DataSet ds = new DataSet();
    118118
     
    138138     */
    139139    @Test
    140     public void testUndo() {
     140    void testUndo() {
    141141        DataSet ds = new DataSet();
    142142
     
    172172     */
    173173    @Test
    174     public void testUndoIgnoresExisting() {
     174    void testUndoIgnoresExisting() {
    175175        DataSet ds = new DataSet();
    176176
     
    208208     */
    209209    @Test
    210     public void testUndoIgnoresExistingAsDeleted() {
     210    void testUndoIgnoresExistingAsDeleted() {
    211211        DataSet ds = new DataSet();
    212212
     
    243243     */
    244244    @Test
    245     public void testUndoIgnoresExistingSameUniqueIdDifferentType() {
     245    void testUndoIgnoresExistingSameUniqueIdDifferentType() {
    246246        DataSet ds = new DataSet();
    247247
     
    288288     */
    289289    @Test
    290     public void testParticipatingPrimitives() {
     290    void testParticipatingPrimitives() {
    291291        DataSet ds = new DataSet();
    292292
     
    308308     */
    309309    @Test
    310     public void testFillModifiedData() {
     310    void testFillModifiedData() {
    311311        ArrayList<OsmPrimitive> modified = new ArrayList<>();
    312312        ArrayList<OsmPrimitive> deleted = new ArrayList<>();
     
    364364     */
    365365    @Test
    366     public void testEqualsContract() {
     366    void testEqualsContract() {
    367367        TestUtils.assumeWorkingEqualsVerifier();
    368368        EqualsVerifier.forClass(AddPrimitivesCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/ChangeCommandTest.java

    r13079 r17275  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertNull;
    7 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
    89
    910import java.util.ArrayList;
     
    1112import java.util.List;
    1213
    13 import org.junit.Before;
    14 import org.junit.Rule;
    15 import org.junit.Test;
     14import org.junit.jupiter.api.BeforeEach;
     15import org.junit.jupiter.api.Test;
     16import org.junit.jupiter.api.extension.RegisterExtension;
    1617import org.openstreetmap.josm.TestUtils;
    1718import org.openstreetmap.josm.command.CommandTest.CommandTestData;
     
    3435 * Unit tests of {@link ChangeCommand} class.
    3536 */
    36 public class ChangeCommandTest {
     37class ChangeCommandTest {
    3738
    3839    /**
    3940     * We need prefs for nodes.
    4041     */
    41     @Rule
     42    @RegisterExtension
    4243    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4344    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4748     * Set up the test data.
    4849     */
    49     @Before
     50    @BeforeEach
    5051    public void createTestData() {
    5152        testData = new CommandTestData();
     
    5556     * Test that empty ways are prevented.
    5657     */
    57     @Test(expected = IllegalArgumentException.class)
    58     public void testPreventEmptyWays() {
     58    @Test
     59    void testPreventEmptyWays() {
    5960        Way emptyWay = new Way();
    60         new ChangeCommand(testData.existingWay, emptyWay);
     61        assertThrows(IllegalArgumentException.class, () -> new ChangeCommand(testData.existingWay, emptyWay));
    6162    }
    6263
     
    6566     */
    6667    @Test
    67     public void testChange() {
     68    void testChange() {
    6869        Node newNode = new Node(5);
    6970        newNode.setCoor(LatLon.NORTH_POLE);
     
    8889     * Test {@link ChangeCommand#executeCommand()} fails if ID is changed
    8990     */
    90     @Test(expected = DataIntegrityProblemException.class)
    91     public void testChangeIdChange() {
     91    @Test
     92    void testChangeIdChange() {
    9293        Node newNode = new Node(1);
    9394        newNode.setCoor(LatLon.NORTH_POLE);
    9495
    95         new ChangeCommand(testData.existingNode, newNode).executeCommand();
     96        assertThrows(DataIntegrityProblemException.class, () -> new ChangeCommand(testData.existingNode, newNode).executeCommand());
    9697    }
    9798
     
    100101     */
    101102    @Test
    102     public void testUndo() {
     103    void testUndo() {
    103104        Node newNode = new Node(5);
    104105        newNode.setCoor(LatLon.NORTH_POLE);
     
    121122     */
    122123    @Test
    123     public void testFillModifiedData() {
     124    void testFillModifiedData() {
    124125        ArrayList<OsmPrimitive> modified = new ArrayList<>();
    125126        ArrayList<OsmPrimitive> deleted = new ArrayList<>();
     
    135136     */
    136137    @Test
    137     public void testDescription() {
     138    void testDescription() {
    138139        Node node = new Node(LatLon.ZERO);
    139140        node.put("name", "xy");
     
    154155     */
    155156    @Test
    156     public void testEqualsContract() {
     157    void testEqualsContract() {
    157158        TestUtils.assumeWorkingEqualsVerifier();
    158159        EqualsVerifier.forClass(ChangeCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/ChangeMembersCommandTest.java

    r17199 r17275  
    22package org.openstreetmap.josm.command;
    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;
    66
    77import java.util.Collections;
    88import java.util.List;
    99
    10 import org.junit.Before;
    11 import org.junit.Rule;
    12 import org.junit.Test;
     10import org.junit.jupiter.api.BeforeEach;
     11import org.junit.jupiter.api.Test;
     12import org.junit.jupiter.api.extension.RegisterExtension;
    1313import org.openstreetmap.josm.TestUtils;
    1414import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
     
    2828 * Unit tests of {@link ChangeMembersCommand} class.
    2929 */
    30 public class ChangeMembersCommandTest {
     30class ChangeMembersCommandTest {
    3131
    3232    /**
    3333     * We need prefs for nodes.
    3434     */
    35     @Rule
     35    @RegisterExtension
    3636    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3737    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4141     * Set up the test data.
    4242     */
    43     @Before
     43    @BeforeEach
    4444    public void createTestData() {
    4545        testData = new CommandTestDataWithRelation();
     
    5050     */
    5151    @Test
    52     public void testChange() {
     52    void testChange() {
    5353        assertTrue(testData.existingNode.getReferrers().contains(testData.existingRelation));
    5454        assertEquals(2, testData.existingRelation.getMembersCount());
     
    7070     */
    7171    @Test
    72     public void testUndo() {
     72    void testUndo() {
    7373        List<RelationMember> members = testData.existingRelation.getMembers();
    7474        members.add(new RelationMember("n2", testData.existingNode2));
     
    8686     */
    8787    @Test
    88     public void testDescription() {
     88    void testDescription() {
    8989        testData.existingRelation.put("name", "xy");
    9090        List<RelationMember> members = testData.existingRelation.getMembers();
     
    9797     */
    9898    @Test
    99     public void testEqualsContract() {
     99    void testEqualsContract() {
    100100        TestUtils.assumeWorkingEqualsVerifier();
    101101        EqualsVerifier.forClass(ChangeMembersCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/ChangeNodesCommandTest.java

    r13079 r17275  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     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.ArrayList;
     
    1213import java.util.List;
    1314
    14 import org.junit.Before;
    15 import org.junit.Rule;
    16 import org.junit.Test;
     15import org.junit.jupiter.api.BeforeEach;
     16import org.junit.jupiter.api.Test;
     17import org.junit.jupiter.api.extension.RegisterExtension;
    1718import org.openstreetmap.josm.TestUtils;
    1819import org.openstreetmap.josm.command.CommandTest.CommandTestData;
     
    3334 * Unit tests of {@link ChangeNodesCommand} class.
    3435 */
    35 public class ChangeNodesCommandTest {
     36class ChangeNodesCommandTest {
    3637
    3738    /**
    3839     * We need prefs for nodes.
    3940     */
    40     @Rule
     41    @RegisterExtension
    4142    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4243    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4647     * Set up the test data.
    4748     */
    48     @Before
     49    @BeforeEach
    4950    public void createTestData() {
    5051        testData = new CommandTestData();
     
    5455     * Test that empty ways are prevented.
    5556     */
    56     @Test(expected = IllegalArgumentException.class)
    57     public void testPreventEmptyWays() {
    58         new ChangeNodesCommand(testData.existingWay, Collections.<Node>emptyList());
     57    @Test
     58    void testPreventEmptyWays() {
     59        assertThrows(IllegalArgumentException.class, () -> new ChangeNodesCommand(testData.existingWay, Collections.<Node>emptyList()));
    5960    }
    6061
     
    6364     */
    6465    @Test
    65     public void testChange() {
     66    void testChange() {
    6667        List<Node> newNodes = testData.existingWay.getNodes();
    6768        Collections.reverse(newNodes);
     
    7980     */
    8081    @Test
    81     public void testUndo() {
     82    void testUndo() {
    8283        List<Node> newNodes = testData.existingWay.getNodes();
    8384        Collections.reverse(newNodes);
     
    9596     */
    9697    @Test
    97     public void testFillModifiedData() {
     98    void testFillModifiedData() {
    9899        ArrayList<OsmPrimitive> modified = new ArrayList<>();
    99100        ArrayList<OsmPrimitive> deleted = new ArrayList<>();
     
    110111     */
    111112    @Test
    112     public void testDescription() {
     113    void testDescription() {
    113114        Node node = new Node(LatLon.ZERO);
    114115        node.put("name", "xy");
     
    125126     */
    126127    @Test
    127     public void testEqualsContract() {
     128    void testEqualsContract() {
    128129        TestUtils.assumeWorkingEqualsVerifier();
    129130        EqualsVerifier.forClass(ChangeNodesCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/ChangePropertyCommandTest.java

    r13079 r17275  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertNull;
    8 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertNull;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.util.ArrayList;
     
    1414import java.util.List;
    1515
    16 import org.junit.Before;
    17 import org.junit.Rule;
    18 import org.junit.Test;
     16import org.junit.jupiter.api.BeforeEach;
     17import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.extension.RegisterExtension;
    1919import org.openstreetmap.josm.TestUtils;
    2020import org.openstreetmap.josm.command.CommandTest.CommandTestData;
     
    3636 * Unit tests of {@link ChangePropertyCommand} class.
    3737 */
    38 public class ChangePropertyCommandTest {
     38class ChangePropertyCommandTest {
    3939
    4040    /**
    4141     * We need prefs for nodes.
    4242     */
    43     @Rule
     43    @RegisterExtension
    4444    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4545    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4949     * Set up the test data.
    5050     */
    51     @Before
     51    @BeforeEach
    5252    public void createTestData() {
    5353        testData = new CommandTestData();
     
    5858     */
    5959    @Test
    60     public void testShortConstructor() {
     60    void testShortConstructor() {
    6161        ChangePropertyCommand command = new ChangePropertyCommand(Arrays.asList(testData.existingNode), "a", "b");
    6262        assertEquals("b", command.getTags().get("a"));
     
    7474     */
    7575    @Test
    76     public void testUpdateSingleProperty() {
     76    void testUpdateSingleProperty() {
    7777        Node node1 = testData.createNode(14);
    7878        Node node2 = testData.createNode(15);
     
    9393     */
    9494    @Test
    95     public void testRemoveProperty() {
     95    void testRemoveProperty() {
    9696        Node node1 = testData.createNode(14);
    9797        Node node2 = testData.createNode(15);
     
    112112     */
    113113    @Test
    114     public void testUpdateMultipleProperties() {
     114    void testUpdateMultipleProperties() {
    115115        Node node1 = testData.createNode(14);
    116116        Node node2 = testData.createNode(15);
     
    139139     */
    140140    @Test
    141     public void testUpdateIgnoresExistingProperty() {
     141    void testUpdateIgnoresExistingProperty() {
    142142        Node node1 = testData.createNode(14);
    143143        Node node2 = testData.createNode(15);
     
    159159     */
    160160    @Test
    161     public void testFillModifiedData() {
     161    void testFillModifiedData() {
    162162        Node node1 = testData.createNode(14);
    163163        Node node2 = testData.createNode(15);
     
    188188     */
    189189    @Test
    190     public void testDescription() {
     190    void testDescription() {
    191191        Node node1 = testData.createNode(14);
    192192        Node node2 = testData.createNode(15);
     
    252252     */
    253253    @Test
    254     public void testChildren() {
     254    void testChildren() {
    255255        Node node1 = testData.createNode(15);
    256256        Node node2 = testData.createNode(16);
     
    278278     */
    279279    @Test
    280     public void testEqualsContract() {
     280    void testEqualsContract() {
    281281        TestUtils.assumeWorkingEqualsVerifier();
    282282        EqualsVerifier.forClass(ChangePropertyCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/ChangePropertyKeyCommandTest.java

    r13079 r17275  
    22package org.openstreetmap.josm.command;
    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.ArrayList;
     
    1111import java.util.Collection;
    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.TestUtils;
    1717import org.openstreetmap.josm.command.CommandTest.CommandTestData;
     
    3030 * Unit tests of {@link ChangePropertyKeyCommand} class.
    3131 */
    32 public class ChangePropertyKeyCommandTest {
     32class ChangePropertyKeyCommandTest {
    3333
    3434    /**
    3535     * We need prefs for nodes.
    3636     */
    37     @Rule
     37    @RegisterExtension
    3838    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3939    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4343     * Set up the test data.
    4444     */
    45     @Before
     45    @BeforeEach
    4646    public void createTestData() {
    4747        testData = new CommandTestData();
     
    5252     */
    5353    @Test
    54     public void testChangeKeySingle() {
     54    void testChangeKeySingle() {
    5555        assertTrue(new ChangePropertyKeyCommand(testData.existingNode, "existing", "newKey").executeCommand());
    5656
     
    6464     */
    6565    @Test
    66     public void testChangeKey() {
     66    void testChangeKey() {
    6767        assertTrue(new ChangePropertyKeyCommand(Arrays.asList(testData.existingNode, testData.existingWay), "existing",
    6868                "newKey").executeCommand());
     
    8080     */
    8181    @Test
    82     public void testChangeKeyIgnored() {
     82    void testChangeKeyIgnored() {
    8383        Node node1 = testData.createNode(15);
    8484        node1.removeAll();
     
    109109     */
    110110    @Test
    111     public void testDescription() {
     111    void testDescription() {
    112112        Node node1 = testData.createNode(15);
    113113        node1.put("name", "xy");
     
    123123     */
    124124    @Test
    125     public void testChildren() {
     125    void testChildren() {
    126126        Node node1 = testData.createNode(15);
    127127        Node node2 = testData.createNode(16);
     
    149149     */
    150150    @Test
    151     public void testEqualsContract() {
     151    void testEqualsContract() {
    152152        TestUtils.assumeWorkingEqualsVerifier();
    153153        EqualsVerifier.forClass(ChangePropertyKeyCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommandTest.java

    r13079 r17275  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertNull;
    8 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertNull;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.util.ArrayList;
    1111
    12 import org.junit.Before;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.extension.RegisterExtension;
    1515import org.openstreetmap.josm.TestUtils;
    1616import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
     
    2929 * Unit tests of {@link ChangeRelationMemberRoleCommand} class.
    3030 */
    31 public class ChangeRelationMemberRoleCommandTest {
     31class ChangeRelationMemberRoleCommandTest {
    3232
    3333    /**
    3434     * We need prefs for nodes.
    3535     */
    36     @Rule
     36    @RegisterExtension
    3737    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3838    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4242     * Set up the test data.
    4343     */
    44     @Before
     44    @BeforeEach
    4545    public void createTestData() {
    4646        testData = new CommandTestDataWithRelation();
     
    5151     */
    5252    @Test
    53     public void testRoleChanged() {
     53    void testRoleChanged() {
    5454        assertTrue(new ChangeRelationMemberRoleCommand(testData.existingRelation, 0, "newRole").executeCommand());
    5555        assertEquals("newRole", testData.existingRelation.getMember(0).getRole());
     
    6767     */
    6868    @Test
    69     public void testWrongIndex() {
     69    void testWrongIndex() {
    7070        // should be ignored
    7171        ChangeRelationMemberRoleCommand command1 = new ChangeRelationMemberRoleCommand(testData.existingRelation, -1, "newRole");
     
    8585     */
    8686    @Test
    87     public void testSameRole() {
     87    void testSameRole() {
    8888        // should be ignored
    8989        assertTrue(new ChangeRelationMemberRoleCommand(testData.existingRelation, 0, "node").executeCommand());
     
    9595     */
    9696    @Test
    97     public void testUndo() {
     97    void testUndo() {
    9898        ChangeRelationMemberRoleCommand command = new ChangeRelationMemberRoleCommand(testData.existingRelation, 0, "newRole");
    9999        command.executeCommand();
     
    114114     */
    115115    @Test
    116     public void testFillModifiedData() {
     116    void testFillModifiedData() {
    117117        ArrayList<OsmPrimitive> modified = new ArrayList<>();
    118118        ArrayList<OsmPrimitive> deleted = new ArrayList<>();
     
    128128     */
    129129    @Test
    130     public void testDescription() {
     130    void testDescription() {
    131131        testData.existingRelation.put("name", "xy");
    132132        assertTrue(new ChangeRelationMemberRoleCommand(testData.existingRelation, 0, "newRole").getDescriptionText()
     
    138138     */
    139139    @Test
    140     public void testChildren() {
     140    void testChildren() {
    141141        assertNull(new ChangeRelationMemberRoleCommand(testData.existingRelation, 0, "newRole").getChildren());
    142142    }
     
    146146     */
    147147    @Test
    148     public void testEqualsContract() {
     148    void testEqualsContract() {
    149149        TestUtils.assumeWorkingEqualsVerifier();
    150150        EqualsVerifier.forClass(ChangeRelationMemberRoleCommand.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/CommandTest.java

    r13079 r17275  
    44import java.util.Arrays;
    55
    6 import org.junit.Rule;
    7 import org.junit.Test;
     6import org.junit.jupiter.api.Test;
     7import org.junit.jupiter.api.extension.RegisterExtension;
    88import org.openstreetmap.josm.TestUtils;
    99import org.openstreetmap.josm.data.coor.LatLon;
     
    3030     * We need prefs for nodes / data sets.
    3131     */
    32     @Rule
     32    @RegisterExtension
    3333    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3434    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    3838     */
    3939    @Test
    40     public void testEqualsContract() {
     40    void testEqualsContract() {
    4141        TestUtils.assumeWorkingEqualsVerifier();
    4242        EqualsVerifier.forClass(Command.class).usingGetClass()
  • trunk/test/unit/org/openstreetmap/josm/command/DeleteCommandTest.java

    r13616 r17275  
    22package org.openstreetmap.josm.command;
    33
    4 import static org.junit.Assert.assertArrayEquals;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     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.ArrayList;
     
    1314import java.util.NoSuchElementException;
    1415
    15 import org.junit.Before;
    16 import org.junit.Rule;
    17 import org.junit.Test;
     16import org.junit.jupiter.api.BeforeEach;
     17import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.extension.RegisterExtension;
    1819import org.openstreetmap.josm.TestUtils;
    1920import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
     
    3536 * Unit tests of {@link DeleteCommand} class.
    3637 */
    37 public class DeleteCommandTest {
     38class DeleteCommandTest {
    3839
    3940    /**
    4041     * We need prefs for nodes.
    4142     */
    42     @Rule
     43    @RegisterExtension
    4344    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    4445    public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
     
    4849     * Set up the test data.
    4950     */
    50     @Before
     51    @BeforeEach
    5152    public void createTestData() {
    5253        testData = new CommandTestDataWithRelation();
     
    5758     */
    5859    @Test
    59     public void testSimpleDelete() {
     60    void testSimpleDelete() {
    6061        Node node = testData.createNode(15);
    6162        assertTrue(testData.layer.data.allPrimitives().contains(node));
     
    7273     */
    7374    @Test
    74     public void testDeleteIgnoresReferences() {
     75    void testDeleteIgnoresReferences() {
    7576        assertTrue(testData.existingNode.getReferrers().contains(testData.existingRelation));
    7677        new DeleteCommand(testData.existingRelation).executeCommand();
     
    9293     * A delete should delete all objects with references to the deleted one
    9394     */
    94     @Test(expected = IllegalArgumentException.class)
    95     public void testDeleteFailsOnDelted() {
     95    @Test
     96    void testDeleteFailsOnDeleted() {
    9697        new DeleteCommand(testData.existingRelation).executeCommand();
    9798
    98         new DeleteCommand(testData.existingRelation).executeCommand();
     99        assertThrows(IllegalArgumentException.class, () -> new DeleteCommand(testData.existingRelation).executeCommand());
    99100    }
    100101
     
    103104     */
    104105    @Test
    105     public void testReferredDelete() {
     106    void testReferredDelete() {
    106107        DeleteCommand.deleteWithReferences(Arrays.asList(testData.existingNode), true).executeCommand();
    107108
     
    115116     */
    116117    @Test
    117     public void testDeleteNodesInWay() {
     118    void testDeleteNodesInWay() {
    118119        testData.existingNode.removeAll();
    119120        // That untagged node should be deleted.
     
    152153     * Test that {@link DeleteCommand} checks for non-null.
    153154     */
    154     @Test(expected = IllegalArgumentException.class)
    155     public void testConsistency() {
    156         new DeleteCommand(Arrays.asList(testData.existingNode, testData.existingWay, null));
     155    @Test
     156    void testConsistency() {
     157        assertThrows(IllegalArgumentException.class, () -> new DeleteCommand(Arrays.asList(testData.existingNode, testData.existingWay, null)));
    157158    }
    158159
     
    160161     * Test that {@link DeleteCommand} checks for the dataset
    161162     */
    162     @Test(expected = IllegalArgumentException.class)
    163     public void testConsistencyDataset() {
     163    @Test
     164    void testConsistencyDataset() {
    164165        testData.layer.getDataSet().removePrimitive(testData.existingNode);
    165         new DeleteCommand(Arrays.asList(testData.existingNode, testData.existingWay));
     166        assertThrows(IllegalArgumentException.class, () -> new DeleteCommand(Arrays.asList(testData.existingNode, testData.existingWay)));
    166167    }
    167168
     
    169170     * Test that {@link DeleteCommand} checks for non-empty list
    170171     */
    171     @Test(expected = NoSuchElementException.class)
    172     public void testConsistencyNonEmpty() {
    173         new DeleteCommand(Arrays.<OsmPrimitive>asList());
     172    @Test
     173    void testConsistencyNonEmpty() {
     174        assertThrows(NoSuchElementException.class, () -> new DeleteCommand(Arrays.<OsmPrimitive>asList()));
    174175    }
    175176
     
    177178     * Test that {@link DeleteCommand} checks for non-null list
    178179     */
    179     @Test(expected = NullPointerException.class)
    180     public void testConsistencyNonNull() {
    181         new DeleteCommand((Collection<OsmPrimitive>) null);
     180    @Test
     181    void testConsistencyNonNull() {
     182        assertThrows(NullPointerException.class, () -> new DeleteCommand((Collection<OsmPrimitive>) null));
    182183    }
    183184
     
    186187     */
    187188    @Test
    188     public void testUndo() {
     189    void testUndo() {
    189190        DeleteCommand command = new DeleteCommand(
    190191                Arrays.asList(testData.existingNode, testData.existingNode2, testData.existingWay));
     
    211212     */
    212213    @Test
    213     public void testDeleteWaySegment() {
     214    void testDeleteWaySegment() {
    214215        Way way1 = testData.createWay(100, testData.createNode(101), testData.createNode(102));
    215216        WaySegment ws = new WaySegment(way1, 0);
     
    225226     */
    226227    @Test
    227     public void testDeleteWaySegmentEndOfWay() {
     228    void testDeleteWaySegmentEndOfWay() {
    228229        Way way = testData.createWay(200, testData.createNode(201), testData.createNode(202), testData.createNode(203),
    229230                testData.createNode(204));
     
    243244     */
    244245    @Test
    245     public void testDeleteWaySegmentStartOfWay() {
     246    void testDeleteWaySegmentStartOfWay() {
    246247        Way way = testData.createWay(100, testData.createNode(101), testData.createNode(102), testData.createNode(103),
    247248                testData.createNode(104));
     
    261262     */
    262263    @Test
    263     public void testDeleteWaySegmentSplit() {
     264    void testDeleteWaySegmentSplit() {
    264265        Node node103 = testData.createNode(103);
    265266        Node node104 = testData.createNode(104);
     
    285286     */
    286287    @Test
    287     public void testDeleteWaySegmentCycle() {
     288    void testDeleteWaySegmentCycle() {
    288289        Node n = testData.createNode(101);
    289290        Way way = testData.createWay(100, n, testData.createNode(102), testData.createNode(103),
     
    304305     */
    305306    @Test
    306     public void testGetChildren() {
     307    void testGetChildren() {
    307308        testData.existingNode.put("name", "xy");
    308309        Collection<PseudoCommand> children = new DeleteCommand(Arrays.<OsmPrimitive>asList(testData.existingNode, testData.existingNode2))
     
    319320     */
    320321    @Test
    321     public void testFillModifiedData() {
     322    void testFillModifiedData() {
    322323        ArrayList<OsmPrimitive> modified = new ArrayList<>();
    323324        ArrayList<OsmPrimitive> deleted = new ArrayList<>();
     
    334335     */
    335336    @Test
    336     public void testGetParticipatingPrimitives() {
     337    void testGetParticipatingPrimitives() {
    337338        DeleteCommand command = new DeleteCommand(Arrays.<OsmPrimitive>asList(testData.existingNode));
    338339        assertArrayEquals(new Object[] {testData.existingNode }, command.getParticipatingPrimitives().toArray());
     
    348349     */
    349350    @Test
    350     public <