Ignore:
Timestamp:
2023-03-21T14:49:10+01:00 (21 months ago)
Author:
taylor.smock
Message:

See #16567: Convert most plugin tests to JUnit 5

Location:
applications/editors/josm/plugins
Files:
79 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideAbstractImageTest.java

    r34432 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    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
    7 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    88import org.openstreetmap.josm.data.coor.LatLon;
    99
    10 public class StreetsideAbstractImageTest {
    11 
    12   /*@Rule
    13   public JOSMTestRules rules = new StreetsideTestRules().platform();*/
    14 
     10class StreetsideAbstractImageTest {
    1511  @Test
    16   public void testIsModified() {
     12  void testIsModified() {
    1713    StreetsideImage img = new StreetsideImage("key___________________", new LatLon(0, 0), 0);
    1814    assertFalse(img.isModified());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideDataTest.java

    r34434 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    58
    69import java.util.Arrays;
    710import java.util.concurrent.ConcurrentSkipListSet;
    811
    9 import org.junit.Before;
    10 import org.junit.Ignore;
    11 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.condition.DisabledIf;
    1215import org.openstreetmap.josm.data.coor.LatLon;
    1316
     
    1821 * @see StreetsideData
    1922 */
    20 public class StreetsideDataTest {
     23@DisabledIf(value = "org.openstreetmap.josm.plugins.streetside.utils.TestUtil#cannotLoadImages", disabledReason = "At JOSM maintainer request (flaky?)")
     24class StreetsideDataTest {
    2125
    2226  /*@Rule
     
    3337   * objects and a {@link StreetsideSequence} object.
    3438   */
    35   @Before
     39  @BeforeEach
    3640  public void setUp() {
    3741    img1 = new StreetsideImage("id1__________________", new LatLon(0.1, 0.1), 90);
     
    5155   * another one in the database, the one that is being added should be ignored.
    5256   */
    53   @Ignore
    5457  @Test
    55   public void addTest() {
     58  void testAdd() {
    5659    data = new StreetsideData();
    5760    assertEquals(0, data.getImages().size());
     
    6972   * Test that the size is properly calculated.
    7073   */
    71   @Ignore
    7274  @Test
    73   public void sizeTest() {
     75  void testSize() {
    7476    assertEquals(4, data.getImages().size());
    7577    data.add(new StreetsideImage("id5__________________", new LatLon(0.1, 0.1), 90));
     
    8183   * and {@link StreetsideData#getHighlightedImage()} methods.
    8284   */
    83   @Ignore
    8485  @Test
    85   public void highlighTest() {
     86  void testHighlight() {
    8687    data.setHighlightedImage(img1);
    8788    assertEquals(img1, data.getHighlightedImage());
    8889
    8990    data.setHighlightedImage(null);
    90     assertEquals(null, data.getHighlightedImage());
     91    assertNull(data.getHighlightedImage());
    9192  }
    9293
     
    9495   * Tests the selection of images.
    9596   */
    96   @Ignore
    9797  @Test
    98   public void selectTest() {
     98  void testSelect() {
    9999    data.setSelectedImage(img1);
    100100    assertEquals(img1, data.getSelectedImage());
     
    104104
    105105    data.setSelectedImage(null);
    106     assertEquals(null, data.getSelectedImage());
     106    assertNull(data.getSelectedImage());
    107107  }
    108108
     
    111111   * {@link StreetsideData#selectPrevious()} methods.
    112112   */
    113   @Ignore
    114113  @Test
    115   public void nextAndPreviousTest() {
     114  void testNextAndPrevious() {
    116115    data.setSelectedImage(img1);
    117116
     
    126125  }
    127126
    128   @Ignore
    129   @Test(expected=IllegalStateException.class)
    130   public void nextOfNullImgTest() {
     127  @Test
     128  void testNextOfNullImg() {
    131129    data.setSelectedImage(null);
    132     data.selectNext();
     130    assertThrows(IllegalStateException.class, data::selectNext);
    133131  }
    134132
    135   @Ignore
    136   @Test(expected=IllegalStateException.class)
    137   public void previousOfNullImgTest() {
     133  @Test
     134  void testPreviousOfNullImg() {
    138135    data.setSelectedImage(null);
    139     data.selectPrevious();
     136    assertThrows(IllegalStateException.class, data::selectPrevious);
    140137  }
    141138
     
    144141   * multiselected List should reset.
    145142   */
    146   @Ignore
    147143  @Test
    148   public void multiSelectTest() {
     144  void testMultiSelect() {
    149145    assertEquals(0, data.getMultiSelectedImages().size());
    150146    data.setSelectedImage(img1);
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideLayerTest.java

    r34434 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    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.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    9 import org.junit.Ignore;
    10 import org.junit.Rule;
    11 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
     10import org.junit.jupiter.api.condition.DisabledIf;
    1211import org.openstreetmap.josm.data.coor.LatLon;
    1312import org.openstreetmap.josm.data.imagery.ImageryInfo;
     
    1514import org.openstreetmap.josm.gui.layer.Layer;
    1615import org.openstreetmap.josm.plugins.streetside.cubemap.CubemapUtils;
    17 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    1816import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     18import org.openstreetmap.josm.testutils.annotations.Main;
     19import org.openstreetmap.josm.testutils.annotations.Projection;
    1920
    20 public class StreetsideLayerTest {
    21 
    22   @Rule
    23   public JOSMTestRules rules = new StreetsideTestRules().main().preferences().projection();
    24 
     21@BasicPreferences
     22@Main
     23@Projection
     24@DisabledIf(value = "org.openstreetmap.josm.plugins.streetside.utils.TestUtil#cannotLoadImages", disabledReason = "At JOSM maintainer request (flaky?)")
     25class StreetsideLayerTest {
    2526  private static Layer getDummyLayer() {
    2627    return ImageryLayer.create(new ImageryInfo("dummy", "https://example.org"));
    2728  }
    2829
    29   @Ignore
    3030  @Test
    31   public void testGetIcon() {
     31  void testGetIcon() {
    3232    assertNotNull(StreetsideLayer.getInstance().getIcon());
    3333  }
    3434
    35   @Ignore
    3635  @Test
    37   public void testIsMergable() {
     36  void testIsMergable() {
    3837    assertFalse(StreetsideLayer.getInstance().isMergable(getDummyLayer()));
    3938  }
    4039
    41   @Ignore
    42   @Test(expected = UnsupportedOperationException.class)
    43   public void testMergeFrom() {
    44     StreetsideLayer.getInstance().mergeFrom(getDummyLayer());
     40  @Test
     41  void testMergeFrom() {
     42    StreetsideLayer layer = StreetsideLayer.getInstance();
     43    Layer dummyLayer = getDummyLayer();
     44    assertThrows(UnsupportedOperationException.class, () -> layer.mergeFrom(dummyLayer));
    4545  }
    4646
    47   @Ignore
    4847  @Test
    49   public void testSetVisible() {
     48  void testSetVisible() {
    5049    StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0));
    5150    StreetsideLayer.getInstance().getData().add(new StreetsideImage(CubemapUtils.TEST_IMAGE_ID, new LatLon(0.0, 0.0), 0.0));
     
    5655    StreetsideLayer.getInstance().setVisible(false);
    5756    for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) {
    58       assertEquals(false, img.isVisible());
     57      assertFalse(img.isVisible());
    5958    }
    6059
     
    6261    StreetsideLayer.getInstance().setVisible(true);
    6362    for (StreetsideAbstractImage img : StreetsideLayer.getInstance().getData().getImages()) {
    64       assertEquals(true, img.isVisible());
     63      assertTrue(img.isVisible());
    6564    }
    6665  }
    6766
    68   @Ignore
    6967  @Test
    70   public void testGetInfoComponent() {
     68  void testGetInfoComponent() {
    7169    Object comp = StreetsideLayer.getInstance().getInfoComponent();
    7270    assertTrue(comp instanceof String);
     
    7472  }
    7573
    76   @Ignore
    7774  @Test
    78   public void testClearInstance() {
     75  void testClearInstance() {
    7976    StreetsideLayer.getInstance();
    8077    assertTrue(StreetsideLayer.hasInstance());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideSequenceTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
    6 import static org.junit.Assert.assertTrue;
    7 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    87
    98import java.util.Arrays;
    109
    11 import org.junit.Before;
    12 import org.junit.Test;
    13 
     10import org.junit.jupiter.api.BeforeEach;
     11import org.junit.jupiter.api.Test;
    1412import org.openstreetmap.josm.data.coor.LatLon;
    1513
     
    2018 * @see StreetsideSequence
    2119 */
    22 public class StreetsideSequenceTest {
     20class StreetsideSequenceTest {
    2321
    2422  private final StreetsideImage img1 = new StreetsideImage("key1", new LatLon(0.1, 0.1), 90);
     
    3331   * {@link StreetsideSequence} object.
    3432   */
    35   @Before
     33  @BeforeEach
    3634  public void setUp() {
    3735    seq.add(Arrays.asList(img1, img2, img3, img4));
     
    4341   */
    4442  @Test
    45   public void nextAndPreviousTest() {
     43  void testNextAndPrevious() {
    4644    assertEquals(img2, img1.next());
    4745    assertEquals(img1, img2.previous());
     
    6058    // Test IllegalArgumentException when asking for the next image of an image
    6159    // that is not in the sequence.
    62     try {
    63       seq.next(imgWithoutSeq);
    64       fail();
    65     } catch (IllegalArgumentException e) {
    66       assertTrue(true);
    67     }
     60    assertThrows(IllegalArgumentException.class, () -> seq.next(imgWithoutSeq));
     61
    6862    // Test IllegalArgumentException when asking for the previous image of an
    6963    // image that is not in the sequence.
    70     try {
    71       seq.previous(imgWithoutSeq);
    72       fail();
    73     } catch (IllegalArgumentException e) {
    74       assertTrue(true);
    75     }
     64    assertThrows(IllegalArgumentException.class, () -> seq.previous(imgWithoutSeq));
    7665  }
    7766}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/CachesTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.cache;
    33
    4 import org.junit.Test;
    54
     5import org.junit.jupiter.api.Test;
    66import org.openstreetmap.josm.plugins.streetside.utils.TestUtil;
    77
    8 public class CachesTest {
     8class CachesTest {
    99
    1010  @Test
    11   public void testUtilityClass() {
     11  void testUtilityClass() {
    1212    TestUtil.testUtilityClass(Caches.class);
    1313  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cache/StreetsideCacheTest.java

    r34386 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.streetside.cache;
    3 //License: GPL. For details, see LICENSE file.
    43
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNotNull;
    7 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    87
    9 import org.junit.Rule;
    10 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
     9import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache.Type;
     10import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1111
    12 import org.openstreetmap.josm.plugins.streetside.cache.StreetsideCache.Type;
    13 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
    15 
    16 public class StreetsideCacheTest {
    17 
    18   @Rule
    19   public JOSMTestRules rules = new StreetsideTestRules().preferences();
     12@BasicPreferences
     13class StreetsideCacheTest {
    2014
    2115  @Test
    22   public void test() {
     16  void testCache() {
    2317    StreetsideCache cache = new StreetsideCache("00000", Type.FULL_IMAGE);
    2418    assertNotNull(cache.getUrl());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/CubemapUtilsTest.java

    r34432 r36064  
    11package org.openstreetmap.josm.plugins.streetside.cubemap;
    22
    3 import static org.junit.Assert.assertEquals;
    43
    5 import org.junit.Ignore;
    6 import org.junit.Test;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    75
    8 public class CubemapUtilsTest {
     6import org.junit.jupiter.api.Disabled;
     7import org.junit.jupiter.api.Test;
    98
    10   @SuppressWarnings("static-method")
     9class CubemapUtilsTest {
     10
    1111  @Test
    12   public final void testConvertDecimal2Quaternary() {
    13    final long decimal0 = 680730040l;
    14    final long decimal1 = 680931568l;
     12  void testConvertDecimal2Quaternary() {
     13   final long decimal0 = 680730040L;
     14   final long decimal1 = 680931568L;
    1515   String res = CubemapUtils.convertDecimal2Quaternary(decimal0);
    1616   assertEquals("220210301312320", res);
     
    1919  }
    2020
    21   @SuppressWarnings("static-method")
    2221  @Test
    23   public final void testConvertQuaternary2Decimal() {
     22  void testConvertQuaternary2Decimal() {
    2423    final String quadKey0 = "220210301312320";
    2524    final String quadKey1 = "220211203003300";
     
    3029  }
    3130
    32   @SuppressWarnings("static-method")
    33   @Ignore
     31  @Disabled
    3432  @Test
    35   public final void testGetFaceNumberForCount() {
     33  void testGetFaceNumberForCount() {
    3634    String faceNrFront = CubemapUtils.getFaceNumberForCount(0);
    3735    String faceNrRight = CubemapUtils.getFaceNumberForCount(1);
     
    4846  }
    4947
    50   @SuppressWarnings("static-method")
    51   @Ignore
     48  @Disabled
    5249  @Test
    53   public final void testGetCount4FaceNumber() {
     50  void testGetCount4FaceNumber() {
    5451    int count4Front = CubemapUtils.getCount4FaceNumber("01");
    5552    int count4Right = CubemapUtils.getCount4FaceNumber("02");
     
    6663  }
    6764
    68   @SuppressWarnings("static-method")
    6965  @Test
    70   public final void testConvertDoubleCountNrto16TileNr() {
     66  void testConvertDoubleCountNrto16TileNr() {
    7167    String x0y0 = CubemapUtils.convertDoubleCountNrto16TileNr("00");
    7268    String x0y1 = CubemapUtils.convertDoubleCountNrto16TileNr("01");
     
    9288    assertEquals(x1y0, "02");
    9389    assertEquals(x1y1, "03");
    94     assertEquals(x1y2,"12");
     90    assertEquals(x1y2, "12");
    9591    assertEquals(x1y3, "13");
    9692    assertEquals(x2y0, "20");
     
    9995    assertEquals(x2y3, "31");
    10096    assertEquals(x3y0, "22");
    101     assertEquals(x3y1,"23");
     97    assertEquals(x3y1, "23");
    10298    assertEquals(x3y2, "32");
    10399    assertEquals(x3y3, "33");
    104100  }
    105 
    106101}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/cubemap/TileDownloadingTaskTest.java

    r34428 r36064  
    11package org.openstreetmap.josm.plugins.streetside.cubemap;
    22
    3 import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.fail;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.util.ArrayList;
     
    1111import java.util.concurrent.Future;
    1212
    13 import org.junit.Ignore;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.Disabled;
     14import org.junit.jupiter.api.Test;
    1515
    16 public class TileDownloadingTaskTest {
     16@Disabled
     17class TileDownloadingTaskTest {
    1718
    18   @SuppressWarnings("static-method")
    19   @Ignore
    2019  @Test
    21   public final void testCall() {
     20  final void testCall() throws InterruptedException {
    2221    ExecutorService pool = Executors.newFixedThreadPool(1);
    2322    List<Callable<List<String>>> tasks = new ArrayList<>(1);
    2423      tasks.add(new TileDownloadingTask("2202112030033001233"));
    25       try {
    26         List<Future<List<String>>> results = pool.invokeAll(tasks);
    27         assertEquals(results.get(0),"2202112030033001233");
    28       } catch (InterruptedException e) {
    29         e.printStackTrace();
    30         fail("Test threw an exception.");
    31       }
     24    List<Future<List<String>>> results = pool.invokeAll(tasks);
     25    assertEquals(results.get(0), "2202112030033001233");
    3226  }
    3327}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/ImageDisplayTest.java

    r34432 r36064  
    22package org.openstreetmap.josm.plugins.streetside.gui;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.awt.GraphicsEnvironment;
     
    1111import javax.swing.JFrame;
    1212
    13 import org.junit.Rule;
    14 import org.junit.Test;
    15 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.junit.jupiter.api.Test;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1715
    1816/**
    1917 * Tests {@link StreetsideImageDisplay}
    2018 */
    21 public class ImageDisplayTest {
    22 
    23   @Rule
    24   public JOSMTestRules rules = new StreetsideTestRules().preferences();
     19@BasicPreferences
     20class ImageDisplayTest {
    2521
    2622  private static final BufferedImage DUMMY_IMAGE = new BufferedImage(1, 1, BufferedImage.TYPE_INT_RGB);
    2723
    2824  @Test
    29   public void testImagePersistence() {
     25  void testImagePersistence() {
    3026    StreetsideImageDisplay display = new StreetsideImageDisplay();
    3127    display.setImage(DUMMY_IMAGE, null);
     
    3935
    4036  @Test
    41   public void testMouseWheelMoved() {
     37  void testMouseWheelMoved() {
    4238    if (GraphicsEnvironment.isHeadless()) {
    4339      return;
     
    6561   */
    6662  @Test
    67   public void testMouseClicked() {
     63  void testMouseClicked() {
    6864    if (GraphicsEnvironment.isHeadless()) {
    6965      return;
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/StreetsidePreferenceSettingTest.java

    r34434 r36064  
    11package org.openstreetmap.josm.plugins.streetside.gui;
    22
    3 import static org.junit.Assert.assertEquals;
    4 import static org.junit.Assert.assertFalse;
     3import static org.junit.jupiter.api.Assertions.assertEquals;
    54import static org.openstreetmap.josm.plugins.streetside.utils.TestUtil.getPrivateFieldValue;
    65
     
    1110import javax.swing.SpinnerNumberModel;
    1211
    13 import org.junit.Ignore;
    14 import org.junit.Rule;
    15 import org.junit.Test;
     12import org.junit.jupiter.api.Assertions;
     13import org.junit.jupiter.api.Disabled;
     14import org.junit.jupiter.api.Test;
    1615import org.openstreetmap.josm.data.preferences.BooleanProperty;
    1716import org.openstreetmap.josm.data.preferences.StringProperty;
    1817import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    1918import org.openstreetmap.josm.plugins.streetside.io.download.StreetsideDownloader.DOWNLOAD_MODE;
    20 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.Main;
    2220
    23 public class StreetsidePreferenceSettingTest {
    24 
    25   @Rule
    26   public JOSMTestRules rules = new StreetsideTestRules().main();
    27 
     21@Main
     22@Disabled
     23class StreetsidePreferenceSettingTest {
    2824  // TODO: repair broken unit test from Mapillary
    29   @Ignore
    3025  @Test
    31   public void testAddGui() {
     26  void testAddGui() {
    3227    if (GraphicsEnvironment.isHeadless()) {
    3328      return;
     
    4237  }
    4338
    44   @Ignore
    4539  @Test
    46   public void testIsExpert() {
    47     assertFalse(new StreetsidePreferenceSetting().isExpert());
     40  void testIsExpert() {
     41    Assertions.assertFalse(new StreetsidePreferenceSetting().isExpert());
    4842  }
    4943
    5044  @SuppressWarnings("unchecked")
    51   @Ignore
    5245  @Test
    53   public void testOk() {
     46  void testOk() {
    5447    StreetsidePreferenceSetting settings = new StreetsidePreferenceSetting();
    5548
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/gui/boilerplate/SelectableLabelTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.gui.boilerplate;
    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
    7 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    88
    9 public class SelectableLabelTest {
     9
     10class SelectableLabelTest {
    1011  @Test
    11   public void test() {
     12  void testSelectableLabel() {
    1213    SelectableLabel l1 = new SelectableLabel();
    1314    assertFalse(l1.isEditable());
     
    1516    assertTrue(l2.getText().contains("some text"));
    1617    assertFalse(l2.isEditable());
    17 
    1818  }
    1919}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/history/StreetsideRecordTest.java

    r34433 r36064  
    22package org.openstreetmap.josm.plugins.streetside.history;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.fail;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67
    78import java.util.Arrays;
     
    910import java.util.concurrent.ConcurrentSkipListSet;
    1011
    11 import org.junit.Before;
    12 import org.junit.Ignore;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Disabled;
     14import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.data.coor.LatLon;
    1616import org.openstreetmap.josm.plugins.streetside.StreetsideAbstractImage;
     
    2222import org.openstreetmap.josm.plugins.streetside.history.commands.CommandUnjoin;
    2323import org.openstreetmap.josm.plugins.streetside.history.commands.StreetsideCommand;
    24 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    25 import org.openstreetmap.josm.testutils.JOSMTestRules;
     24import org.openstreetmap.josm.testutils.annotations.Main;
     25import org.openstreetmap.josm.testutils.annotations.Projection;
    2626
    2727/**
     
    3030 * @author nokutu
    3131 */
    32 public class StreetsideRecordTest {
    33 
    34   @Rule
    35   public JOSMTestRules rules = new StreetsideTestRules().main().projection();
     32@Main
     33@Projection
     34@Disabled
     35class StreetsideRecordTest {
    3636
    3737  private StreetsideRecord record;
     
    4444   * objects.
    4545   */
    46   @Before
     46  @BeforeEach
    4747  public void setUp() {
    4848    record = new StreetsideRecord();
     
    5858   * Test commands in general.
    5959   */
    60   @Ignore
    61   @Test
    62   public void commandTest() {
     60  @Test
     61  void testCommand() {
    6362    StreetsideCommand cmd12 = new CommandMove(
    6463            new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)),
     
    115114   * Tests {@link CommandMove} class.
    116115   */
    117   @Ignore
    118   @Test
    119   public void commandMoveTest() {
     116  @Test
     117  void testCommandMove() {
    120118    CommandMove cmd1 = new CommandMove(
    121119            new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)),
     
    150148   * Tests {@link CommandTurn} class.
    151149   */
    152   @Ignore
    153   @Test
    154   public void commandTurnTest() {
     150  @Test
     151  void testCommandTurn() {
    155152    CommandTurn cmd1 = new CommandTurn(
    156153            new ConcurrentSkipListSet<>(Arrays.asList(img1, img2)),
     
    182179   * Tests {@link CommandJoin} class.
    183180   */
    184   @Ignore
    185   @Test
    186   public void commandJoinClass() {
     181  @Test
     182  void testCommandJoinClass() {
    187183    CommandJoin cmd1 = new CommandJoin(img1, img2);
    188184    CommandJoin cmd2 = new CommandJoin(img2, img3);
     
    199195  }
    200196
    201   @Ignore
    202   @Test(expected=NullPointerException.class)
    203   public void commandJoinNull1() {
    204     new CommandJoin(img1, null);
    205   }
    206 
    207   @Ignore
    208   @Test(expected=NullPointerException.class)
    209   public void commandJoinNull2() {
    210     new CommandJoin(null, img1);
     197  @Test
     198  void testCommandJoinNull1() {
     199    assertThrows(NullPointerException.class, () -> new CommandJoin(img1, null));
     200  }
     201
     202  @Test
     203  void commandJoinNull2() {
     204    assertThrows(NullPointerException.class, () -> new CommandJoin(null, img1));
    211205  }
    212206
     
    214208   * Tests {@link CommandUnjoin} class.
    215209   */
    216   @Ignore
    217   @Test
    218   public void commandUnjoinClass() {
     210  @Test
     211  void testCommandUnjoinClass() {
    219212    CommandJoin join1 = new CommandJoin(img1, img2);
    220213    CommandJoin join2 = new CommandJoin(img2, img3);
     
    237230    assertEquals(1, img2.getSequence().getImages().size());
    238231
    239     try {
    240       record.addCommand(new CommandUnjoin(Arrays.asList(new StreetsideAbstractImage[]{img1, img2, img3})));
    241       fail();
    242     } catch (IllegalArgumentException e) {
    243       // Expected output.
    244     }
     232    CommandUnjoin command = new CommandUnjoin(Arrays.asList(new StreetsideAbstractImage[]{img1, img2, img3}));
     233    assertThrows(IllegalArgumentException.class, () -> record.addCommand(command));
    245234  }
    246235}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/io/download/SequenceDownloadRunnableTest.java

    r34577 r36064  
    22package org.openstreetmap.josm.plugins.streetside.io.download;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    56
    67import java.lang.reflect.Field;
     
    910import java.util.function.Function;
    1011
    11 import org.junit.AfterClass;
    12 import org.junit.Ignore;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     12import org.junit.jupiter.api.Disabled;
     13import org.junit.jupiter.api.Test;
    1514import org.openstreetmap.josm.data.Bounds;
    16 import org.openstreetmap.josm.gui.MainApplication;
    1715import org.openstreetmap.josm.plugins.streetside.StreetsideLayer;
    1816import org.openstreetmap.josm.plugins.streetside.utils.StreetsideProperties;
    19 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    20 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.LayerManager;
    2118
    22 public class SequenceDownloadRunnableTest {
    23 
    24   @Rule
    25   public JOSMTestRules rules = new StreetsideTestRules();
     19@Disabled
     20@LayerManager
     21class SequenceDownloadRunnableTest {
    2622
    2723  private static final Function<Bounds, URL> SEARCH_SEQUENCES_URL_GEN = b -> {
     
    3026  private Field urlGenField;
    3127
    32   @AfterClass
    33   public static void tearDown() {
    34     MainApplication.getLayerManager().resetState();
    35   }
    3628
    37   @Ignore
    3829  @Test
    39   public void testRun1() throws IllegalArgumentException, IllegalAccessException {
     30  void testRun1() throws IllegalArgumentException, IllegalAccessException {
    4031    testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976));
    4132  }
    4233
    43   @Ignore
    4434  @Test
    45   public void testRun2() throws IllegalArgumentException, IllegalAccessException {
     35  void testRun2() throws IllegalArgumentException, IllegalAccessException {
    4636    testNumberOfDecodedImages(0, SEARCH_SEQUENCES_URL_GEN, new Bounds(0, 0, 0, 0));
    4737  }
    4838
    49   @Ignore
    5039  @Test
    51   public void testRun3() throws IllegalArgumentException, IllegalAccessException {
     40  void testRun3() throws IllegalArgumentException, IllegalAccessException {
    5241    testNumberOfDecodedImages(0, b -> {
    5342      try { return new URL("https://streetside/nonexistentURL"); } catch (MalformedURLException e) { return null; }
     
    5544  }
    5645
    57   @Ignore
    5846  @Test
    59   public void testRun4() throws IllegalArgumentException, IllegalAccessException {
     47  void testRun4() throws IllegalArgumentException, IllegalAccessException {
    6048    StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true);
    6149    testNumberOfDecodedImages(4, SEARCH_SEQUENCES_URL_GEN, new Bounds(7.246497, 16.432955, 7.249027, 16.432976));
    6250  }
    6351
    64   @Ignore
    6552  @Test
    66   public void testRun5() throws IllegalArgumentException, IllegalAccessException {
     53  void testRun5() throws IllegalArgumentException, IllegalAccessException {
    6754    StreetsideProperties.CUT_OFF_SEQUENCES_AT_BOUNDS.put(true);
    6855    testNumberOfDecodedImages(0, SEARCH_SEQUENCES_URL_GEN, new Bounds(0, 0, 0, 0));
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/ImageUtilTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    56
    67import java.awt.image.BufferedImage;
     
    89import javax.swing.ImageIcon;
    910
    10 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
    1112
    12 public class ImageUtilTest {
     13
     14class ImageUtilTest {
    1315
    1416  @Test
    15   public void testUtilityClass() {
     17  void testUtilityClass() {
    1618    TestUtil.testUtilityClass(ImageUtil.class);
    1719  }
    1820
    1921  @Test
    20   public void testScaleImageIcon() {
     22  void testScaleImageIcon() {
    2123    ImageIcon largeLandscape = new ImageIcon(new BufferedImage(72, 60, BufferedImage.TYPE_4BYTE_ABGR));
    2224    ImageIcon largePortrait = new ImageIcon(new BufferedImage(56, 88, BufferedImage.TYPE_4BYTE_ABGR));
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/PluginStateTest.java

    r34583 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    58
    69import javax.swing.JOptionPane;
    710
    8 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
    912import org.openstreetmap.josm.TestUtils;
    1013import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
     
    1619 * @see PluginState
    1720 */
    18 public class PluginStateTest {
     21class PluginStateTest {
    1922
    2023  /**
     
    2225   */
    2326  @Test
    24   public void downloadTest() {
    25     assertEquals(false, PluginState.isDownloading());
     27  void testDownload() {
     28    assertFalse(PluginState.isDownloading());
    2629    PluginState.startDownload();
    27     assertEquals(true, PluginState.isDownloading());
     30    assertTrue(PluginState.isDownloading());
    2831    PluginState.startDownload();
    29     assertEquals(true, PluginState.isDownloading());
     32    assertTrue(PluginState.isDownloading());
    3033    PluginState.finishDownload();
    31     assertEquals(true, PluginState.isDownloading());
     34    assertTrue(PluginState.isDownloading());
    3235    PluginState.finishDownload();
    33     assertEquals(false, PluginState.isDownloading());
     36    assertFalse(PluginState.isDownloading());
    3437  }
    3538
     
    3841   */
    3942  @Test
    40   public void uploadTest() {
     43  void testUpload() {
    4144    TestUtils.assumeWorkingJMockit();
    4245    JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker();
     
    4548            JOptionPane.OK_OPTION
    4649        );
    47     assertEquals(false, PluginState.isUploading());
     50    assertFalse(PluginState.isUploading());
    4851    PluginState.addImagesToUpload(2);
    4952    assertEquals(2, PluginState.getImagesToUpload());
    5053    assertEquals(0, PluginState.getImagesUploaded());
    51     assertEquals(true, PluginState.isUploading());
     54    assertTrue(PluginState.isUploading());
    5255    PluginState.imageUploaded();
    5356    assertEquals(1, PluginState.getImagesUploaded());
    54     assertEquals(true, PluginState.isUploading());
     57    assertTrue(PluginState.isUploading());
    5558    PluginState.imageUploaded();
    56     assertEquals(false, PluginState.isUploading());
     59    assertFalse(PluginState.isUploading());
    5760    assertEquals(2, PluginState.getImagesToUpload());
    5861    assertEquals(2, PluginState.getImagesUploaded());
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideColorSchemeTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     5
    46import javax.swing.JComponent;
    57
    6 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    79
    8 public class StreetsideColorSchemeTest {
     10class StreetsideColorSchemeTest {
    911
    1012  @Test
    11   public void testUtilityClass() {
     13  void testUtilityClass() {
    1214    TestUtil.testUtilityClass(StreetsideColorScheme.class);
    1315  }
    1416
    1517  @Test
    16   public void testStyleAsDefaultPanel() {
    17     StreetsideColorScheme.styleAsDefaultPanel();
    18     StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null);
     18  void testStyleAsDefaultPanel() {
     19    assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel());
     20    assertDoesNotThrow(() -> StreetsideColorScheme.styleAsDefaultPanel((JComponent[]) null));
    1921  }
    2022}
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsidePropertiesTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import org.junit.Rule;
    5 import org.junit.Test;
    6 
    7 import org.openstreetmap.josm.plugins.streetside.utils.TestUtil.StreetsideTestRules;
    8 import org.openstreetmap.josm.testutils.JOSMTestRules;
     4import org.junit.jupiter.api.Test;
    95
    106public class StreetsidePropertiesTest {
    11 
    12   @Rule
    13   public JOSMTestRules rules = new StreetsideTestRules();
    14 
    157  @Test
    16   public void test() {
     8  public void testUtilityClass() {
    179    TestUtil.testUtilityClass(StreetsideProperties.class);
    1810  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideURLTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNull;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    77
    88import java.lang.reflect.InvocationTargetException;
     
    1111import java.net.URL;
    1212
    13 import org.junit.Ignore;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.Assertions;
     14import org.junit.jupiter.api.Disabled;
     15import org.junit.jupiter.api.Test;
    1516
    16 public class StreetsideURLTest {
     17class StreetsideURLTest {
    1718  // TODO: replace with Streetside URL @rrh
    1819  private static final String CLIENT_ID_QUERY_PART = "client_id=T1Fzd20xZjdtR0s1VDk5OFNIOXpYdzoxNDYyOGRkYzUyYTFiMzgz";
     
    4445
    4546        @Test
    46     public void testParseNextFromHeaderValue() throws MalformedURLException {
     47    void testParseNextFromHeaderValue() throws MalformedURLException {
    4748      String headerVal =
    4849        "<https://a.streetside.com/v3/sequences?page=1&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"first\", " +
    4950        "<https://a.streetside.com/v3/sequences?page=2&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"prev\", " +
    5051        "<https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2>; rel=\"next\"";
    51       assertEquals(
    52         new URL("https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2"),
    53         StreetsideURL.APIv3.parseNextFromLinkHeaderValue(headerVal)
    54       );
     52      assertEquals(new URL("https://a.streetside.com/v3/sequences?page=4&per_page=200&client_id=TG1sUUxGQlBiYWx2V05NM0pQNUVMQTo2NTU3NTBiNTk1NzM1Y2U2"), StreetsideURL.APIv3.parseNextFromLinkHeaderValue(headerVal));
    5553    }
    5654
    5755    @Test
    58     public void testParseNextFromHeaderValue2() throws MalformedURLException {
     56    void testParseNextFromHeaderValue2() throws MalformedURLException {
    5957      String headerVal =
    6058        "<https://urlFirst>; rel=\"first\", " +
     
    6664
    6765    @Test
    68     public void testParseNextFromHeaderValueNull() {
    69       assertEquals(null, StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null));
     66    void testParseNextFromHeaderValueNull() {
     67      assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue(null));
    7068    }
    7169
    7270    @Test
    73     public void testParseNextFromHeaderValueMalformed() {
    74       assertEquals(null, StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub"));
     71    void testParseNextFromHeaderValueMalformed() {
     72      assertNull(StreetsideURL.APIv3.parseNextFromLinkHeaderValue("<###>; rel=\"next\", blub"));
    7573    }
    7674
     
    8583  }*/
    8684
    87   @Ignore
     85  @Disabled
    8886  @Test
    89   public void testBrowseImageURL() throws MalformedURLException {
    90     assertEquals(
    91         new URL("https://www.streetside.com/map/im/1234567890123456789012"),
    92         StreetsideURL.MainWebsite.browseImage("1234567890123456789012")
    93     );
     87  void testBrowseImageURL() throws MalformedURLException {
     88    assertEquals(new URL("https://www.streetside.com/map/im/1234567890123456789012"), StreetsideURL.MainWebsite.browseImage("1234567890123456789012"));
    9489  }
    9590
    96   @Test(expected = IllegalArgumentException.class)
    97   public void testIllegalBrowseImageURL() {
    98     StreetsideURL.MainWebsite.browseImage(null);
     91  @Test
     92  void testIllegalBrowseImageURL() {
     93    assertThrows(IllegalArgumentException.class, () -> StreetsideURL.MainWebsite.browseImage(null));
    9994  }
    10095
    101   @Ignore
     96  @Disabled
    10297  @Test
    103   public void testConnectURL() {
     98  void testConnectURL() {
    10499    /*assertUrlEquals(
    105100        StreetsideURL.MainWebsite.connect("http://redirect-host/ä"),
     
    128123  }
    129124
    130   @Ignore
     125  @Disabled
    131126  @Test
    132   public void testUploadSecretsURL() throws MalformedURLException {
     127  void testUploadSecretsURL() throws MalformedURLException {
    133128    /*assertEquals(
    134129        new URL("https://a.streetside.com/v2/me/uploads/secrets?"+CLIENT_ID_QUERY_PART),
     
    137132  }
    138133
    139   @Ignore
     134  @Disabled
    140135  @Test
    141   public void testUserURL() throws MalformedURLException {
     136  void testUserURL() throws MalformedURLException {
    142137    /*assertEquals(
    143138        new URL("https://a.streetside.com/v3/me?"+CLIENT_ID_QUERY_PART),
     
    147142
    148143  @Test
    149   public void testString2MalformedURL()
     144  void testString2MalformedURL()
    150145      throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    151146    Method method = StreetsideURL.class.getDeclaredMethod("string2URL", String[].class);
    152147    method.setAccessible(true);
    153     assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL")
    154     assertNull(method.invoke(null, new Object[]{null})); // invokes string2URL(null)
     148    Assertions.assertNull(method.invoke(null, new Object[]{new String[]{"malformed URL"}})); // this simply invokes string2URL("malformed URL")
     149    Assertions.assertNull(method.invoke(null, new Object[]{null})); // invokes string2URL(null)
    155150  }
    156151
    157152  @Test
    158   public void testUtilityClass() {
     153  void testUtilityClass() {
    159154    TestUtil.testUtilityClass(StreetsideURL.class);
    160155    TestUtil.testUtilityClass(StreetsideURL.APIv3.class);
     
    173168        parameterIsPresent |= actualParams[acIndex].equals(expectedParams[exIndex]);
    174169      }
    175       assertTrue(
    176           expectedParams[exIndex] + " was expected in the query string of " + actualUrl.toString() + " but wasn't there.",
    177           parameterIsPresent
    178       );
     170      Assertions.assertTrue(parameterIsPresent, expectedParams[exIndex] + " was expected in the query string of " + actualUrl.toString() + " but wasn't there.");
    179171    }
    180172  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/StreetsideUtilsTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import org.apache.commons.imaging.common.RationalNumber;
    77import org.apache.commons.imaging.formats.tiff.constants.GpsTagConstants;
    8 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    99
    1010/**
     
    1515 *
    1616 */
    17 public class StreetsideUtilsTest {
     17class StreetsideUtilsTest {
    1818
    1919  @Test
    20   public void testUtilityClass() {
     20  void testUtilityClass() {
    2121    TestUtil.testUtilityClass(StreetsideUtils.class);
    2222  }
     
    2727   */
    2828  @Test
    29   public void degMinSecToDoubleTest() {
     29  void testDegMinSecToDouble() {
    3030    RationalNumber[] num = new RationalNumber[3];
    3131    num[0] = new RationalNumber(1, 1);
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/TestUtil.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
    6 import static org.junit.Assert.fail;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6import static org.junit.jupiter.api.Assertions.fail;
    77
    88import java.awt.GraphicsEnvironment;
     
    1515
    1616import org.junit.runners.model.InitializationError;
    17 
     17import org.openstreetmap.josm.plugins.streetside.StreetsidePlugin;
     18import org.openstreetmap.josm.spi.preferences.Config;
     19import org.openstreetmap.josm.spi.preferences.MemoryPreferences;
    1820import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.tools.ImageProvider;
    1922import org.openstreetmap.josm.tools.Logging;
    2023import org.openstreetmap.josm.tools.Utils;
     
    2730  private TestUtil() {
    2831    // Prevent instantiation
     32  }
     33
     34  /**
     35   * Check if we can load images
     36   * @return {@code true} if the {@link StreetsidePlugin#LOGO} could be loaded
     37   */
     38  public static boolean cannotLoadImages() {
     39    // The class-level @DisabledIf seems to be run prior to any possible setup code
     40    if (Config.getPref() == null) {
     41      Config.setPreferencesInstance(new MemoryPreferences());
     42    }
     43    return new ImageProvider("streetside-logo").setOptional(true).getResource() == null;
    2944  }
    3045
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonDecoderTest.java

    r34386 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils.api;
    33
    4 import static org.junit.Assert.assertNull;
     4
     5import static org.junit.jupiter.api.Assertions.assertNull;
    56
    67import java.io.ByteArrayInputStream;
     
    1112import javax.json.JsonObject;
    1213
    13 import org.junit.Test;
    14 
     14import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.plugins.streetside.utils.TestUtil;
    1616
    17 public class JsonDecoderTest {
     17class JsonDecoderTest {
    1818
    1919  @Test
    20   public void testUtilityClass() {
     20  void testUtilityClass() {
    2121    TestUtil.testUtilityClass(JsonDecoder.class);
    2222  }
    2323
    2424  @Test
    25   public void testDecodeDoublePair() {
     25  void testDecodeDoublePair() {
    2626    assertNull(JsonDecoder.decodeDoublePair(null));
    2727  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/api/JsonSequencesDecoderTest.java

    r34432 r36064  
    22package org.openstreetmap.josm.plugins.streetside.utils.api;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
    76import static org.openstreetmap.josm.plugins.streetside.utils.api.JsonDecoderTest.assertDecodesToNull;
    87
     
    1918import javax.json.JsonValue;
    2019
    21 import org.junit.Ignore;
    22 import org.junit.Test;
     20import org.junit.jupiter.api.Assertions;
     21import org.junit.jupiter.api.Disabled;
     22import org.junit.jupiter.api.Test;
    2323import org.openstreetmap.josm.data.coor.LatLon;
    2424import org.openstreetmap.josm.plugins.streetside.StreetsideImage;
     
    2727import org.openstreetmap.josm.plugins.streetside.utils.TestUtil;
    2828
    29 public class JsonSequencesDecoderTest {
    30 
    31   @Ignore
    32   @Test
    33   public void testDecodeSequences() {
     29class JsonSequencesDecoderTest {
     30
     31  @Disabled
     32  @Test
     33  void testDecodeSequences() {
    3434    Collection<StreetsideSequence> exampleSequences = JsonDecoder.decodeFeatureCollection(
    3535      Json.createReader(this.getClass().getResourceAsStream("test/data/api/v3/responses/searchSequences.json")).readObject(),
     
    5151    assertEquals(329.94820000000004, seq.getImages().get(3).getHe(), 1e-10);
    5252
    53     assertEquals(new LatLon(7.246497, 16.432958),  seq.getImages().get(0).getLatLon());
    54     assertEquals(new LatLon(7.246567, 16.432955),  seq.getImages().get(1).getLatLon());
    55     assertEquals(new LatLon(7.248372, 16.432971),  seq.getImages().get(2).getLatLon());
    56     assertEquals(new LatLon(7.249027, 16.432976),  seq.getImages().get(3).getLatLon());
     53    assertEquals(new LatLon(7.246497, 16.432958), seq.getImages().get(0).getLatLon());
     54    assertEquals(new LatLon(7.246567, 16.432955), seq.getImages().get(1).getLatLon());
     55    assertEquals(new LatLon(7.248372, 16.432971), seq.getImages().get(2).getLatLon());
     56    assertEquals(new LatLon(7.249027, 16.432976), seq.getImages().get(3).getLatLon());
    5757
    5858    assertEquals(1_457_963_093_860L, seq.getCd()); // 2016-03-14T13:44:53.860 UTC
     
    6060
    6161  @Test
    62   public void testDecodeSequencesInvalid() {
     62  void testDecodeSequencesInvalid() {
    6363    // null input
    6464    assertEquals(0, JsonDecoder.decodeFeatureCollection(null, JsonSequencesDecoder::decodeSequence).size());
     
    7676
    7777  @Test
    78   public void testDecodeSequencesWithArbitraryObjectAsFeature() {
     78  void testDecodeSequencesWithArbitraryObjectAsFeature() {
    7979    assertNumberOfDecodedSequences(0, "{\"type\": \"FeatureCollection\", \"features\": [{}]}");
    8080  }
    8181
    8282  private static void assertNumberOfDecodedSequences(int expectedNumberOfSequences, String jsonString) {
    83     assertEquals(
    84       expectedNumberOfSequences,
    85       JsonDecoder.decodeFeatureCollection(
    86         Json.createReader(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))).readObject(),
    87         JsonSequencesDecoder::decodeSequence
    88       ).size()
    89     );
    90   }
    91 
    92   @Ignore
    93   @Test
    94   public void testDecodeSequence() {
     83    assertEquals(expectedNumberOfSequences, JsonDecoder.decodeFeatureCollection(
     84      Json.createReader(new ByteArrayInputStream(jsonString.getBytes(StandardCharsets.UTF_8))).readObject(),
     85      JsonSequencesDecoder::decodeSequence
     86    ).size());
     87  }
     88
     89  @Disabled
     90  @Test
     91  void testDecodeSequence() {
    9592    StreetsideSequence exampleSequence = JsonSequencesDecoder.decodeSequence(
    9693      Json.createReader(this.getClass().getResourceAsStream("/api/v3/responses/sequence.json")).readObject()
     
    10097    assertEquals(2, exampleSequence.getImages().size());
    10198
    102     assertEquals(
    103       new StreetsideImage("76P0YUrlDD_lF6J7Od3yoA", new LatLon(16.43279, 7.246085), 96.71454),
    104       exampleSequence.getImages().get(0)
    105     );
    106     assertEquals(
    107       new StreetsideImage("Ap_8E0BwoAqqewhJaEbFyQ", new LatLon(16.432799, 7.246082), 96.47705000000002),
    108       exampleSequence.getImages().get(1)
    109     );
    110   }
    111 
    112   @Test
    113   public void testDecodeSequenceInvalid() {
     99    assertEquals(new StreetsideImage("76P0YUrlDD_lF6J7Od3yoA", new LatLon(16.43279, 7.246085), 96.71454), exampleSequence.getImages().get(0));
     100    assertEquals(new StreetsideImage("Ap_8E0BwoAqqewhJaEbFyQ", new LatLon(16.432799, 7.246082), 96.47705000000002), exampleSequence.getImages().get(1));
     101  }
     102
     103  @Test
     104  void testDecodeSequenceInvalid() {
    114105    // null input
    115     assertNull(JsonSequencesDecoder.decodeSequence(null));
     106    Assertions.assertNull(JsonSequencesDecoder.decodeSequence(null));
    116107    // `properties` key is not set
    117108    assertDecodesToNull(JsonSequencesDecoder::decodeSequence, "{\"type\": \"Feature\"}");
     
    150141   */
    151142  @Test
    152   public void testDecodeJsonArray()
     143  void testDecodeJsonArray()
    153144      throws NoSuchMethodException, SecurityException, IllegalAccessException,
    154145      IllegalArgumentException, InvocationTargetException {
    155146    Method method = JsonSequencesDecoder.class.getDeclaredMethod("decodeJsonArray", JsonArray.class, Function.class, Class.class);
    156147    method.setAccessible(true);
    157     assertEquals(
    158       0,
    159       ((String[]) method.invoke(null, null, (Function<JsonValue, String>) val -> null, String.class)).length
    160     );
    161   }
    162 
    163   @Test
    164   public void testDecodeCoordinateProperty() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
     148    assertEquals(0, ((String[]) method.invoke(null, null, (Function<JsonValue, String>) val -> null, String.class)).length);
     149  }
     150
     151  @Test
     152  void testDecodeCoordinateProperty() throws NoSuchMethodException, SecurityException, IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    165153    Method decodeCoordinateProperty = JsonSequencesDecoder.class.getDeclaredMethod(
    166154      "decodeCoordinateProperty",
     
    172160    decodeCoordinateProperty.setAccessible(true);
    173161
    174     assertEquals(
    175       0,
    176       ((String[]) decodeCoordinateProperty.invoke(
    177         null, null, "key", (Function<JsonValue, String>) val -> "string", String.class
    178       )).length
    179     );
    180 
    181     assertEquals(
    182       0,
    183       ((String[]) decodeCoordinateProperty.invoke(
    184         null, JsonUtil.string2jsonObject("{\"coordinateProperties\":{\"key\":0}}"), "key", (Function<JsonValue, String>) val -> "string", String.class
    185       )).length
    186     );
    187   }
    188 
    189   @Test
    190   public void testDecodeLatLons()
     162    assertEquals(0, ((String[]) decodeCoordinateProperty.invoke(
     163      null, null, "key", (Function<JsonValue, String>) val -> "string", String.class
     164    )).length);
     165
     166    assertEquals(0, ((String[]) decodeCoordinateProperty.invoke(
     167      null, JsonUtil.string2jsonObject("{\"coordinateProperties\":{\"key\":0}}"), "key", (Function<JsonValue, String>) val -> "string", String.class
     168    )).length);
     169  }
     170
     171  @Test
     172  void testDecodeLatLons()
    191173      throws NoSuchMethodException, SecurityException, IllegalAccessException,
    192174      IllegalArgumentException, InvocationTargetException {
     
    206188    )).readObject());
    207189    assertEquals(3, example.length);
    208     assertNull(example[0]);
    209     assertNull(example[1]);
    210     assertNull(example[2]);
    211   }
    212 
    213   @Test
    214   public void testUtilityClass() {
     190    Assertions.assertNull(example[0]);
     191    Assertions.assertNull(example[1]);
     192    Assertions.assertNull(example[2]);
     193  }
     194
     195  @Test
     196  void testUtilityClass() {
    215197    TestUtil.testUtilityClass(JsonSequencesDecoder.class);
    216198  }
  • applications/editors/josm/plugins/alignways/test/unit/org/openstreetmap/josm/plugins/alignways/geometry/AlignWaysGeomLineTest.java

    r34489 r36064  
    22package org.openstreetmap.josm.plugins.alignways.geometry;
    33
    4 import static org.junit.Assert.assertTrue;
    54
    6 import org.junit.Before;
    7 import org.junit.Test;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertSame;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8
     9import org.junit.jupiter.api.BeforeEach;
     10import org.junit.jupiter.api.Test;
    811import org.openstreetmap.josm.plugins.alignways.geometry.AlignWaysGeomLine.IntersectionStatus;
    912
     
    1114 * Tests of {@link AlignWaysGeomLine}
    1215 */
    13 public class AlignWaysGeomLineTest {
     16class AlignWaysGeomLineTest {
    1417    private AlignWaysGeomLine line_x1y1x2y2, line_par_x1y1x2y2;
    1518    private AlignWaysGeomLine line_abc;
     
    1821    private AlignWaysGeomLine line_horiz, line_vert;
    1922
    20     @Before
    21     public void setUp() {
     23    @BeforeEach
     24    void setUp() {
    2225        line_x1y1x2y2 = new AlignWaysGeomLine(-2.0, -1.0, 4.0, 3.0);
    2326        line_abc = new AlignWaysGeomLine(2.0/3, -1.0, 1.0/3);
     
    3033
    3134    @Test
    32     public void LineLineEquiv() {
    33         assertTrue(line_x1y1x2y2.equals(line_line));
     35    void testLineLineEquiv() {
     36        assertEquals(line_x1y1x2y2, line_line);
    3437    }
    3538
    3639    @Test
    37     public void LineAbcLineEquiv() {
    38         assertTrue(line_x1y1x2y2.equals(line_abc));
     40    void testLineAbcLineEquiv() {
     41        assertEquals(line_x1y1x2y2, line_abc);
    3942    }
    4043
    4144    @Test
    42     public void LineMbLineEquiv() {
    43         assertTrue(line_x1y1x2y2.equals(line_mb));
     45    void testLineMbLineEquiv() {
     46        assertEquals(line_x1y1x2y2, line_mb);
    4447    }
    4548
    4649    @Test
    47     public void LineAbcMbEquiv() {
    48         assertTrue(line_abc.equals(line_mb));
     50    void testLineAbcMbEquiv() {
     51        assertEquals(line_abc, line_mb);
    4952    }
    5053
    5154    @Test
    52     public void LineLineParallel() {
     55    void testLineLineParallel() {
    5356        line_x1y1x2y2.getIntersection(line_par_x1y1x2y2);
    54         assertTrue(line_x1y1x2y2.getIntersectionStatus() == IntersectionStatus.LINES_PARALLEL);
     57        assertSame(line_x1y1x2y2.getIntersectionStatus(), IntersectionStatus.LINES_PARALLEL);
    5558    }
    5659
    5760    @Test
    58     public void LineAbcOverlap() {
     61    void testLineAbcOverlap() {
    5962        line_x1y1x2y2.getIntersection(line_abc);
    60         assertTrue(line_x1y1x2y2.getIntersectionStatus() == IntersectionStatus.LINES_OVERLAP);
     63        assertSame(line_x1y1x2y2.getIntersectionStatus(), IntersectionStatus.LINES_OVERLAP);
    6164    }
    6265
    6366    @Test
    64     public void LineMbOverlap() {
     67    void testLineMbOverlap() {
    6568        line_x1y1x2y2.getIntersection(line_mb);
    66         assertTrue(line_x1y1x2y2.getIntersectionStatus() == IntersectionStatus.LINES_OVERLAP);
     69        assertSame(line_x1y1x2y2.getIntersectionStatus(), IntersectionStatus.LINES_OVERLAP);
    6770    }
    6871
    6972    @Test
    70     public void AbcMbOverlap() {
     73    void testAbcMbOverlap() {
    7174        line_abc.getIntersection(line_mb);
    72         assertTrue(line_abc.getIntersectionStatus() == IntersectionStatus.LINES_OVERLAP);
     75        assertSame(line_abc.getIntersectionStatus(), IntersectionStatus.LINES_OVERLAP);
    7376    }
    7477
    7578    @Test
    76     public void GetXOnHoriz() {
     79    void testGetXOnHoriz() {
    7780        assertTrue(line_horiz.getXonLine(2.0).isNaN());
    7881    }
    7982
    8083    @Test
    81     public void GetYOnVert() {
     84    void testGetYOnVert() {
    8285        assertTrue(line_vert.getYonLine(2.0).isNaN());
    8386    }
    8487
    8588    @Test
    86     public void StatusUndefAfterConstruct() throws Exception {
     89    void testStatusUndefAfterConstruct() {
    8790        AlignWaysGeomLine newLine = new AlignWaysGeomLine(1.0, 2.0);
    88         assertTrue(newLine.getIntersectionStatus() == IntersectionStatus.UNDEFINED);
    89 
     91        assertSame(newLine.getIntersectionStatus(), IntersectionStatus.UNDEFINED);
    9092    }
    9193
  • applications/editors/josm/plugins/cadastre-fr/test/unit/org/openstreetmap/josm/plugins/fr/cadastre/edigeo/EdigeoRecordTest.java

    r33773 r36064  
    22package org.openstreetmap.josm.plugins.fr.cadastre.edigeo;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.util.Arrays;
    77
    8 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    99import org.openstreetmap.josm.TestUtils;
    1010import org.openstreetmap.josm.plugins.fr.cadastre.edigeo.EdigeoRecord.Format;
     
    1616 * Unit test of {@link EdigeoRecord}.
    1717 */
    18 public class EdigeoRecordTest {
     18class EdigeoRecordTest {
    1919
    2020    /**
     
    2222     */
    2323    @Test
    24     public void testEdigeoRecord() {
     24    void testEdigeoRecord() {
    2525        EdigeoRecord r = new EdigeoRecord("SCPCP27:TEST01;SeSD;OBJ;PARCELLE_id");
    2626        assertEquals("SCP", r.name);
     
    3535     */
    3636    @Test
    37     public void testEqualsContract() {
     37    void testEqualsContract() {
    3838        TestUtils.assumeWorkingEqualsVerifier();
    3939        EqualsVerifier.forClass(EdigeoRecord.class).usingGetClass()
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/AsyncEventBusTest.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus;
    1818
    19 import static org.junit.Assert.assertEquals;
    20 import static org.junit.Assert.assertTrue;
     19import static org.junit.jupiter.api.Assertions.assertEquals;
     20import static org.junit.jupiter.api.Assertions.assertTrue;
    2121
    2222import java.util.ArrayList;
     
    2424import java.util.concurrent.Executor;
    2525
    26 import org.junit.Before;
    27 import org.junit.Test;
    28 import org.openstreetmap.josm.eventbus.AsyncEventBus;
     26import org.junit.jupiter.api.BeforeEach;
     27import org.junit.jupiter.api.Test;
    2928
    3029/**
     
    3332 * @author Cliff Biffle
    3433 */
    35 public class AsyncEventBusTest {
     34class AsyncEventBusTest {
    3635  private static final String EVENT = "Hello";
    3736
     
    4140  private AsyncEventBus bus;
    4241
    43   @Before
    44   public void setUp() throws Exception {
     42  @BeforeEach
     43  void setUp() {
    4544    executor = new FakeExecutor();
    4645    bus = new AsyncEventBus(executor);
     
    4847
    4948  @Test
    50   public void testBasicDistribution() {
     49  void testBasicDistribution() {
    5150    StringCatcher catcher = new StringCatcher();
    5251    bus.register(catcher);
     
    5655
    5756    List<String> events = catcher.getEvents();
    58     assertTrue("No events should be delivered synchronously.", events.isEmpty());
     57    assertTrue(events.isEmpty(), "No events should be delivered synchronously.");
    5958
    6059    // Now we find the task in our Executor and explicitly activate it.
    6160    List<Runnable> tasks = executor.getTasks();
    62     assertEquals("One event dispatch task should be queued.", 1, tasks.size());
     61    assertEquals(1, tasks.size(), "One event dispatch task should be queued.");
    6362
    6463    tasks.get(0).run();
    6564
    66     assertEquals("One event should be delivered.", 1, events.size());
    67     assertEquals("Correct string should be delivered.", EVENT, events.get(0));
     65    assertEquals(1, events.size(), "One event should be delivered.");
     66    assertEquals(EVENT, events.get(0), "Correct string should be delivered.");
    6867  }
    6968
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/DispatcherTest.java

    r34000 r36064  
    2727import java.util.concurrent.CyclicBarrier;
    2828
    29 import org.junit.Ignore;
    30 import org.junit.Test;
    31 import org.openstreetmap.josm.eventbus.Dispatcher;
    32 import org.openstreetmap.josm.eventbus.EventBus;
    33 import org.openstreetmap.josm.eventbus.Subscribe;
    34 import org.openstreetmap.josm.eventbus.Subscriber;
     29import org.junit.jupiter.api.Disabled;
     30import org.junit.jupiter.api.Test;
    3531
    3632/**
     
    4036 */
    4137
    42 public class DispatcherTest {
     38class DispatcherTest {
    4339
    4440  private final EventBus bus = new EventBus();
     
    6662
    6763  @Test
    68   @Ignore("FIXME")
    69   public void testPerThreadQueuedDispatcher() {
     64  @Disabled("FIXME")
     65  void testPerThreadQueuedDispatcher() {
    7066    dispatcher = Dispatcher.perThreadDispatchQueue();
    7167    dispatcher.dispatch(1, integerSubscribers.iterator());
     
    8783
    8884  @Test
    89   @Ignore("FIXME")
    90   public void testLegacyAsyncDispatcher() {
     85  @Disabled("FIXME")
     86  void testLegacyAsyncDispatcher() {
    9187    dispatcher = Dispatcher.legacyAsync();
    9288
     
    9591
    9692    new Thread(
    97             new Runnable() {
    98               @Override
    99               public void run() {
    100                 try {
    101                   barrier.await();
    102                 } catch (Exception e) {
    103                   throw new AssertionError(e);
    104                 }
     93            () -> {
     94              try {
     95                barrier.await();
     96              } catch (Exception e) {
     97                throw new AssertionError(e);
     98              }
    10599
    106                 dispatcher.dispatch(2, integerSubscribers.iterator());
    107                 latch.countDown();
    108               }
     100              dispatcher.dispatch(2, integerSubscribers.iterator());
     101              latch.countDown();
    109102            })
    110103        .start();
    111104
    112105    new Thread(
    113             new Runnable() {
    114               @Override
    115               public void run() {
    116                 try {
    117                   barrier.await();
    118                 } catch (Exception e) {
    119                   throw new AssertionError(e);
    120                 }
     106            () -> {
     107              try {
     108                barrier.await();
     109              } catch (Exception e) {
     110                throw new AssertionError(e);
     111              }
    121112
    122                 dispatcher.dispatch("foo", stringSubscribers.iterator());
    123                 latch.countDown();
    124               }
     113              dispatcher.dispatch("foo", stringSubscribers.iterator());
     114              latch.countDown();
    125115            })
    126116        .start();
     
    135125
    136126  @Test
    137   @Ignore("FIXME")
    138   public void testImmediateDispatcher() {
     127  @Disabled("FIXME")
     128  void testImmediateDispatcher() {
    139129    dispatcher = Dispatcher.immediate();
    140130    dispatcher.dispatch(1, integerSubscribers.iterator());
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/EventBusTest.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus;
    1818
    19 import static org.junit.Assert.assertEquals;
    20 import static org.junit.Assert.fail;
     19import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     20import static org.junit.jupiter.api.Assertions.assertEquals;
     21import static org.junit.jupiter.api.Assertions.assertThrows;
    2122
    2223import java.util.ArrayList;
    23 import java.util.Arrays;
     24import java.util.Collections;
    2425import java.util.List;
    2526import java.util.concurrent.CopyOnWriteArrayList;
     
    2930import java.util.concurrent.atomic.AtomicInteger;
    3031
    31 import org.junit.Before;
    32 import org.junit.Test;
    33 import org.openstreetmap.josm.eventbus.DeadEvent;
    34 import org.openstreetmap.josm.eventbus.EventBus;
    35 import org.openstreetmap.josm.eventbus.Subscribe;
    36 import org.openstreetmap.josm.eventbus.SubscriberExceptionContext;
    37 import org.openstreetmap.josm.eventbus.SubscriberExceptionHandler;
     32import org.junit.jupiter.api.BeforeEach;
     33import org.junit.jupiter.api.Test;
    3834
    3935/**
     
    4238 * @author Cliff Biffle
    4339 */
    44 public class EventBusTest {
     40class EventBusTest {
    4541  private static final String EVENT = "Hello";
    4642  private static final String BUS_IDENTIFIER = "test-bus";
     
    4844  private EventBus bus;
    4945
    50   @Before
    51   public void setUp() throws Exception {
     46  @BeforeEach
     47  void setUp() {
    5248    bus = new EventBus(BUS_IDENTIFIER);
    5349  }
    5450
    5551  @Test
    56   public void testBasicCatcherDistribution() {
     52  void testBasicCatcherDistribution() {
    5753    StringCatcher catcher = new StringCatcher();
    5854    bus.register(catcher);
     
    6056
    6157    List<String> events = catcher.getEvents();
    62     assertEquals("Only one event should be delivered.", 1, events.size());
    63     assertEquals("Correct string should be delivered.", EVENT, events.get(0));
     58    assertEquals(1, events.size(), "Only one event should be delivered.");
     59    assertEquals(EVENT, events.get(0), "Correct string should be delivered.");
    6460  }
    6561
     
    7167   */
    7268  @Test
    73   public void testPolymorphicDistribution() {
     69  void testPolymorphicDistribution() {
    7470    // Three catchers for related types String, Object, and Comparable<?>.
    7571    // String isa Object
     
    10197    // Two additional event types: Object and Comparable<?> (played by Integer)
    10298    Object objEvent = new Object();
    103     Object compEvent = new Integer(6);
     99    Object compEvent = 6;
    104100
    105101    bus.post(EVENT);
     
    109105    // Check the StringCatcher...
    110106    List<String> stringEvents = stringCatcher.getEvents();
    111     assertEquals("Only one String should be delivered.", 1, stringEvents.size());
    112     assertEquals("Correct string should be delivered.", EVENT, stringEvents.get(0));
     107    assertEquals(1, stringEvents.size(), "Only one String should be delivered.");
     108    assertEquals(EVENT, stringEvents.get(0), "Correct string should be delivered.");
    113109
    114110    // Check the Catcher<Object>...
    115     assertEquals("Three Objects should be delivered.", 3, objectEvents.size());
    116     assertEquals("String fixture must be first object delivered.", EVENT, objectEvents.get(0));
    117     assertEquals("Object fixture must be second object delivered.", objEvent, objectEvents.get(1));
    118     assertEquals(
    119         "Comparable fixture must be thirdobject delivered.", compEvent, objectEvents.get(2));
     111    assertEquals(3, objectEvents.size(), "Three Objects should be delivered.");
     112    assertEquals(EVENT, objectEvents.get(0), "String fixture must be first object delivered.");
     113    assertEquals(objEvent, objectEvents.get(1), "Object fixture must be second object delivered.");
     114    assertEquals(compEvent, objectEvents.get(2), "Comparable fixture must be thirdobject delivered.");
    120115
    121116    // Check the Catcher<Comparable<?>>...
    122     assertEquals("Two Comparable<?>s should be delivered.", 2, compEvents.size());
    123     assertEquals("String fixture must be first comparable delivered.", EVENT, compEvents.get(0));
    124     assertEquals(
    125         "Comparable fixture must be second comparable delivered.", compEvent, compEvents.get(1));
    126   }
    127 
    128   @Test
    129   public void testSubscriberThrowsException() throws Exception {
     117    assertEquals(2, compEvents.size(), "Two Comparable<?>s should be delivered.");
     118    assertEquals(EVENT, compEvents.get(0), "String fixture must be first comparable delivered.");
     119    assertEquals(compEvent, compEvents.get(1), "Comparable fixture must be second comparable delivered.");
     120  }
     121
     122  @Test
     123  void testSubscriberThrowsException() throws Exception {
    130124    final RecordingSubscriberExceptionHandler handler = new RecordingSubscriberExceptionHandler();
    131125    final EventBus eventBus = new EventBus(handler);
     
    142136    eventBus.post(EVENT);
    143137
    144     assertEquals("Cause should be available.", exception, handler.exception);
    145     assertEquals("EventBus should be available.", eventBus, handler.context.getEventBus());
    146     assertEquals("Event should be available.", EVENT, handler.context.getEvent());
    147     assertEquals("Subscriber should be available.", subscriber, handler.context.getSubscriber());
    148     assertEquals(
    149         "Method should be available.",
    150         subscriber.getClass().getMethod("throwExceptionOn", String.class),
    151         handler.context.getSubscriberMethod());
    152   }
    153 
    154   @Test
    155   public void testSubscriberThrowsExceptionHandlerThrowsException() throws Exception {
     138    assertEquals(exception, handler.exception, "Cause should be available.");
     139    assertEquals(eventBus, handler.context.getEventBus(), "EventBus should be available.");
     140    assertEquals(EVENT, handler.context.getEvent(), "Event should be available.");
     141    assertEquals(subscriber, handler.context.getSubscriber(), "Subscriber should be available.");
     142    assertEquals(subscriber.getClass().getMethod("throwExceptionOn", String.class), handler.context.getSubscriberMethod(), "Method should be available.");
     143  }
     144
     145  @Test
     146  void testSubscriberThrowsExceptionHandlerThrowsException() throws Exception {
    156147    final EventBus eventBus =
    157148        new EventBus(
    158             new SubscriberExceptionHandler() {
    159               @Override
    160               public void handleException(Throwable exception, SubscriberExceptionContext context) {
    161                 throw new RuntimeException("testSubscriberThrowsExceptionHandlerThrowsException_1. This is a normal exception");
    162               }
    163             });
     149                (exception, context) -> {
     150                  throw new RuntimeException("testSubscriberThrowsExceptionHandlerThrowsException_1. This is a normal exception");
     151                });
    164152    final Object subscriber =
    165153        new Object() {
     
    170158        };
    171159    eventBus.register(subscriber);
    172     try {
    173       eventBus.post(EVENT);
    174     } catch (RuntimeException e) {
    175       fail("Exception should not be thrown.");
    176     }
    177   }
    178 
    179   @Test
    180   public void testDeadEventForwarding() {
     160    assertDoesNotThrow(() -> eventBus.post(EVENT));
     161  }
     162
     163  @Test
     164  void testDeadEventForwarding() {
    181165    GhostCatcher catcher = new GhostCatcher();
    182166    bus.register(catcher);
     
    186170
    187171    List<DeadEvent> events = catcher.getEvents();
    188     assertEquals("One dead event should be delivered.", 1, events.size());
    189     assertEquals("The dead event should wrap the original event.", EVENT, events.get(0).getEvent());
    190   }
    191 
    192   @Test
    193   public void testDeadEventPosting() {
     172    assertEquals(1, events.size(), "One dead event should be delivered.");
     173    assertEquals(EVENT, events.get(0).getEvent(), "The dead event should wrap the original event.");
     174  }
     175
     176  @Test
     177  void testDeadEventPosting() {
    194178    GhostCatcher catcher = new GhostCatcher();
    195179    bus.register(catcher);
     
    198182
    199183    List<DeadEvent> events = catcher.getEvents();
    200     assertEquals("The explicit DeadEvent should be delivered.", 1, events.size());
    201     assertEquals("The dead event must not be re-wrapped.", EVENT, events.get(0).getEvent());
    202   }
    203 
    204   @Test
    205   public void testMissingSubscribe() {
     184    assertEquals(1, events.size(), "The explicit DeadEvent should be delivered.");
     185    assertEquals(EVENT, events.get(0).getEvent(), "The dead event must not be re-wrapped.");
     186  }
     187
     188  @Test
     189  void testMissingSubscribe() {
    206190    bus.register(new Object());
    207191  }
    208192
    209193  @Test
    210   public void testUnregister() {
     194  void testUnregister() {
    211195    StringCatcher catcher1 = new StringCatcher();
    212196    StringCatcher catcher2 = new StringCatcher();
    213     try {
    214       bus.unregister(catcher1);
    215       fail("Attempting to unregister an unregistered object succeeded");
    216     } catch (IllegalArgumentException expected) {
    217       // OK.
    218     }
     197    assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1), "Attempting to unregister an unregistered object succeeded");
    219198
    220199    bus.register(catcher1);
     
    227206    expectedEvents.add(EVENT);
    228207
    229     assertEquals("Two correct events should be delivered.", expectedEvents, catcher1.getEvents());
    230 
    231     assertEquals(
    232         "One correct event should be delivered.", Arrays.asList(EVENT), catcher2.getEvents());
     208    assertEquals(expectedEvents, catcher1.getEvents(), "Two correct events should be delivered.");
     209
     210    assertEquals(Collections.singletonList(EVENT), catcher2.getEvents(), "One correct event should be delivered.");
    233211
    234212    bus.unregister(catcher1);
    235213    bus.post(EVENT);
    236214
    237     assertEquals(
    238         "Shouldn't catch any more events when unregistered.", expectedEvents, catcher1.getEvents());
    239     assertEquals("Two correct events should be delivered.", expectedEvents, catcher2.getEvents());
    240 
    241     try {
    242       bus.unregister(catcher1);
    243       fail("Attempting to unregister an unregistered object succeeded");
    244     } catch (IllegalArgumentException expected) {
    245       // OK.
    246     }
     215    assertEquals(expectedEvents, catcher1.getEvents(), "Shouldn't catch any more events when unregistered.");
     216    assertEquals(expectedEvents, catcher2.getEvents(), "Two correct events should be delivered.");
     217
     218    assertThrows(IllegalArgumentException.class, () -> bus.unregister(catcher1), "Attempting to unregister an unregistered object succeeded");
    247219
    248220    bus.unregister(catcher2);
    249221    bus.post(EVENT);
    250     assertEquals(
    251         "Shouldn't catch any more events when unregistered.", expectedEvents, catcher1.getEvents());
    252     assertEquals(
    253         "Shouldn't catch any more events when unregistered.", expectedEvents, catcher2.getEvents());
     222    assertEquals(expectedEvents, catcher1.getEvents(), "Shouldn't catch any more events when unregistered.");
     223    assertEquals(expectedEvents, catcher2.getEvents(), "Shouldn't catch any more events when unregistered.");
    254224  }
    255225
     
    258228
    259229  @Test
    260   public void testRegisterThreadSafety() throws Exception {
     230  void testRegisterThreadSafety() throws Exception {
    261231    List<StringCatcher> catchers = new CopyOnWriteArrayList<>();
    262232    List<Future<?>> futures = new ArrayList<>();
     
    269239      futures.get(i).get();
    270240    }
    271     assertEquals("Unexpected number of catchers in the list", numberOfCatchers, catchers.size());
    272     bus.post(EVENT);
    273     List<String> expectedEvents = Arrays.asList(EVENT);
     241    assertEquals(numberOfCatchers, catchers.size(), "Unexpected number of catchers in the list");
     242    bus.post(EVENT);
     243    List<String> expectedEvents = Collections.singletonList(EVENT);
    274244    for (StringCatcher catcher : catchers) {
    275       assertEquals(
    276           "One of the registered catchers did not receive an event.",
    277           expectedEvents,
    278           catcher.getEvents());
    279     }
    280   }
    281 
    282   @Test
    283   public void testToString() throws Exception {
     245      assertEquals(expectedEvents, catcher.getEvents(), "One of the registered catchers did not receive an event.");
     246    }
     247  }
     248
     249  @Test
     250  void testToString() {
    284251    EventBus eventBus = new EventBus("a b ; - \" < > / \\ €");
    285252    assertEquals("EventBus [a b ; - \" < > / \\ €]", eventBus.toString());
     
    293260   */
    294261  @Test
    295   public void testRegistrationWithBridgeMethod() {
     262  void testRegistrationWithBridgeMethod() {
    296263    final AtomicInteger calls = new AtomicInteger();
    297264    bus.register(
     
    347314   */
    348315  public static class GhostCatcher {
    349     private List<DeadEvent> events = new ArrayList<>();
     316    private final List<DeadEvent> events = new ArrayList<>();
    350317
    351318    @Subscribe
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/ReentrantEventsTest.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus;
    1818
    19 import static org.junit.Assert.assertEquals;
    20 import static org.junit.Assert.assertTrue;
     19import static org.junit.jupiter.api.Assertions.assertEquals;
    2120
    2221import java.util.ArrayList;
     
    2423import java.util.List;
    2524
    26 import org.junit.Test;
    27 import org.openstreetmap.josm.eventbus.EventBus;
    28 import org.openstreetmap.josm.eventbus.Subscribe;
     25import org.junit.jupiter.api.Assertions;
     26import org.junit.jupiter.api.Test;
    2927
    3028/**
     
    3331 * @author Jesse Wilson
    3432 */
    35 public class ReentrantEventsTest {
     33class ReentrantEventsTest {
    3634
    3735  static final String FIRST = "one";
     
    4139
    4240  @Test
    43   public void testNoReentrantEvents() {
     41  void testNoReentrantEvents() {
    4442    ReentrantEventsHater hater = new ReentrantEventsHater();
    4543    bus.register(hater);
     
    4745    bus.post(FIRST);
    4846
    49     assertEquals(
    50         "ReentrantEventHater expected 2 events",
    51         Arrays.asList(FIRST, SECOND),
    52         hater.eventsReceived);
     47    assertEquals(Arrays.asList(FIRST, SECOND), hater.eventsReceived, "ReentrantEventHater expected 2 events");
    5348  }
    5449
     
    7065    @Subscribe
    7166    public void listenForDoubles(Double event) {
    72       assertTrue("I received an event when I wasn't ready!", ready);
     67      Assertions.assertTrue(ready, "I received an event when I wasn't ready!");
    7368      eventsReceived.add(event);
    7469    }
     
    7671
    7772  @Test
    78   public void testEventOrderingIsPredictable() {
     73  void testEventOrderingIsPredictable() {
    7974    EventProcessor processor = new EventProcessor();
    8075    bus.register(processor);
     
    8580    bus.post(FIRST);
    8681
    87     assertEquals(
    88         "EventRecorder expected events in order",
    89         Arrays.asList(FIRST, SECOND),
    90         recorder.eventsReceived);
     82    assertEquals(Arrays.asList(FIRST, SECOND), recorder.eventsReceived, "EventRecorder expected events in order");
    9183  }
    9284
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/StringCatcher.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus;
    1818
    19 import static org.junit.Assert.fail;
     19import static org.junit.jupiter.api.Assertions.fail;
    2020
    2121import java.util.ArrayList;
    2222import java.util.List;
    23 
    24 import org.openstreetmap.josm.eventbus.Subscribe;
    2523
    2624/**
     
    3331 */
    3432public class StringCatcher {
    35   private List<String> events = new ArrayList<>();
     33  private final List<String> events = new ArrayList<>();
    3634
    3735  @Subscribe
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/SubscriberRegistryTest.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus;
    1818
    19 import static org.junit.Assert.assertEquals;
    20 import static org.junit.Assert.assertFalse;
    21 import static org.junit.Assert.assertTrue;
    22 import static org.junit.Assert.fail;
     19import static org.junit.jupiter.api.Assertions.assertEquals;
     20import static org.junit.jupiter.api.Assertions.assertFalse;
     21import static org.junit.jupiter.api.Assertions.assertThrows;
     22import static org.junit.jupiter.api.Assertions.assertTrue;
    2323
    2424import java.util.Arrays;
     
    2626import java.util.Iterator;
    2727
    28 import org.junit.Ignore;
    29 import org.junit.Test;
    30 import org.openstreetmap.josm.eventbus.EventBus;
    31 import org.openstreetmap.josm.eventbus.Subscribe;
    32 import org.openstreetmap.josm.eventbus.Subscriber;
    33 import org.openstreetmap.josm.eventbus.SubscriberRegistry;
     28import org.junit.jupiter.api.Assertions;
     29import org.junit.jupiter.api.Disabled;
     30import org.junit.jupiter.api.Test;
     31
    3432
    3533/**
     
    4341
    4442  @Test
    45   public void testRegister() {
     43  void testRegister() {
    4644    assertEquals(0, registry.getSubscribersForTesting(String.class).size());
    4745
     
    5856
    5957  @Test
    60   public void testUnregister() {
     58  void testUnregister() {
    6159    StringSubscriber s1 = new StringSubscriber();
    6260    StringSubscriber s2 = new StringSubscriber();
     
    7371
    7472  @Test
    75   public void testUnregister_notRegistered() {
    76     try {
    77       registry.unregister(new StringSubscriber());
    78       fail();
    79     } catch (IllegalArgumentException expected) {
    80     }
     73  void testUnregisterNotRegistered() {
     74    StringSubscriber temp = new StringSubscriber();
     75    assertThrows(IllegalArgumentException.class, () -> registry.unregister(temp));
    8176
    8277    StringSubscriber s1 = new StringSubscriber();
    8378    registry.register(s1);
    84     try {
    85       registry.unregister(new StringSubscriber());
    86       fail();
    87     } catch (IllegalArgumentException expected) {
    88       // a StringSubscriber was registered, but not the same one we tried to unregister
    89     }
     79    // a StringSubscriber was registered, but not the same one we tried to unregister
     80    assertThrows(IllegalArgumentException.class, () -> registry.unregister(temp));
    9081
    9182    registry.unregister(s1);
    92 
    93     try {
    94       registry.unregister(s1);
    95       fail();
    96     } catch (IllegalArgumentException expected) {
    97     }
    98   }
    99 
    100   @Test
    101   public void testGetSubscribers() {
     83    assertThrows(IllegalArgumentException.class, () -> registry.unregister(s1));
     84  }
     85
     86  @Test
     87  void testGetSubscribers() {
    10288    assertEquals(0, size(registry.getSubscribers("")));
    10389
     
    120106
    121107  @Test
    122   @Ignore("FIXME")
    123   public void testGetSubscribers_returnsImmutableSnapshot() {
     108  @Disabled("FIXME")
     109  void testGetSubscribersReturnsImmutableSnapshot() {
    124110    StringSubscriber s1 = new StringSubscriber();
    125111    StringSubscriber s2 = new StringSubscriber();
     
    186172
    187173  @Test
    188   public void testFlattenHierarchy() {
    189     assertEquals(
    190         new HashSet<>(Arrays.asList(
    191             Object.class,
    192             HierarchyFixtureInterface.class,
    193             HierarchyFixtureSubinterface.class,
    194             HierarchyFixtureParent.class,
    195             HierarchyFixture.class)),
    196         SubscriberRegistry.flattenHierarchy(HierarchyFixture.class));
     174  void testFlattenHierarchy() {
     175    assertEquals(new HashSet<>(Arrays.asList(
     176        Object.class,
     177        HierarchyFixtureInterface.class,
     178        HierarchyFixtureSubinterface.class,
     179        HierarchyFixtureParent.class,
     180        HierarchyFixture.class)), SubscriberRegistry.flattenHierarchy(HierarchyFixture.class));
    197181  }
    198182
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/SubscriberTest.java

    r34000 r36064  
    1818
    1919//import com.google.common.testing.EqualsTester;
     20
     21import static org.junit.jupiter.api.Assertions.assertSame;
     22import static org.junit.jupiter.api.Assertions.assertThrows;
     23import static org.junit.jupiter.api.Assertions.assertTrue;
     24
    2025import java.lang.reflect.InvocationTargetException;
    2126import java.lang.reflect.Method;
    2227
    23 import org.junit.Ignore;
    24 import org.junit.Test;
    25 import org.openstreetmap.josm.eventbus.AllowConcurrentEvents;
    26 import org.openstreetmap.josm.eventbus.EventBus;
    27 import org.openstreetmap.josm.eventbus.Subscribe;
    28 import org.openstreetmap.josm.eventbus.Subscriber;
    29 
    30 import junit.framework.TestCase;
     28import org.junit.jupiter.api.Assertions;
     29import org.junit.jupiter.api.BeforeEach;
     30import org.junit.jupiter.api.Disabled;
     31import org.junit.jupiter.api.Test;
    3132
    3233/**
     
    3637 * @author Colin Decker
    3738 */
    38 public class SubscriberTest extends TestCase {
     39class SubscriberTest {
    3940
    4041  private static final Object FIXTURE_ARGUMENT = new Object();
     
    4445  private Object methodArgument;
    4546
    46   @Override
    47   protected void setUp() throws Exception {
     47  @BeforeEach
     48  protected void setUp() {
    4849    bus = new EventBus();
    4950    methodCalled = false;
     
    5253
    5354  @Test
    54   public void testCreate() {
     55  void testCreate() {
    5556    Subscriber s1 = Subscriber.create(bus, this, getTestSubscriberMethod("recordingMethod"));
    5657    assertTrue(s1 instanceof Subscriber.SynchronizedSubscriber);
     
    5859    // a thread-safe method should not create a synchronized subscriber
    5960    Subscriber s2 = Subscriber.create(bus, this, getTestSubscriberMethod("threadSafeMethod"));
    60     assertFalse(s2 instanceof Subscriber.SynchronizedSubscriber);
     61    Assertions.assertFalse(s2 instanceof Subscriber.SynchronizedSubscriber);
    6162  }
    6263
    6364  @Test
    64   public void testInvokeSubscriberMethod_basicMethodCall() throws Throwable {
     65  void testInvokeSubscriberMethodBasicMethodCall() throws Throwable {
    6566    Method method = getTestSubscriberMethod("recordingMethod");
    6667    Subscriber subscriber = Subscriber.create(bus, this, method);
     
    6869    subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
    6970
    70     assertTrue("Subscriber must call provided method", methodCalled);
    71     assertTrue(
    72         "Subscriber argument must be exactly the provided object.",
    73         methodArgument == FIXTURE_ARGUMENT);
     71    assertTrue(methodCalled, "Subscriber must call provided method");
     72    assertSame(methodArgument, FIXTURE_ARGUMENT, "Subscriber argument must be exactly the provided object.");
    7473  }
    7574
    7675  @Test
    77   public void testInvokeSubscriberMethod_exceptionWrapping() throws Throwable {
     76  void testInvokeSubscriberMethodExceptionWrapping() {
    7877    Method method = getTestSubscriberMethod("exceptionThrowingMethod");
    7978    Subscriber subscriber = Subscriber.create(bus, this, method);
    8079
    81     try {
    82       subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
    83       fail("Subscribers whose methods throw must throw InvocationTargetException");
    84     } catch (InvocationTargetException expected) {
    85       assertTrue(expected.getCause() instanceof IntentionalException);
    86     }
     80    InvocationTargetException ite = assertThrows(InvocationTargetException.class, () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT),
     81            "Subscribers whose methods throw must throw InvocationTargetException");
     82    assertTrue(ite.getCause() instanceof IntentionalException);
    8783  }
    8884
    8985  @Test
    90   public void testInvokeSubscriberMethod_errorPassthrough() throws Throwable {
     86  void testInvokeSubscriberMethodErrorPassthrough() {
    9187    Method method = getTestSubscriberMethod("errorThrowingMethod");
    9288    Subscriber subscriber = Subscriber.create(bus, this, method);
    9389
    94     try {
    95       subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT);
    96       fail("Subscribers whose methods throw Errors must rethrow them");
    97     } catch (JudgmentError expected) {
    98     }
     90    assertThrows(JudgmentError.class, () -> subscriber.invokeSubscriberMethod(FIXTURE_ARGUMENT),
     91      "Subscribers whose methods throw Errors must rethrow them");
    9992  }
    10093
    10194  @Test
    102   @Ignore("FIXME")
    103   public void testEquals() throws Exception {
     95  @Disabled("FIXME")
     96  void testEquals() {
    10497    /*Method charAt = String.class.getMethod("charAt", int.class);
    10598    Method concat = String.class.getMethod("concat", String.class);
     
    128121  @Subscribe
    129122  public void recordingMethod(Object arg) {
    130     assertFalse(methodCalled);
     123    Assertions.assertFalse(methodCalled);
    131124    methodCalled = true;
    132125    methodArgument = arg;
     
    139132
    140133  /** Local exception subclass to check variety of exception thrown. */
    141   class IntentionalException extends Exception {
     134  static class IntentionalException extends Exception {
    142135
    143136    private static final long serialVersionUID = -2500191180248181379L;
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/outside/AnnotatedSubscriberFinderTests.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus.outside;
    1818
    19 import static org.junit.Assert.assertTrue;
     19
     20import static org.junit.jupiter.api.Assertions.assertTrue;
    2021
    2122import java.util.ArrayList;
    2223import java.util.List;
    2324
    24 import org.junit.After;
    25 import org.junit.Before;
    26 import org.junit.Test;
     25import org.junit.jupiter.api.AfterEach;
     26import org.junit.jupiter.api.BeforeEach;
     27import org.junit.jupiter.api.Test;
    2728import org.openstreetmap.josm.eventbus.EventBus;
    2829import org.openstreetmap.josm.eventbus.Subscribe;
     
    4849    }
    4950
    50     @Before
    51     public void setUp() throws Exception {
     51    @BeforeEach
     52    public void setUp() {
    5253      subscriber = createSubscriber();
    5354      EventBus bus = new EventBus();
     
    5657    }
    5758
    58     @After
    59     public void tearDown() throws Exception {
     59    @AfterEach
     60    public void tearDown() {
    6061      subscriber = null;
    6162    }
     
    6566   * We break the tests up based on whether they are annotated or abstract in the superclass.
    6667   */
    67   public static class BaseSubscriberFinderTest
     68  static class BaseSubscriberFinderTest
    6869      extends AbstractEventBusTestParent<BaseSubscriberFinderTest.Subscriber> {
    6970    static class Subscriber {
     
    8283
    8384    @Test
    84     public void testNonSubscriber() {
     85    void testNonSubscriber() {
    8586      assertTrue(getSubscriber().nonSubscriberEvents.isEmpty());
    8687    }
    8788
    8889    @Test
    89     public void testSubscriber() {
     90    void testSubscriber() {
    9091      assertTrue(getSubscriber().subscriberEvents.contains(EVENT));
    9192    }
     
    9798  }
    9899
    99   public static class AnnotatedAndAbstractInSuperclassTest
     100  static class AnnotatedAndAbstractInSuperclassTest
    100101      extends AbstractEventBusTestParent<AnnotatedAndAbstractInSuperclassTest.SubClass> {
    101102    abstract static class SuperClass {
     
    124125
    125126    @Test
    126     public void testOverriddenAndAnnotatedInSubclass() {
     127    void testOverriddenAndAnnotatedInSubclass() {
    127128      assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT));
    128129    }
    129130
    130131    @Test
    131     public void testOverriddenNotAnnotatedInSubclass() {
     132    void testOverriddenNotAnnotatedInSubclass() {
    132133      assertTrue(getSubscriber().overriddenInSubclassEvents.contains(EVENT));
    133134    }
     
    139140  }
    140141
    141   public static class AnnotatedNotAbstractInSuperclassTest
     142  static class AnnotatedNotAbstractInSuperclassTest
    142143      extends AbstractEventBusTestParent<AnnotatedNotAbstractInSuperclassTest.SubClass> {
    143144    static class SuperClass {
     
    206207
    207208    @Test
    208     public void testNotOverriddenInSubclass() {
     209    void testNotOverriddenInSubclass() {
    209210      assertTrue(getSubscriber().notOverriddenInSubclassEvents.contains(EVENT));
    210211    }
    211212
    212213    @Test
    213     public void testOverriddenNotAnnotatedInSubclass() {
     214    void testOverriddenNotAnnotatedInSubclass() {
    214215      assertTrue(getSubscriber().overriddenNotAnnotatedInSubclassEvents.contains(EVENT));
    215216    }
    216217
    217218    @Test
    218     public void testDifferentlyOverriddenNotAnnotatedInSubclass() {
     219    void testDifferentlyOverriddenNotAnnotatedInSubclass() {
    219220      assertTrue(getSubscriber().differentlyOverriddenNotAnnotatedInSubclassGoodEvents
    220221          .contains(EVENT));
     
    223224
    224225    @Test
    225     public void testOverriddenAndAnnotatedInSubclass() {
     226    void testOverriddenAndAnnotatedInSubclass() {
    226227      assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT));
    227228    }
    228229
    229230    @Test
    230     public void testDifferentlyOverriddenAndAnnotatedInSubclass() {
     231    void testDifferentlyOverriddenAndAnnotatedInSubclass() {
    231232      assertTrue(getSubscriber().differentlyOverriddenAnnotatedInSubclassGoodEvents
    232233          .contains(EVENT));
     
    240241  }
    241242
    242   public static class AbstractNotAnnotatedInSuperclassTest
     243  static class AbstractNotAnnotatedInSuperclassTest
    243244      extends AbstractEventBusTestParent<AbstractNotAnnotatedInSuperclassTest.SubClass> {
    244245    abstract static class SuperClass {
     
    265266
    266267    @Test
    267     public void testOverriddenAndAnnotatedInSubclass() {
     268    void testOverriddenAndAnnotatedInSubclass() {
    268269      assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT));
    269270    }
    270271
    271272    @Test
    272     public void testOverriddenInSubclassNowhereAnnotated() {
     273    void testOverriddenInSubclassNowhereAnnotated() {
    273274      assertTrue(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents.isEmpty());
    274275    }
     
    280281  }
    281282
    282   public static class NeitherAbstractNorAnnotatedInSuperclassTest
     283  static class NeitherAbstractNorAnnotatedInSuperclassTest
    283284      extends AbstractEventBusTestParent<NeitherAbstractNorAnnotatedInSuperclassTest.SubClass> {
    284285    static class SuperClass {
     
    314315
    315316    @Test
    316     public void testNeitherOverriddenNorAnnotated() {
     317    void testNeitherOverriddenNorAnnotated() {
    317318      assertTrue(getSubscriber().neitherOverriddenNorAnnotatedEvents.isEmpty());
    318319    }
    319320
    320321    @Test
    321     public void testOverriddenInSubclassNowhereAnnotated() {
     322    void testOverriddenInSubclassNowhereAnnotated() {
    322323      assertTrue(getSubscriber().overriddenInSubclassNowhereAnnotatedEvents.isEmpty());
    323324    }
    324325
    325326    @Test
    326     public void testOverriddenAndAnnotatedInSubclass() {
     327    void testOverriddenAndAnnotatedInSubclass() {
    327328      assertTrue(getSubscriber().overriddenAndAnnotatedInSubclassEvents.contains(EVENT));
    328329    }
     
    334335  }
    335336
    336   public static class DeepInterfaceTest
     337  static class DeepInterfaceTest
    337338      extends AbstractEventBusTestParent<DeepInterfaceTest.SubscriberClass> {
    338339    interface Interface1 {
     
    427428
    428429    @Test
    429     public void testAnnotatedIn1() {
     430    void testAnnotatedIn1() {
    430431      assertTrue(getSubscriber().annotatedIn1Events.contains(EVENT));
    431432    }
    432433
    433434    @Test
    434     public void testAnnotatedIn2() {
     435    void testAnnotatedIn2() {
    435436      assertTrue(getSubscriber().annotatedIn2Events.contains(EVENT));
    436437    }
    437438
    438439    @Test
    439     public void testAnnotatedIn1And2() {
     440    void testAnnotatedIn1And2() {
    440441      assertTrue(getSubscriber().annotatedIn1And2Events.contains(EVENT));
    441442    }
    442443
    443444    @Test
    444     public void testAnnotatedIn1And2AndClass() {
     445    void testAnnotatedIn1And2AndClass() {
    445446      assertTrue(getSubscriber().annotatedIn1And2AndClassEvents.contains(EVENT));
    446447    }
    447448
    448449    @Test
    449     public void testDeclaredIn1AnnotatedIn2() {
     450    void testDeclaredIn1AnnotatedIn2() {
    450451      assertTrue(getSubscriber().declaredIn1AnnotatedIn2Events.contains(EVENT));
    451452    }
    452453
    453454    @Test
    454     public void testDeclaredIn1AnnotatedInClass() {
     455    void testDeclaredIn1AnnotatedInClass() {
    455456      assertTrue(getSubscriber().declaredIn1AnnotatedInClassEvents.contains(EVENT));
    456457    }
    457458
    458459    @Test
    459     public void testDeclaredIn2AnnotatedInClass() {
     460    void testDeclaredIn2AnnotatedInClass() {
    460461      assertTrue(getSubscriber().declaredIn2AnnotatedInClassEvents.contains(EVENT));
    461462    }
    462463
    463464    @Test
    464     public void testNowhereAnnotated() {
     465    void testNowhereAnnotated() {
    465466      assertTrue(getSubscriber().nowhereAnnotatedEvents.isEmpty());
    466467    }
  • applications/editors/josm/plugins/eventbus/test/unit/org/openstreetmap/josm/eventbus/outside/OutsideEventBusTest.java

    r34000 r36064  
    1717package org.openstreetmap.josm.eventbus.outside;
    1818
    19 import static org.junit.Assert.assertEquals;
     19import static org.junit.jupiter.api.Assertions.assertEquals;
    2020
    2121import java.util.concurrent.atomic.AtomicInteger;
    2222import java.util.concurrent.atomic.AtomicReference;
    2323
    24 import org.junit.Test;
     24import org.junit.jupiter.api.Test;
    2525import org.openstreetmap.josm.eventbus.EventBus;
    2626import org.openstreetmap.josm.eventbus.Subscribe;
     
    3131 * @author Louis Wasserman
    3232 */
    33 public class OutsideEventBusTest {
     33class OutsideEventBusTest {
    3434
    3535  /*
     
    3939   */
    4040  @Test
    41   public void testAnonymous() {
     41  void testAnonymous() {
    4242    final AtomicReference<String> holder = new AtomicReference<>();
    4343    final AtomicInteger deliveries = new AtomicInteger();
     
    5555    bus.post(EVENT);
    5656
    57     assertEquals("Only one event should be delivered.", 1, deliveries.get());
    58     assertEquals("Correct string should be delivered.", EVENT, holder.get());
     57    assertEquals(1, deliveries.get(), "Only one event should be delivered.");
     58    assertEquals(EVENT, holder.get(), "Correct string should be delivered.");
    5959  }
    6060}
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/FullGraphCreationTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core;
    33
    4 import static org.junit.Assert.assertSame;
     4
     5import static org.junit.jupiter.api.Assertions.assertSame;
    56
    67import java.util.Arrays;
    78import java.util.Collection;
     9import java.util.Collections;
    810import java.util.HashMap;
    911import java.util.Iterator;
     
    1214import java.util.Map;
    1315
    14 import org.junit.Test;
     16import org.junit.jupiter.api.Test;
    1517import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestNode;
    1618import org.openstreetmap.josm.plugins.graphview.core.TestDataSource.TestRelation;
     
    3335import org.openstreetmap.josm.plugins.graphview.plugin.preferences.VehiclePropertyStringParser.PropertyValueSyntaxException;
    3436
    35 public class FullGraphCreationTest {
     37class FullGraphCreationTest {
    3638
    3739    private static final AccessParameters ACCESS_PARAMS;
     
    4446            ACCESS_PARAMS = new PreferenceAccessParameters(
    4547                    "test_vehicle",
    46                     Arrays.asList(AccessType.UNDEFINED),
     48                    Collections.singletonList(AccessType.UNDEFINED),
    4749                    vehiclePropertyValues);
    4850        } catch (PropertyValueSyntaxException e) {
     
    5456        @Override
    5557        public java.util.List<String> getAccessHierarchyAncestors(String transportMode) {
    56             return Arrays.asList(transportMode);
     58            return Collections.singletonList(transportMode);
    5759        }
    5860
    5961        @Override
    6062        public Collection<Tag> getBaseTags() {
    61             return Arrays.asList(new Tag("highway", "test"));
     63            return Collections.singletonList(new Tag("highway", "test"));
    6264        }
    6365
     
    6971
    7072    @Test
    71     public void testTJunction() {
     73    void testTJunction() {
    7274
    7375        TestDataSource ds = new TestDataSource();
     
    125127
    126128    @Test
    127     public void testBarrier() {
     129    void testBarrier() {
    128130
    129131        TestDataSource ds = new TestDataSource();
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/access/AccessRulesetReaderTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.access;
    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.assertSame;
    8 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertSame;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.io.FileInputStream;
     
    1515import java.util.Map;
    1616
    17 import org.junit.Test;
     17import org.junit.jupiter.api.Test;
    1818import org.openstreetmap.josm.TestUtils;
    1919import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup;
     
    2121import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup;
    2222
    23 public class AccessRulesetReaderTest {
     23class AccessRulesetReaderTest {
    2424
    2525    @Test
    26     public void testReadAccessRuleset_valid_classes() throws IOException {
     26    void testReadAccessRulesetValidClasses() throws IOException {
    2727
    2828        InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml");
     
    5050
    5151    @Test
    52     public void testReadAccessRuleset_valid_basetags() throws IOException {
     52    void testReadAccessRulesetValidBasetags() throws IOException {
    5353
    5454        InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml");
     
    6666
    6767    @Test
    68     public void testReadAccessRuleset_valid_implications() throws IOException {
     68    void testReadAccessRulesetValidImplications() throws IOException {
    6969
    7070        InputStream is = new FileInputStream(TestUtils.getTestDataRoot()+"accessRuleset_valid.xml");
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadInclineTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.property;
    33
    4 import org.junit.Test;
     4import org.junit.jupiter.api.Test;
    55import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    66
    7 public class RoadInclineTest extends RoadPropertyTest {
     7class RoadInclineTest implements RoadPropertyTest {
    88
    99    private static void testIncline(Float expectedInclineForward, Float expectedInclineBackward,
    1010            String inclineString) {
    1111
    12         testEvaluateW(new RoadIncline(),
     12        RoadPropertyTest.testEvaluateW(new RoadIncline(),
    1313                expectedInclineForward, expectedInclineBackward,
    1414                new Tag("incline", inclineString));
     
    1616
    1717    @Test
    18     public void testEvaluate() {
     18    void testEvaluate() {
    1919        testIncline(5f, -5f, "5 %");
    2020        testIncline(9.5f, -9.5f, "9.5 %");
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadMaxspeedTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.property;
    33
    4 import org.junit.Test;
     4import org.junit.jupiter.api.Test;
    55import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    66
    7 public class RoadMaxspeedTest extends RoadPropertyTest {
     7class RoadMaxspeedTest implements RoadPropertyTest {
    88
    99    private static void testMaxspeed(float expectedMaxspeed, String maxspeedString) {
    10         testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString));
     10        RoadPropertyTest.testEvaluateBoth(new RoadMaxspeed(), expectedMaxspeed, new Tag("maxspeed", maxspeedString));
    1111    }
    1212
    1313    @Test
    14     public void testEvaluate_numeric() {
     14    void testEvaluateNumeric() {
    1515        testMaxspeed(30, "30");
    1616        testMaxspeed(48.3f, "48.3");
     
    1818
    1919    @Test
    20     public void testEvaluate_kmh() {
     20    void testEvaluateKmh() {
    2121        testMaxspeed(50, "50 km/h");
    2222        testMaxspeed(120, "120km/h");
     
    2525
    2626    @Test
    27     public void testEvaluate_mph() {
     27    void testEvaluateMph() {
    2828        testMaxspeed(72.42048f, "45 mph");
    2929        testMaxspeed(64.373764f, "40mph");
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/property/RoadPropertyTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.property;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.Ignore;
    76import org.openstreetmap.josm.plugins.graphview.core.TestDataSource;
    87import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    98
    10 @Ignore("no test")
    11 public abstract class RoadPropertyTest {
     9public interface RoadPropertyTest {
    1210
    13     protected static <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) {
     11    static <P> void testEvaluateW(RoadPropertyType<P> property, P expectedForward, P expectedBackward, Tag... wayTags) {
    1412
    1513        TestDataSource ds = new TestDataSource();
     
    2523    }
    2624
    27     protected static <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
     25    static <P> void testEvaluateN(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
    2826
    2927        TestDataSource ds = new TestDataSource();
     
    4038    }
    4139
    42     protected static <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
     40    static <P> void testEvaluateBoth(RoadPropertyType<P> property, P expected, Tag... nodeTags) {
    4341        testEvaluateW(property, expected, expected, nodeTags);
    4442        testEvaluateN(property, expected, nodeTags);
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/TagConditionLogicTest.java

    r32620 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.graphview.core.util;
    3 import static org.junit.Assert.assertFalse;
    4 import static org.junit.Assert.assertTrue;
     3
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    56
    67import java.util.Arrays;
     8import java.util.Collections;
    79import java.util.HashMap;
    810import java.util.Map;
    911
    10 import org.junit.Before;
    11 import org.junit.Test;
     12import org.junit.jupiter.api.BeforeEach;
     13import org.junit.jupiter.api.Test;
    1214import org.openstreetmap.josm.plugins.graphview.core.data.MapBasedTagGroup;
    1315import org.openstreetmap.josm.plugins.graphview.core.data.Tag;
    1416import org.openstreetmap.josm.plugins.graphview.core.data.TagGroup;
    1517
    16 public class TagConditionLogicTest {
     18class TagConditionLogicTest {
    1719
    1820    TagGroup groupA;
    1921    TagGroup groupB;
    2022
    21     @Before
    22     public void setUp() {
     23    @BeforeEach
     24    void setUp() {
    2325        Map<String, String> mapA = new HashMap<>();
    2426        mapA.put("key1", "value1");
     
    3436
    3537    @Test
    36     public void testTag() {
     38    void testTag() {
    3739        TagCondition condition = TagConditionLogic.tag(new Tag("key3", "value1"));
    3840        assertTrue(condition.matches(groupA));
     
    4143
    4244    @Test
    43     public void testKey() {
     45    void testKey() {
    4446        TagCondition condition = TagConditionLogic.key("key3");
    4547        assertTrue(condition.matches(groupA));
     
    4850
    4951    @Test
    50     public void testAnd() {
     52    void testAnd() {
    5153        TagCondition condition1 = TagConditionLogic.tag(new Tag("key2", "value2"));
    5254        TagCondition conditionAnd1a = TagConditionLogic.and(condition1);
    53         TagCondition conditionAnd1b = TagConditionLogic.and(Arrays.asList(condition1));
     55        TagCondition conditionAnd1b = TagConditionLogic.and(Collections.singletonList(condition1));
    5456
    5557        assertTrue(conditionAnd1a.matches(groupA));
     
    7880
    7981    @Test
    80     public void testOr() {
     82    void testOr() {
    8183        TagCondition condition1 = TagConditionLogic.tag(new Tag("key42", "value42"));
    8284        TagCondition conditionOr1a = TagConditionLogic.or(condition1);
    83         TagCondition conditionOr1b = TagConditionLogic.or(Arrays.asList(condition1));
     85        TagCondition conditionOr1b = TagConditionLogic.or(Collections.singletonList(condition1));
    8486
    8587        assertFalse(conditionOr1a.matches(groupA));
     
    108110
    109111    @Test
    110     public void testNot() {
     112    void testNot() {
    111113        TagCondition condition = TagConditionLogic.not(TagConditionLogic.key("key3"));
    112114        assertFalse(condition.matches(groupA));
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/util/ValueStringParserTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.util;
    33
    4 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertNull;
    55import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseMeasure;
    66import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseSpeed;
    77import static org.openstreetmap.josm.plugins.graphview.core.util.ValueStringParser.parseWeight;
    88
    9 import org.junit.Test;
     9import org.junit.jupiter.api.Test;
    1010
    11 public class ValueStringParserTest {
     11
     12class ValueStringParserTest {
    1213
    1314    /* speed */
    1415
    1516    @Test
    16     public void testParseSpeedDefault() {
     17    void testParseSpeedDefault() {
    1718        assertClose(50, parseSpeed("50"));
    1819    }
    1920
    2021    @Test
    21     public void testParseSpeedKmh() {
     22    void testParseSpeedKmh() {
    2223        assertClose(30, parseSpeed("30 km/h"));
    2324        assertClose(100, parseSpeed("100km/h"));
     
    2526
    2627    @Test
    27     public void testParseSpeedMph() {
     28    void testParseSpeedMph() {
    2829        assertClose(40.234f, parseSpeed("25mph"));
    2930        assertClose(40.234f, parseSpeed("25 mph"));
     
    3132
    3233    @Test
    33     public void testParseSpeedInvalid() {
     34    void testParseSpeedInvalid() {
    3435        assertNull(parseSpeed("lightspeed"));
    3536    }
     
    3839
    3940    @Test
    40     public void testParseMeasureDefault() {
     41    void testParseMeasureDefault() {
    4142        assertClose(3.5f, parseMeasure("3.5"));
    4243    }
    4344
    4445    @Test
    45     public void testParseMeasureM() {
     46    void testParseMeasureM() {
    4647        assertClose(2, parseMeasure("2m"));
    4748        assertClose(5.5f, parseMeasure("5.5 m"));
     
    4950
    5051    @Test
    51     public void testParseMeasureKm() {
     52    void testParseMeasureKm() {
    5253        assertClose(1000, parseMeasure("1 km"));
    5354        assertClose(7200, parseMeasure("7.2km"));
     
    5556
    5657    @Test
    57     public void testParseMeasureMi() {
     58    void testParseMeasureMi() {
    5859        assertClose(1609.344f, parseMeasure("1 mi"));
    5960    }
    6061
    6162    @Test
    62     public void testParseMeasureFeetInches() {
     63    void testParseMeasureFeetInches() {
    6364        assertClose(3.6576f, parseMeasure("12'0\""));
    6465        assertClose(1.9812f, parseMeasure("6' 6\""));
     
    6667
    6768    @Test
    68     public void testParseMeasureInvalid() {
     69    void testParseMeasureInvalid() {
    6970        assertNull(parseMeasure("very long"));
    7071        assertNull(parseMeasure("6' 16\""));
     
    7475
    7576    @Test
    76     public void testParseWeightDefault() {
     77    void testParseWeightDefault() {
    7778        assertClose(3.6f, parseWeight("3.6"));
    7879    }
    7980
    8081    @Test
    81     public void testParseWeightT() {
     82    void testParseWeightT() {
    8283        assertClose(30, parseWeight("30t"));
    8384        assertClose(3.5f, parseWeight("3.5 t"));
     
    8586
    8687    @Test
    87     public void testParseWeightInvalid() {
     88    void testParseWeightInvalid() {
    8889        assertNull(parseWeight("heavy"));
    8990    }
  • applications/editors/josm/plugins/graphview/test/unit/org/openstreetmap/josm/plugins/graphview/core/visualisation/FloatPropertyColorSchemeTest.java

    r32620 r36064  
    22package org.openstreetmap.josm.plugins.graphview.core.visualisation;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    66import java.awt.Color;
     
    88import java.util.Map;
    99
    10 import org.junit.Before;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.BeforeEach;
     11import org.junit.jupiter.api.Test;
    1212import org.openstreetmap.josm.plugins.graphview.core.property.RoadMaxweight;
    1313
    14 public class FloatPropertyColorSchemeTest {
     14class FloatPropertyColorSchemeTest {
    1515
    1616    private FloatPropertyColorScheme subject;
    1717
    18     @Before
     18    @BeforeEach
    1919    public void setUp() {
    2020
     
    2828
    2929    @Test
    30     public void testGetColorForValue_below() {
     30    void testGetColorForValueBelow() {
    3131        assertEquals(new Color(42, 42, 42), subject.getColorForValue(1f));
    3232        assertEquals(new Color(42, 42, 42), subject.getColorForValue(5f));
     
    3434
    3535    @Test
    36     public void testGetColorForValue_above() {
     36    void testGetColorForValueAbove() {
    3737        assertEquals(new Color(200, 200, 200), subject.getColorForValue(25f));
    3838    }
    3939
    4040    @Test
    41     public void testGetColorForValue_value() {
     41    void testGetColorForValueValue() {
    4242        assertEquals(new Color(100, 100, 100), subject.getColorForValue(10f));
    4343    }
    4444
    4545    @Test
    46     public void testGetColorForValue_interpolate() {
     46    void testGetColorForValueInterpolate() {
    4747        assertEquals(new Color(150, 150, 150), subject.getColorForValue(15f));
    4848    }
  • applications/editors/josm/plugins/http2/test/unit/org/openstreetmap/josm/plugins/http2/Http2ClientTest.java

    r35790 r36064  
    22package org.openstreetmap.josm.plugins.http2;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    56import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
     
    6364
    6465    @Test
    65     void testCreateRequest_invalidURI() throws Exception {
     66    void testCreateRequestInvalidURI() {
    6667        // From https://josm.openstreetmap.de/ticket/21126
    6768        // URISyntaxException for URL not formatted strictly according to RFC2396
    6869        // See chapter "2.4.3. Excluded US-ASCII Characters"
    69         assertTrue(assertThrows(IOException.class, () -> new Http2Client(
    70                 new URL("https://commons.wikimedia.org/w/api.php?format=xml&action=query&list=geosearch&gsnamespace=6&gslimit=500&gsprop=type|name&gsbbox=52.2804692|38.1772755|52.269721|38.2045051"), "GET")
     70        final URL url = assertDoesNotThrow(() -> new URL("https://commons.wikimedia.org/w/api.php?format=xml&action=query&list=geosearch&gsnamespace=6&gslimit=500&gsprop=type|name&gsbbox=52.2804692|38.1772755|52.269721|38.2045051"));
     71        assertTrue(assertThrows(IOException.class, () -> new Http2Client(url, "GET")
    7172                .createRequest()).getCause().getMessage().startsWith("Illegal character in query at index 116:"));
    7273    }
  • applications/editors/josm/plugins/imagery-xml-bounds/test/unit/org/openstreetmap/josm/plugins/imageryxmlbounds/actions/ComputeBoundsActionTest.java

    r35100 r36064  
    11package org.openstreetmap.josm.plugins.imageryxmlbounds.actions;
    22
    3 import static org.junit.Assert.assertEquals;
     3import static org.junit.jupiter.api.Assertions.assertEquals;
    44
    55import java.util.Arrays;
    66
    7 import org.junit.Rule;
    8 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    98import org.openstreetmap.josm.data.coor.LatLon;
    109import org.openstreetmap.josm.data.osm.Node;
    1110import org.openstreetmap.josm.data.osm.Way;
    12 import org.openstreetmap.josm.testutils.JOSMTestRules;
    13 
    14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1512
    1613/**
    1714 * Unit tests of {@link ComputeBoundsAction}
    1815 */
    19 public class ComputeBoundsActionTest {
    20 
    21     /**
    22      * Setup rule
    23      */
    24     @Rule
    25     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    26     public JOSMTestRules test = new JOSMTestRules();
    27 
     16@BasicPreferences
     17class ComputeBoundsActionTest {
    2818    /**
    2919     * Unit test of {@link ComputeBoundsAction#getBounds}
    3020     */
    3121    @Test
    32     public void testGetBounds() {
     22    void testGetBounds() {
    3323        assertEquals("        <bounds min-lat='0' min-lon='0' max-lat='0' max-lon='0'>\n",
    3424                ComputeBoundsAction.getBounds(new Node(LatLon.ZERO), false));
  • applications/editors/josm/plugins/o5m/test/unit/org/openstreetmap/josm/plugins/o5m/io/O5mImporterTest.java

    r34837 r36064  
    22package org.openstreetmap.josm.plugins.o5m.io;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    77
    88import java.io.IOException;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.Assertions;
     11import org.junit.jupiter.api.Test;
    1212import org.openstreetmap.josm.TestUtils;
    1313import org.openstreetmap.josm.data.osm.DataSet;
     
    1616import org.openstreetmap.josm.data.osm.User;
    1717import org.openstreetmap.josm.io.IllegalDataException;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1919
    2020/**
    2121 * Unit tests for {@link O5mImporter}.
    2222 */
    23 public class O5mImporterTest {
    24 
    25     /**
    26      * Setup test.
    27      */
    28     @Rule
    29     public JOSMTestRules rules = new JOSMTestRules().preferences();
    30 
     23@BasicPreferences
     24class O5mImporterTest {
    3125    private static void checkUserNull(OsmPrimitive osm, boolean hasToBeNull) {
    3226        User usr = osm.getUser();
    3327        if (hasToBeNull) {
    34             assertNull(osm + " -> " + usr, usr);
     28            assertNull(usr, osm + " -> " + usr);
    3529        } else {
    36             assertNotNull(osm + " -> " + usr, usr);
     30            assertNotNull(usr, osm + " -> " + usr);
    3731        }
    3832    }
     
    5650     */
    5751    @Test
    58     public void testParseDataSet() throws Exception {
     52    void testParseDataSet() throws Exception {
    5953        doTestMonaco(TestUtils.getTestDataRoot() + "/monaco-latest.o5m", false);
    6054    }
     
    6660     */
    6761    @Test
    68     public void testParseDataSetDropVersion() throws Exception {
     62    void testParseDataSetDropVersion() throws Exception {
    6963        doTestMonaco(TestUtils.getTestDataRoot() + "/monaco-drop-version.o5m", true);
    7064    }
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/test/unit/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModuleTest.java

    r35269 r36064  
    22package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    64
    7 import org.junit.Rule;
    8 import org.junit.Test;
    9 import org.openstreetmap.josm.testutils.JOSMTestRules;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7
     8import org.junit.jupiter.api.Test;
     9import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1010
    1111/**
    1212 * Unit tests of {@link ToulouseModule} class.
    1313 */
    14 public class ToulouseModuleTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @Rule
    20     public JOSMTestRules rules = new JOSMTestRules().preferences();
    21 
     14@BasicPreferences
     15class ToulouseModuleTest {
    2216    @Test
    23     public void testHandlersConstruction() {
     17    void testHandlersConstruction() {
    2418        ToulouseModule module = new ToulouseModule(null);
    2519        assertFalse(module.getHandlers().isEmpty());
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/test/unit/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModuleTestIT.java

    r35272 r36064  
    22package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse;
    33
    4 import static org.junit.Assert.assertTrue;
     4
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    56
    67import java.io.IOException;
     
    89import java.util.TreeMap;
    910
    10 import org.junit.Rule;
    11 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
     12import org.junit.jupiter.api.Timeout;
    1213import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1415import org.openstreetmap.josm.tools.HttpClient;
    1516
     
    1718 * Integration tests of {@link ToulouseModule} class.
    1819 */
    19 public class ToulouseModuleTestIT {
    20 
    21     /**
    22      * Setup test.
    23      */
    24     @Rule
    25     public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(30_000);
    26 
     20@BasicPreferences
     21@Timeout(30)
     22class ToulouseModuleTestIT {
    2723    @Test
    28     public void testUrlValidity() throws IOException {
     24    void testUrlValidity() throws IOException {
    2925        Map<String, Integer> errors = new TreeMap<>();
    3026        for (AbstractDataSetHandler handler : new ToulouseModule(null).getNewlyInstanciatedHandlers()) {
     
    3430            }
    3531        }
    36         assertTrue(errors.toString(), errors.isEmpty());
     32        assertTrue(errors.isEmpty(), errors.toString());
    3733    }
    3834}
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReaderTest.java

    r35899 r36064  
    33
    44import java.io.File;
    5 import java.io.FileInputStream;
    65import java.io.InputStream;
     6import java.nio.file.Files;
    77import java.nio.file.Path;
    88import java.util.Map.Entry;
     9import java.util.concurrent.TimeUnit;
    910
    1011import org.junit.jupiter.api.Test;
    11 import org.junit.jupiter.api.extension.RegisterExtension;
     12import org.junit.jupiter.api.Timeout;
    1213import org.openstreetmap.josm.data.osm.DataSet;
    1314import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     16import org.openstreetmap.josm.testutils.annotations.Projection;
    1617import org.openstreetmap.josm.tools.Logging;
    1718
     
    2021 */
    2122@BasicPreferences
     23@Projection
     24@Timeout(value = 10, unit = TimeUnit.MINUTES)
    2225class ZipReaderTest {
    23 
    24     /**
    25      * Setup test.
    26      */
    27     @RegisterExtension
    28     public JOSMTestRules rules = new JOSMTestRules().projection().noTimeout();
    29 
    3026    /**
    3127     * Test for various zip files reading
     
    3733            File zipfile = p.toFile();
    3834            Logging.info("Testing reading file "+zipfile.getPath());
    39             try (InputStream is = new FileInputStream(zipfile)) {
     35            try (InputStream is = Files.newInputStream(zipfile.toPath())) {
    4036                for (Entry<File, DataSet> entry : ZipReader.parseDataSets(is, null, null, false).entrySet()) {
    4137                    String name = entry.getKey().getName();
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/datasets/DataSetUpdaterTest.java

    r35899 r36064  
    22package org.openstreetmap.josm.plugins.opendata.core.io.datasets;
    33
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6
    47import java.io.File;
    5 import java.io.FileInputStream;
    68import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.util.concurrent.TimeUnit;
    711import java.util.function.Predicate;
    812
    913import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.Timeout;
    1015import org.junit.jupiter.api.extension.RegisterExtension;
    1116import org.openstreetmap.josm.TestUtils;
     
    1722import org.openstreetmap.josm.testutils.JOSMTestRules;
    1823import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    19 
    20 import static org.junit.jupiter.api.Assertions.assertFalse;
    21 import static org.junit.jupiter.api.Assertions.assertTrue;
     24import org.openstreetmap.josm.testutils.annotations.Projection;
    2225
    2326/**
     
    2528 */
    2629@BasicPreferences
     30@Projection
     31@Timeout(value = 1, unit = TimeUnit.MINUTES)
    2732class DataSetUpdaterTest {
    2833
     
    3136     */
    3237    @RegisterExtension
    33     JOSMTestRules rules = new JOSMTestRules().projection().devAPI().timeout(60000);
     38    JOSMTestRules rules = new JOSMTestRules().devAPI();
    3439
    3540    /**
     
    4045    void testTicket11166() throws Exception {
    4146        File file = new File(TestUtils.getRegressionDataFile(11166, "raba760dissJosm.zip"));
    42         try (InputStream is = new FileInputStream(file)) {
     47        try (InputStream is = Files.newInputStream(file.toPath())) {
    4348            Predicate<? super Way> p = w -> w.getNodesCount() >= 0.9 * OsmApi.getOsmApi().getCapabilities().getMaxWayNodes();
    4449            DataSet ds = ZipReader.parseDataSet(is, null, null, false);
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReaderTest.java

    r35899 r36064  
    66
    77import java.io.File;
    8 import java.io.FileInputStream;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.util.concurrent.TimeUnit;
    1011
    1112import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
     13import org.junit.jupiter.api.Timeout;
    1314import org.openstreetmap.josm.TestUtils;
    1415import org.openstreetmap.josm.data.osm.Node;
    15 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     17import org.openstreetmap.josm.testutils.annotations.Projection;
    1718
    1819/**
     
    2021 */
    2122@BasicPreferences
     23@Projection
     24@Timeout(value = 1, unit = TimeUnit.MINUTES)
    2225class GmlReaderTest {
    23 
    24     /**
    25      * Setup test.
    26      */
    27     @RegisterExtension
    28     JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);
    29 
    3026    /**
    3127     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/11624">#11624</a>
     
    3531    void testTicket11624() throws Exception {
    3632        File file = new File(TestUtils.getRegressionDataFile(11624, "temp3.gml"));
    37         try (InputStream is = new FileInputStream(file)) {
     33        try (InputStream is = Files.newInputStream(file.toPath())) {
    3834            for (Node n : GmlReader.parseDataSet(is, null, null).getNodes()) {
    3935                assertNotNull(n.getCoor(), n.toString());
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReaderTest.java

    r35910 r36064  
    88
    99import org.junit.jupiter.api.Test;
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.openstreetmap.josm.TestUtils;
    1211import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1412import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     13import org.openstreetmap.josm.testutils.annotations.Projection;
    1514
    1615/**
     
    1817 */
    1918@BasicPreferences
     19@Projection
    2020class KmlReaderTest {
    21 
    22     /**
    23      * Setup test.
    24      */
    25     @RegisterExtension
    26     JOSMTestRules rules = new JOSMTestRules().projection();
    27 
    2821    /**
    2922     * Unit test of {@link KmlReader#COLOR_PATTERN}
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReaderTest.java

    r35899 r36064  
    88
    99import org.junit.jupiter.api.Test;
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.openstreetmap.josm.TestUtils;
    1211import org.openstreetmap.josm.data.osm.DataSet;
     
    1413import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    1514import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1715import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     16import org.openstreetmap.josm.testutils.annotations.Projection;
    1817
    1918/**
     
    2120 */
    2221@BasicPreferences
     22@Projection
    2323class MifReaderTest {
    24 
    25     /**
    26      * Setup test.
    27      */
    28     @RegisterExtension
    29     JOSMTestRules rules = new JOSMTestRules().projection();
    30 
    3124    private static AbstractDataSetHandler newHandler(final String epsgCode) {
    3225        AbstractDataSetHandler handler = new AbstractDataSetHandler() {
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReaderTest.java

    r35899 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.opendata.core.io.geographic;
    3 
    4 import java.io.File;
    5 import java.io.FileInputStream;
    6 import java.io.InputStream;
    7 import java.util.Collection;
    8 import java.util.Objects;
    9 
    10 import org.junit.jupiter.api.Disabled;
    11 import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    13 import org.openstreetmap.josm.TestUtils;
    14 import org.openstreetmap.josm.data.coor.LatLon;
    15 import org.openstreetmap.josm.data.osm.Node;
    16 import org.openstreetmap.josm.data.osm.Way;
    17 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
    19 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    203
    214import static org.junit.jupiter.api.Assertions.assertEquals;
     
    258import static org.junit.jupiter.api.Assertions.assertTrue;
    269
     10import java.io.File;
     11import java.io.FileInputStream;
     12import java.io.InputStream;
     13import java.nio.file.Files;
     14import java.util.Collection;
     15import java.util.Objects;
     16import java.util.concurrent.TimeUnit;
     17
     18import org.junit.jupiter.api.Disabled;
     19import org.junit.jupiter.api.Test;
     20import org.junit.jupiter.api.Timeout;
     21import org.openstreetmap.josm.TestUtils;
     22import org.openstreetmap.josm.data.coor.LatLon;
     23import org.openstreetmap.josm.data.osm.Node;
     24import org.openstreetmap.josm.data.osm.Way;
     25import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     27import org.openstreetmap.josm.testutils.annotations.Projection;
     28
    2729/**
    2830 * Unit tests of {@link ShpReader} class.
    2931 */
    3032@BasicPreferences
     33@Projection
     34@Timeout(value = 1, unit = TimeUnit.MINUTES)
    3135class ShpReaderTest {
    32 
    33     /**
    34      * Setup test.
    35      */
    36     @RegisterExtension
    37     JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);
    38 
    3936    /**
    4037     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12714">#12714</a>
     
    4441    void testTicket12714() throws Exception {
    4542        File file = new File(TestUtils.getRegressionDataFile(12714, "linhas.shp"));
    46         try (InputStream is = new FileInputStream(file)) {
     43        try (InputStream is = Files.newInputStream(file.toPath())) {
    4744            for (Node n : ShpReader.parseDataSet(is, file, null, null).getNodes()) {
    4845                assertNotNull(n.getCoor(), n.toString());
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/TabReaderTest.java

    r35899 r36064  
    33
    44import java.io.File;
    5 import java.io.FileInputStream;
    65import java.io.InputStream;
     6import java.nio.file.Files;
     7import java.util.concurrent.TimeUnit;
    78
    89import org.junit.jupiter.api.Test;
    9 import org.junit.jupiter.api.extension.RegisterExtension;
     10import org.junit.jupiter.api.Timeout;
    1011import org.openstreetmap.josm.TestUtils;
    1112import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    12 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1313import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     14import org.openstreetmap.josm.testutils.annotations.Projection;
    1415
    1516/**
     
    1718 */
    1819@BasicPreferences
     20@Projection
     21@Timeout(value = 1, unit = TimeUnit.MINUTES)
    1922class TabReaderTest {
    20 
    21     /**
    22      * Setup test.
    23      */
    24     @RegisterExtension
    25     JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);
    26 
    2723    /**
    2824     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/15159">#15159</a>
     
    3228    void testTicket15159() throws Exception {
    3329        File file = new File(TestUtils.getRegressionDataFile(15159, "Sanisette.tab"));
    34         try (InputStream is = new FileInputStream(file)) {
     30        try (InputStream is = Files.newInputStream(file.toPath())) {
    3531            NonRegFunctionalTests.testGeneric("#15159", TabReader.parseDataSet(is, file, null, null));
    3632        }
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReaderTest.java

    r35899 r36064  
    55
    66import org.junit.jupiter.api.Test;
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    87import org.openstreetmap.josm.TestUtils;
    98import org.openstreetmap.josm.data.coor.EastNorth;
     
    1312import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    1413import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    15 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1614import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     15import org.openstreetmap.josm.testutils.annotations.Projection;
    1716
    1817/**
     
    2019 */
    2120@BasicPreferences
     21@Projection
    2222class CsvReaderTest {
    23 
    24     /**
    25      * Setup test.
    26      */
    27     @RegisterExtension
    28     JOSMTestRules rules = new JOSMTestRules().projection();
    29 
    3023    private static AbstractDataSetHandler newHandler(final String epsgCode) {
    3124        AbstractDataSetHandler handler = new AbstractDataSetHandler() {
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsReaderTest.java

    r35899 r36064  
    55
    66import org.junit.jupiter.api.Test;
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    87import org.openstreetmap.josm.TestUtils;
    98import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    10 import org.openstreetmap.josm.testutils.JOSMTestRules;
    119import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     10import org.openstreetmap.josm.testutils.annotations.Projection;
    1211
    1312/**
     
    1514 */
    1615@BasicPreferences
     16@Projection
    1717class OdsReaderTest {
    18 
    19     /**
    20      * Setup test.
    21      */
    22     @RegisterExtension
    23     JOSMTestRules rules = new JOSMTestRules().projection();
    2418
    2519    /**
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/XlsReaderTest.java

    r35899 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.opendata.core.io.tabular;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
    36
    47import java.io.InputStream;
    58
    69import org.junit.jupiter.api.Test;
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    810import org.openstreetmap.josm.TestUtils;
    911import org.openstreetmap.josm.data.coor.EastNorth;
     
    1416import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    1517import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1718import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    18 
    19 import static org.junit.jupiter.api.Assertions.assertEquals;
    20 import static org.junit.jupiter.api.Assertions.assertNotNull;
     19import org.openstreetmap.josm.testutils.annotations.Projection;
    2120
    2221/**
     
    2423 */
    2524@BasicPreferences
     25@Projection
    2626class XlsReaderTest {
    27 
    28     /**
    29      * Setup test.
    30      */
    31     @RegisterExtension
    32     public JOSMTestRules rules = new JOSMTestRules().projection();
    33 
    3427    private static AbstractDataSetHandler newHandler(final String epsgCode) {
    3528        AbstractDataSetHandler handler = new AbstractDataSetHandler() {
  • applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io/PbfExporterTest.java

    r32927 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.pbf.io;
     3
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    35
    46import java.io.FileInputStream;
     
    68import java.nio.file.Files;
    79import java.nio.file.Path;
     10import java.nio.file.Paths;
    811
    9 import org.junit.Rule;
    10 import org.junit.Test;
     12import org.junit.jupiter.api.Test;
     13import org.junit.jupiter.api.Timeout;
    1114import org.openstreetmap.josm.TestUtils;
    1215import org.openstreetmap.josm.data.osm.DataSet;
     
    1417import org.openstreetmap.josm.io.Compression;
    1518import org.openstreetmap.josm.io.OsmReader;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1720
    1821/**
    1922 * Unit tests for {@link PbfExporter}.
    2023 */
    21 public class PbfExporterTest {
    22 
    23     /**
    24      * Setup test.
    25      */
    26     @Rule
    27     public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(20000);
    28 
     24@BasicPreferences
     25@Timeout(20)
     26class PbfExporterTest {
    2927    /**
    3028     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/11169">Ticket #11169</a>.
     
    3230     */
    3331    @Test
    34     public void testTicket11169() throws Exception {
     32    void testTicket11169() throws Exception {
    3533        try (InputStream is = Compression.ZIP.getUncompressedInputStream(
    36                 new FileInputStream(TestUtils.getRegressionDataFile(11169, "Portsmouth_Area.osm.zip")))) {
     34                Files.newInputStream(Paths.get(TestUtils.getRegressionDataFile(11169, "Portsmouth_Area.osm.zip"))))) {
    3735            DataSet ds = OsmReader.parseDataSet(is, null);
    3836            Path out = Files.createTempFile("pbf-bug-11169", "pbf");
    39             new PbfExporter().doSave(out.toFile(), new OsmDataLayer(ds, null, null));
     37            PbfExporter exporter = new PbfExporter();
     38            assertDoesNotThrow(() -> exporter.doSave(out.toFile(), new OsmDataLayer(ds, null, null)));
    4039            Files.delete(out);
    4140        }
  • applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io/PbfImporterTest.java

    r34848 r36064  
    22package org.openstreetmap.josm.plugins.pbf.io;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    77
    88import java.io.IOException;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
    1211import org.openstreetmap.josm.TestUtils;
    1312import org.openstreetmap.josm.data.osm.DataSet;
     
    1615import org.openstreetmap.josm.data.osm.User;
    1716import org.openstreetmap.josm.io.IllegalDataException;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1918
    2019/**
    2120 * Unit tests for {@link PbfImporter}.
    2221 */
    23 public class PbfImporterTest {
    24 
    25     /**
    26      * Setup test.
    27      */
    28     @Rule
    29     public JOSMTestRules rules = new JOSMTestRules().preferences();
    30 
     22@BasicPreferences
     23class PbfImporterTest {
    3124    private static void checkUserNull(OsmPrimitive osm, boolean hasToBeNull) {
    3225        User usr = osm.getUser();
    3326        if (hasToBeNull) {
    34             assertNull(osm + " -> " + usr, usr);
     27            assertNull(usr, osm + " -> " + usr);
    3528        } else {
    36             assertNotNull(osm + " -> " + usr, usr);
     29            assertNotNull(usr, osm + " -> " + usr);
    3730        }
    3831    }
     
    5548     */
    5649    @Test
    57     public void testParseDataSet() throws Exception {
     50    void testParseDataSet() throws Exception {
    5851        doTestMonaco(TestUtils.getTestDataRoot() + "/monaco-latest.osm.pbf", false);
    5952    }
     
    6457     */
    6558    @Test
    66     public void testTicket10132() throws Exception {
     59    void testTicket10132() throws Exception {
    6760        doTestMonaco(TestUtils.getRegressionDataFile(10132, "Monaco-SP.osm.pbf"), true);
    6861    }
     
    7366     */
    7467    @Test
    75     public void testTicket12567() throws Exception {
     68    void testTicket12567() throws Exception {
    7669        DataSet ds = new PbfImporter().parseDataSet(TestUtils.getRegressionDataFile(12567, "12390008.osm.pbf"));
    7770        assertNotNull(ds);
     
    8679     */
    8780    @Test
    88     public void testTicket14545() throws Exception {
     81    void testTicket14545() throws Exception {
    8982        DataSet ds = new PbfImporter().parseDataSet(TestUtils.getRegressionDataFile(14545, "reg14545.osm.pbf"));
    9083        assertNotNull(ds);
  • applications/editors/josm/plugins/pdfimport/test/unit/org/openstreetmap/josm/plugins/pdfimport/pdfbox/PDFParserTest.java

    r34609 r36064  
    22package org.openstreetmap.josm.plugins.pdfimport.pdfbox;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    56
    67import java.awt.Rectangle;
    78import java.io.File;
    89
    9 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
    1011import org.openstreetmap.josm.TestUtils;
    1112import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1213import org.openstreetmap.josm.plugins.pdfimport.PathOptimizer;
    1314
    14 public class PDFParserTest {
     15class PDFParserTest {
    1516
    1617    private PathOptimizer parse(String fileName) throws Exception {
     
    2223
    2324    @Test
    24     public void testParse9053() throws Exception {
     25    void testParse9053() throws Exception {
    2526        PathOptimizer data = parse(TestUtils.getRegressionDataFile(9053, "testpdf.pdf"));
    2627        assertEquals(0, data.bounds.getMinX(), 0);
     
    3334
    3435    @Test
    35     public void testParse12176() throws Exception {
     36    void testParse12176() throws Exception {
    3637        PathOptimizer data = parse(TestUtils.getRegressionDataFile(12176, "LYD_Etage_0.pdf"));
    3738        assertEquals(new Rectangle(595, 842), data.bounds);
  • applications/editors/josm/plugins/poly/test/unit/poly/PolyExporterTest.java

    r34966 r36064  
    22package poly;
    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.nio.file.Files;
    88import java.nio.file.Path;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.api.Timeout;
    1212import org.openstreetmap.josm.TestUtils;
    1313import org.openstreetmap.josm.data.osm.DataSet;
    1414import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    15 import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1616
    1717/**
     
    1919 * @author Gerd Petermann
    2020 */
    21 public class PolyExporterTest {
    22 
    23     /**
    24      * Setup test.
    25      */
    26     @Rule
    27     public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(20000);
    28 
     21@BasicPreferences
     22@Timeout(20)
     23class PolyExporterTest {
    2924    /**
    3025     * Import file, export it, import the exported file and compare content
     
    3227     */
    3328    @Test
    34     public void testSimpleExport() throws Exception {
     29    void testSimpleExport() throws Exception {
    3530        DataSet dsIn1 = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/simple.poly");
    3631        assertNotNull(dsIn1);
     
    5550     */
    5651    @Test
    57     public void testExport() throws Exception {
     52    void testExport() throws Exception {
    5853        DataSet dsIn1 = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/holes.poly");
    5954        assertNotNull(dsIn1);
  • applications/editors/josm/plugins/poly/test/unit/poly/PolyImporterTest.java

    r34860 r36064  
    22package poly;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    77
    8 import org.junit.Rule;
    9 import org.junit.Test;
     8import org.junit.jupiter.api.Test;
    109import org.openstreetmap.josm.TestUtils;
    1110import org.openstreetmap.josm.data.osm.DataSet;
    1211import org.openstreetmap.josm.io.IllegalDataException;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
     12import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1413
    1514/**
     
    1716 * @author Gerd Petermann
    1817 */
    19 public class PolyImporterTest {
    20 
    21     /**
    22      * Setup test.
    23      */
    24     @Rule
    25     public JOSMTestRules rules = new JOSMTestRules().preferences();
    26 
     18@BasicPreferences
     19class PolyImporterTest {
    2720    /**
    2821     * @throws Exception if an error occurs
    2922     */
    3023    @Test
    31     public void testSimple() throws Exception {
     24    void testSimple() throws Exception {
    3225        DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/simple.poly");
    3326        assertNotNull(ds);
     
    4235     */
    4336    @Test
    44     public void testSimple2() throws Exception {
     37    void testSimple2() throws Exception {
    4538        DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/splitter.poly");
    4639        assertNotNull(ds);
     
    5447     */
    5548    @Test
    56     public void testHoles() throws Exception {
     49    void testHoles() throws Exception {
    5750        DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/holes.poly");
    5851        assertNotNull(ds);
     
    6659     */
    6760    @Test
    68     public void testTwoOuter() throws Exception {
     61    void testTwoOuter() throws Exception {
    6962        DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/australia_v.poly");
    7063        assertNotNull(ds);
     
    7871     */
    7972    @Test
    80     public void testDoubleEnd() throws Exception {
     73    void testDoubleEnd() throws Exception {
    8174        DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/bremen-double-end.poly");
    8275        assertNotNull(ds);
     
    9083     */
    9184    @Test
    92     public void testMultipleFile() throws Exception {
     85    void testMultipleFile() throws Exception {
    9386        DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/multi-concat.poly");
    9487        assertNotNull(ds);
     
    10093    /**
    10194     * Should throw an IllegalDataException
    102      * @throws Exception if an error occurs
    10395     */
    104     @Test (expected = IllegalDataException.class)
    105     public void testNameMissing() throws Exception {
    106         DataSet ds = new PolyImporter().parseDataSet(TestUtils.getTestDataRoot() + "/name-missing.poly");
    107         assertNull(ds);
     96    @Test
     97    void testNameMissing() {
     98        final PolyImporter importer = new PolyImporter();
     99        assertThrows(IllegalDataException.class, () -> importer.parseDataSet(TestUtils.getTestDataRoot() + "/name-missing.poly"));
    108100    }
    109101
  • applications/editors/josm/plugins/print/test/unit/org/openstreetmap/josm/plugins/print/PrintDialogTest.java

    r33118 r36064  
    22package org.openstreetmap.josm.plugins.print;
    33
    4 import static org.junit.Assert.assertEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
    56
    67import java.util.Arrays;
     
    89import javax.print.attribute.standard.OrientationRequested;
    910
    10 import org.junit.Ignore;
    11 import org.junit.Rule;
    12 import org.junit.Test;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
     11import org.junit.jupiter.api.Disabled;
     12import org.junit.jupiter.api.Test;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1414
    1515/**
    1616 * Unit test of {@link PrintDialog} class.
    1717 */
    18 public class PrintDialogTest {
    19 
    20     /**
    21      * Setup test.
    22      */
    23     @Rule
    24     public JOSMTestRules rules = new JOSMTestRules().preferences();
    25 
     18@BasicPreferences
     19class PrintDialogTest {
    2620    /**
    2721     * Unit test of {@link PrintDialog#unmarshallPrintSetting}
     
    2923     */
    3024    @Test
    31     public void testUnmarshallPrintSetting() throws ReflectiveOperationException {
     25    void testUnmarshallPrintSetting() throws ReflectiveOperationException {
    3226        assertEquals(OrientationRequested.PORTRAIT, PrintDialog.unmarshallPrintSetting(Arrays.asList(
    3327                "javax.print.attribute.standard.OrientationRequested",
     
    4236     */
    4337    @Test
    44     @Ignore("not fixed yet")
    45     public void testTicket13302() throws ReflectiveOperationException {
     38    @Disabled("not fixed yet")
     39    void testTicket13302() throws ReflectiveOperationException {
    4640        assertEquals(OrientationRequested.PORTRAIT, PrintDialog.unmarshallPrintSetting(Arrays.asList(
    4741                "javax.print.attribute.standard.MediaSizeName",
  • applications/editors/josm/plugins/surveyor/test/unit/org/openstreetmap/josm/plugins/surveyor/SurveyorShowActionTest.java

    r35262 r36064  
    22package org.openstreetmap.josm.plugins.surveyor;
    33
    4 import static org.junit.Assert.assertNotNull;
    5 import static org.junit.Assert.assertTrue;
     4
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    67
    78import java.util.List;
    89
    9 import org.junit.Rule;
    10 import org.junit.Test;
    11 import org.openstreetmap.josm.testutils.JOSMTestRules;
     10import org.junit.jupiter.api.Test;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1212import org.openstreetmap.josm.tools.Logging;
    13 
    14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1513
    1614/**
    1715 * Unit tests of {@link #SurveyorShowAction}
    1816 */
    19 public class SurveyorShowActionTest {
    20 
    21     /**
    22      * Setup rule
    23      */
    24     @Rule
    25     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    26     public JOSMTestRules test = new JOSMTestRules().preferences();
    27 
     17@BasicPreferences
     18class SurveyorShowActionTest {
    2819    @Test
    29     public void testCreateComponent() {
     20    void testCreateComponent() {
    3021        Logging.clearLastErrorAndWarnings();
    3122        SurveyorComponent comp = SurveyorShowAction.createComponent();
    3223        assertNotNull(comp);
    3324        List<String> errors = Logging.getLastErrorAndWarnings();
    34         assertTrue(errors.toString(), errors.isEmpty());
     25        assertTrue(errors.isEmpty(), errors.toString());
    3526    }
    3627}
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/AllUnitTests.java

    r32519 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions;
    33
    4 import org.junit.runner.RunWith;
    5 import org.junit.runners.Suite;
     4import org.junit.platform.suite.api.SelectClasses;
     5import org.junit.platform.suite.api.Suite;
    66import org.openstreetmap.josm.plugins.turnrestrictions.editor.AllEditorTests;
    77
    8 @RunWith(Suite.class)
    9 @Suite.SuiteClasses({
     8@Suite
     9@SelectClasses({
    1010    AllEditorTests.class,
    1111    TurnRestrictionBuilderTest.class
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/TurnRestrictionBuilderTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertNotNull;
    7 import static org.junit.Assert.assertNull;
    8 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertNull;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.intersectionAngle;
    1010import static org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.selectToWayAfterSplit;
     
    1212import java.util.ArrayList;
    1313import java.util.Arrays;
     14import java.util.Collections;
    1415import java.util.List;
    1516import java.util.Optional;
    1617
    17 import org.junit.Rule;
    18 import org.junit.Test;
     18import org.junit.jupiter.api.Test;
    1919import org.openstreetmap.josm.data.coor.LatLon;
    2020import org.openstreetmap.josm.data.osm.Node;
     
    2525import org.openstreetmap.josm.plugins.turnrestrictions.TurnRestrictionBuilder.RelativeWayJoinOrientation;
    2626import org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionType;
    27 import org.openstreetmap.josm.testutils.JOSMTestRules;
    28 
    29 public class TurnRestrictionBuilderTest {
    30 
    31     @Rule
    32     public JOSMTestRules rules = new JOSMTestRules().preferences();
    33 
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     28
     29@BasicPreferences
     30class TurnRestrictionBuilderTest {
    3431    TurnRestrictionBuilder builder = new TurnRestrictionBuilder();
    3532
    3633    boolean hasExactlyOneMemberWithRole(Relation r, final String role) {
    37         return r.getMembers().stream().filter(rm -> role.equals(rm.getRole())).findFirst().isPresent();
     34        return r.getMembers().stream().anyMatch(rm -> role.equals(rm.getRole()));
    3835    }
    3936
    4037    OsmPrimitive memberWithRole(Relation r, final String role) {
    4138        Optional<RelationMember> opt = r.getMembers().stream().filter(rm -> role.equals(rm.getRole())).findFirst();
    42         if (!opt.isPresent())
    43             return null;
    44         return opt.get().getMember();
     39        return opt.map(RelationMember::getMember).orElse(null);
    4540    }
    4641
     
    5752     */
    5853    @Test
    59     public void noUTurn_1() {
     54    void testNoUTurn1() {
    6055        Way w = new Way(1);
    6156        Node n1 = new Node(1);
     
    8479    */
    8580   @Test
    86    public void noUTurn_2() {
     81   void testNoUTurn2() {
    8782       Way w = new Way(1);
    8883       Node n1 = new Node(1);
     
    106101
    107102   @Test
    108    public void nullSelection() {
     103   void testNullSelection() {
    109104       assertEmptyTurnRestriction(builder.build(null));
    110105   }
    111106
    112107   @Test
    113    public void emptySelection() {
     108   void testEmptySelection() {
    114109       assertEmptyTurnRestriction(builder.build(new ArrayList<>()));
    115110   }
     
    120115    */
    121116   @Test
    122    public void oneSelectedWay() {
     117   void testOneSelectedWay() {
    123118       Way w = new Way(1);
    124        Relation tr = builder.build(Arrays.asList(w));
     119       Relation tr = builder.build(Collections.singletonList(w));
    125120       assertNotNull(tr);
    126121       assertEquals("restriction", tr.get("type"));
     
    134129    */
    135130   @Test
    136    public void twoUnconnectedWays() {
     131   void testTwoUnconnectedWays() {
    137132       Way w1 = new Way(1);
    138133       w1.setNodes(Arrays.asList(new Node(11), new Node(12)));
     
    159154    */
    160155   @Test
    161    public void twoConnectedWays_1() {
     156   void testTwoConnectedWays1() {
    162157       Node n1 = new Node(1);
    163158       n1.setCoor(new LatLon(1, 1));
     
    217212    */
    218213   @Test
    219    public void twoConnectedWays_2() {
     214   void testTwoConnectedWays2() {
    220215       Node n1 = new Node(1);
    221216       n1.setCoor(new LatLon(5, 5));
     
    260255
    261256   /**
    262    * Two connected ways. end node of the first way connects to end node of
    263    * the second way. left turn.
    264    *
    265    *
    266    *           (7,5) -
    267    *             ^     -    w2
    268    *             | w1     ------> (6,7)
    269    *             |
    270    *           (5,5)
    271    */
    272   @Test
    273   public void twoConnectedWays_3() {
    274       Node n1 = new Node(1);
    275       n1.setCoor(new LatLon(5, 5));
    276       Node n2 = new Node(2);
    277       n2.setCoor(new LatLon(7, 5));
    278       Node n3 = new Node(3);
    279       n3.setCoor(new LatLon(6, 7));
    280 
    281       Way w1 = new Way(1);
    282       w1.setNodes(Arrays.asList(n1, n2));
    283       Way w2 = new Way(2);
    284       w2.setNodes(Arrays.asList(n2, n3));
    285 
    286       Relation tr = builder.build(Arrays.asList(w1, w2, n2));
    287 
    288       assertNotNull(tr);
    289       assertEquals("restriction", tr.get("type"));
    290       assertEquals(3, tr.getMembersCount());
    291       assertEquals(w1, memberWithRole(tr, "from"));
    292       assertEquals(w2, memberWithRole(tr, "to"));
    293       assertEquals(n2, memberWithRole(tr, "via"));
    294 
    295       assertEquals("no_right_turn", tr.get("restriction"));
    296   }
    297 
    298   /**
    299   * Two connected ways. end node of the first way connects to end node of
    300   * the second way. left turn.
    301   *
    302   *
    303   *           (10,10)
    304   *                 \
    305   *                  \
    306   *                   \
    307   *                    v
    308   *                     (8,15)
    309   *                    /
    310   *                   /
    311   *                  /
    312   *                 v
    313   *            (5,11)
    314   */
    315  @Test
    316  public void twoConnectedWays_4() {
    317      Node n1 = new Node(1);
    318      n1.setCoor(new LatLon(10, 10));
    319      Node n2 = new Node(2);
    320      n2.setCoor(new LatLon(8, 15));
    321      Node n3 = new Node(3);
    322      n3.setCoor(new LatLon(5, 11));
    323 
    324      Way w1 = new Way(1);
    325      w1.setNodes(Arrays.asList(n1, n2));
    326      Way w2 = new Way(2);
    327      w2.setNodes(Arrays.asList(n2, n3));
    328 
    329      Relation tr = builder.build(Arrays.asList(w1, w2, n2));
    330 
    331      assertNotNull(tr);
    332      assertEquals("restriction", tr.get("type"));
    333      assertEquals(3, tr.getMembersCount());
    334      assertEquals(w1, memberWithRole(tr, "from"));
    335      assertEquals(w2, memberWithRole(tr, "to"));
    336      assertEquals(n2, memberWithRole(tr, "via"));
    337 
    338      assertEquals("no_right_turn", tr.get("restriction"));
    339 
    340      /*
    341       * opposite order, from w2 to w1. In  this case we have left turn.
    342       */
    343      tr = builder.build(Arrays.asList(w2, w1, n2));
    344 
    345      assertNotNull(tr);
    346      assertEquals("restriction", tr.get("type"));
    347      assertEquals(3, tr.getMembersCount());
    348      assertEquals(w2, memberWithRole(tr, "from"));
    349      assertEquals(w1, memberWithRole(tr, "to"));
    350      assertEquals(n2, memberWithRole(tr, "via"));
    351 
    352      assertEquals("no_left_turn", tr.get("restriction"));
     257    * Two connected ways. end node of the first way connects to end node of
     258    * the second way. left turn.
     259    *
     260    *           (7,5) -
     261    *             ^     -    w2
     262    *             | w1     ------> (6,7)
     263    *             |
     264    *           (5,5)
     265    */
     266    @Test
     267    void testTwoConnectedWays3() {
     268        Node n1 = new Node(1);
     269        n1.setCoor(new LatLon(5, 5));
     270        Node n2 = new Node(2);
     271        n2.setCoor(new LatLon(7, 5));
     272        Node n3 = new Node(3);
     273        n3.setCoor(new LatLon(6, 7));
     274
     275        Way w1 = new Way(1);
     276        w1.setNodes(Arrays.asList(n1, n2));
     277        Way w2 = new Way(2);
     278        w2.setNodes(Arrays.asList(n2, n3));
     279
     280        Relation tr = builder.build(Arrays.asList(w1, w2, n2));
     281
     282        assertNotNull(tr);
     283        assertEquals("restriction", tr.get("type"));
     284        assertEquals(3, tr.getMembersCount());
     285        assertEquals(w1, memberWithRole(tr, "from"));
     286        assertEquals(w2, memberWithRole(tr, "to"));
     287        assertEquals(n2, memberWithRole(tr, "via"));
     288
     289        assertEquals("no_right_turn", tr.get("restriction"));
     290    }
     291
     292    /**
     293     * Two connected ways. end node of the first way connects to end node of
     294     * the second way. left turn.
     295     *
     296     *           (10,10)
     297     *                 \
     298     *                  \
     299     *                   \
     300     *                    v
     301     *                     (8,15)
     302     *                    /
     303     *                   /
     304     *                  /
     305     *                 v
     306     *            (5,11)
     307     */
     308    @Test
     309    void testTwoConnectedWays4() {
     310        Node n1 = new Node(1);
     311        n1.setCoor(new LatLon(10, 10));
     312        Node n2 = new Node(2);
     313        n2.setCoor(new LatLon(8, 15));
     314        Node n3 = new Node(3);
     315        n3.setCoor(new LatLon(5, 11));
     316
     317        Way w1 = new Way(1);
     318        w1.setNodes(Arrays.asList(n1, n2));
     319        Way w2 = new Way(2);
     320        w2.setNodes(Arrays.asList(n2, n3));
     321
     322        Relation tr = builder.build(Arrays.asList(w1, w2, n2));
     323
     324        assertNotNull(tr);
     325        assertEquals("restriction", tr.get("type"));
     326        assertEquals(3, tr.getMembersCount());
     327        assertEquals(w1, memberWithRole(tr, "from"));
     328        assertEquals(w2, memberWithRole(tr, "to"));
     329        assertEquals(n2, memberWithRole(tr, "via"));
     330
     331        assertEquals("no_right_turn", tr.get("restriction"));
     332
     333        /*
     334         * opposite order, from w2 to w1. In  this case we have left turn.
     335         */
     336        tr = builder.build(Arrays.asList(w2, w1, n2));
     337
     338        assertNotNull(tr);
     339        assertEquals("restriction", tr.get("type"));
     340        assertEquals(3, tr.getMembersCount());
     341        assertEquals(w2, memberWithRole(tr, "from"));
     342        assertEquals(w1, memberWithRole(tr, "to"));
     343        assertEquals(n2, memberWithRole(tr, "via"));
     344
     345        assertEquals("no_left_turn", tr.get("restriction"));
    353346    }
    354347
     
    374367      */
    375368     @Test
    376      public void intersectionAngle_1() {
     369     void testIntersectionAngle1() {
    377370         Node n1 = nn(1, 5, 5);
    378371         Node n2 = nn(2, 5, 10);
     
    429422     */
    430423    @Test
    431     public void intersectionAngle_2() {
     424    void testIntersectionAngle2() {
    432425        Node n1 = nn(1, 5, 5);
    433426        Node n2 = nn(2, 5, 10);
     
    473466     *          /
    474467     *      (-5, -10) n2
    475     *           ^
    476     *           |
    477     *           | from
    478     *           |
    479     *       (-10,-10) n1
    480     */
    481    @Test
    482    public void intersectionAngle_3() {
    483        Node n1 = nn(1, -10, -10);
    484        Node n2 = nn(2, -5, -10);
    485        Node n3 = nn(3, -1, -6);
    486        Way from = nw(1, n1, n2);
    487        Way to = nw(2, n2, n3);
    488 
    489        double a = TurnRestrictionBuilder.intersectionAngle(from, to);
    490        assertEquals(45, Math.toDegrees(a), 1e-7);
    491 
    492        /*
    493         * if reversed from, the intersection angle is still 45
    494         */
    495        from = nw(1, n2, n1);
    496        to = nw(2, n2, n3);
    497        a = TurnRestrictionBuilder.intersectionAngle(from, to);
    498        assertEquals(45, Math.toDegrees(a), 1e-7);
    499 
    500        /*
    501        * if reversed to, the intersection angle is still 45
    502        */
    503        from = nw(1, n1, n2);
    504        to = nw(2, n3, n2);
    505        a = TurnRestrictionBuilder.intersectionAngle(from, to);
    506        assertEquals(45, Math.toDegrees(a), 1e-7);
    507 
    508        /*
    509        * if reversed both, the intersection angle is still 45
    510        */
    511        from = nw(1, n2, n1);
    512        to = nw(2, n3, n2);
    513        a = TurnRestrictionBuilder.intersectionAngle(from, to);
    514        assertEquals(45, Math.toDegrees(a), 1e-7);
    515    }
    516 
    517    /**
    518    *
    519    *
    520    *         (-1,-14) (n3)
    521    *            ^
    522    *            \
    523    *             \ to
    524    *              \
    525    *          (-5, -10) n2
    526   *               ^
    527   *               |
    528   *               | from
    529   *               |
    530   *           (-10,-10) n1
    531   */
    532  @Test
    533  public void intersectionAngle_4() {
    534      Node n1 = nn(1, -10, -10);
    535      Node n2 = nn(2, -5, -10);
    536      Node n3 = nn(3, -1, -14);
    537      Way from = nw(1, n1, n2);
    538      Way to = nw(2, n2, n3);
    539 
    540      double a = TurnRestrictionBuilder.intersectionAngle(from, to);
    541      assertEquals(-45, Math.toDegrees(a), 1e-7);
    542 
    543      /*
    544       * if reversed from, the intersection angle is still -45
    545       */
    546      from = nw(1, n2, n1);
    547      to = nw(2, n2, n3);
    548      a = TurnRestrictionBuilder.intersectionAngle(from, to);
    549      assertEquals(-45, Math.toDegrees(a), 1e-7);
    550 
    551      /*
    552      * if reversed to, the intersection angle is still -45
     468     *           ^
     469     *           |
     470     *           | from
     471     *           |
     472     *       (-10,-10) n1
    553473     */
    554      from = nw(1, n1, n2);
    555      to = nw(2, n3, n2);
    556      a = TurnRestrictionBuilder.intersectionAngle(from, to);
    557      assertEquals(-45, Math.toDegrees(a), 1e-7);
    558 
    559      /*
    560      * if reversed both, the intersection angle is still 45
     474    @Test
     475    void testIntersectionAngle3() {
     476        Node n1 = nn(1, -10, -10);
     477        Node n2 = nn(2, -5, -10);
     478        Node n3 = nn(3, -1, -6);
     479        Way from = nw(1, n1, n2);
     480        Way to = nw(2, n2, n3);
     481
     482        double a = TurnRestrictionBuilder.intersectionAngle(from, to);
     483        assertEquals(45, Math.toDegrees(a), 1e-7);
     484
     485        /*
     486         * if reversed from, the intersection angle is still 45
     487         */
     488        from = nw(1, n2, n1);
     489        to = nw(2, n2, n3);
     490        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     491        assertEquals(45, Math.toDegrees(a), 1e-7);
     492
     493        /*
     494        * if reversed to, the intersection angle is still 45
     495        */
     496        from = nw(1, n1, n2);
     497        to = nw(2, n3, n2);
     498        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     499        assertEquals(45, Math.toDegrees(a), 1e-7);
     500
     501        /*
     502        * if reversed both, the intersection angle is still 45
     503        */
     504        from = nw(1, n2, n1);
     505        to = nw(2, n3, n2);
     506        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     507        assertEquals(45, Math.toDegrees(a), 1e-7);
     508    }
     509
     510    /**
     511     *
     512     *
     513     *         (-1,-14) (n3)
     514     *            ^
     515     *            \
     516     *             \ to
     517     *              \
     518     *          (-5, -10) n2
     519     *               ^
     520     *               |
     521     *               | from
     522     *               |
     523     *           (-10,-10) n1
    561524     */
    562      from = nw(1, n2, n1);
    563      to = nw(2, n3, n2);
    564      a = TurnRestrictionBuilder.intersectionAngle(from, to);
    565      assertEquals(-45, Math.toDegrees(a), 1e-7);
    566  }
    567 
    568 
    569      /*
     525    @Test
     526    void testIntersectionAngle4() {
     527        Node n1 = nn(1, -10, -10);
     528        Node n2 = nn(2, -5, -10);
     529        Node n3 = nn(3, -1, -14);
     530        Way from = nw(1, n1, n2);
     531        Way to = nw(2, n2, n3);
     532
     533        double a = TurnRestrictionBuilder.intersectionAngle(from, to);
     534        assertEquals(-45, Math.toDegrees(a), 1e-7);
     535
     536        /*
     537         * if reversed from, the intersection angle is still -45
     538         */
     539        from = nw(1, n2, n1);
     540        to = nw(2, n2, n3);
     541        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     542        assertEquals(-45, Math.toDegrees(a), 1e-7);
     543
     544        /*
     545        * if reversed to, the intersection angle is still -45
     546        */
     547        from = nw(1, n1, n2);
     548        to = nw(2, n3, n2);
     549        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     550        assertEquals(-45, Math.toDegrees(a), 1e-7);
     551
     552        /*
     553        * if reversed both, the intersection angle is still 45
     554        */
     555        from = nw(1, n2, n1);
     556        to = nw(2, n3, n2);
     557        a = TurnRestrictionBuilder.intersectionAngle(from, to);
     558        assertEquals(-45, Math.toDegrees(a), 1e-7);
     559    }
     560
     561    /**
    570562     *
    571563     *      n21        w21        n22       w22            n23
     
    579571     */
    580572    @Test
    581     public void splitToWay() {
     573    void testSplitToWay() {
    582574        Node n11 = new Node(11);
    583575        n11.setCoor(new LatLon(5, 15));
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/AllEditorTests.java

    r32519 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import org.junit.runner.RunWith;
    5 import org.junit.runners.Suite;
     4import org.junit.platform.suite.api.SelectClasses;
    65
    76import junit.framework.TestCase;
     7import org.junit.platform.suite.api.Suite;
    88
    9 @RunWith(Suite.class)
    10 @Suite.SuiteClasses({
     9@Suite
     10@SelectClasses({
    1111    JosmSelectionListModelTest.class,
    1212    TurnRestrictionEditorModelUnitTest.class,
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/BasicEditorPanelTest.java

    r32519 r36064  
    77import javax.swing.JFrame;
    88
    9 import org.junit.Ignore;
     9import org.junit.jupiter.api.Disabled;
    1010import org.openstreetmap.josm.data.osm.DataSet;
    1111import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1515 *
    1616 */
    17 @Ignore("no test")
     17@Disabled("no test")
    1818public class BasicEditorPanelTest extends JFrame {
    1919
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ExceptValueModelTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    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.assertAll;
     5import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
     6import static org.junit.jupiter.api.Assertions.assertEquals;
     7import static org.junit.jupiter.api.Assertions.assertFalse;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    79
    8 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.params.ParameterizedTest;
     12import org.junit.jupiter.params.provider.ValueSource;
    913
    10 public class ExceptValueModelTest {
     14class ExceptValueModelTest {
    1115
    12     @Test
    13     public void testConstructors() {
    14         new ExceptValueModel();
    15         new ExceptValueModel(null);
    16         new ExceptValueModel("");
    17         new ExceptValueModel("  ");
    18         new ExceptValueModel("hgv");
    19         new ExceptValueModel("hgv;psv");
    20         new ExceptValueModel("non_standard");
     16    @ParameterizedTest
     17    @ValueSource(strings = {"", "  ", "hgv", "hgv;psv", "non_standard"})
     18    void testStringConstructors(String value) {
     19        assertDoesNotThrow(() -> new ExceptValueModel(value));
    2120    }
    2221
    2322    @Test
    24     public void testSetValue() {
     23    void testAdditionalConstructors() {
     24        assertAll(() -> assertDoesNotThrow(() -> new ExceptValueModel()),
     25                () -> assertDoesNotThrow(() -> new ExceptValueModel(null)));
     26    }
     27
     28    @Test
     29    void testSetValue() {
    2530        ExceptValueModel evm;
    2631
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/JosmSelectionListModelTest.java

    r33847 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    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.assertDoesNotThrow;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    79
    810import java.util.ArrayList;
     
    1416import javax.swing.ListSelectionModel;
    1517
    16 import org.junit.Rule;
    17 import org.junit.Test;
     18import org.junit.jupiter.api.Test;
    1819import org.openstreetmap.josm.data.coor.LatLon;
    1920import org.openstreetmap.josm.data.osm.DataSet;
     
    2425import org.openstreetmap.josm.gui.MainApplication;
    2526import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    26 import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2728
    2829/**
    2930 * Unit test for {@see JosmSelctionListModel}
    3031 */
    31 public class JosmSelectionListModelTest {
    32 
    33     @Rule
    34     public JOSMTestRules rules = new JOSMTestRules().preferences();
     32@BasicPreferences
     33class JosmSelectionListModelTest {
    3534
    3635    @Test
    37     public void testConstructor() {
    38         assertNotNull(new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null)));
    39     }
    40 
    41     @Test(expected = IllegalArgumentException.class)
    42     public void testConstructorNull() {
    43         new JosmSelectionListModel(null);
     36    void testConstructor() {
     37        OsmDataLayer layer = new OsmDataLayer(new DataSet(), "test", null);
     38        assertDoesNotThrow(() -> new JosmSelectionListModel(layer));
    4439    }
    4540
    4641    @Test
    47     public void test_setJOSMSelection() {
     42    void testConstructorNull() {
     43        assertThrows(IllegalArgumentException.class, () -> new JosmSelectionListModel(null));
     44    }
     45
     46    @Test
     47    void testSetJOSMSelection() {
    4848        DataSet ds = new DataSet();
    4949        OsmDataLayer layer = new OsmDataLayer(ds, "test", null);
     
    6666
    6767    @Test
    68     public void test_setJOSMSelection_withSelected() {
     68    void testSetJOSMSelectionWithSelected() {
    6969        DataSet ds = new DataSet();
    7070        OsmDataLayer layer = new OsmDataLayer(ds, "test", null);
     
    8484
    8585    @Test
    86     public void test_getSelected() {
     86    void testGetSelected() {
    8787        DataSet ds = new DataSet();
    8888        OsmDataLayer layer = new OsmDataLayer(ds, "test", null);
     
    105105
    106106    @Test
    107     public void test_setSelected() {
     107    void testSetSelected() {
    108108        // set selected with null is OK - nothing selected thereafter
    109109        JosmSelectionListModel model = new JosmSelectionListModel(new OsmDataLayer(new DataSet(), "test", null));
     
    118118        List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation()));
    119119        model.setJOSMSelection(objects);
    120         model.setSelected(Arrays.asList(objects.get(0)));
     120        model.setSelected(Collections.singletonList(objects.get(0)));
    121121        assertEquals(Collections.singleton(objects.get(0)), model.getSelected());
    122122
    123123        // select an object not-existing in the list of displayed objects
    124124        model.setJOSMSelection(objects);
    125         model.setSelected(Arrays.asList(new Way()));
     125        model.setSelected(Collections.singletonList(new Way()));
    126126        assertTrue(model.getSelected().isEmpty());
    127127    }
    128128
    129129    @Test
    130     public void test_editLayerChanged() {
     130    void testEditLayerChanged() {
    131131        DataSet ds = new DataSet();
    132132
    133133        List<OsmPrimitive> objects = (Arrays.asList(new Node(new LatLon(1, 1)), new Way(), new Relation()));
    134         objects.stream().forEach(ds::addPrimitive);
     134        objects.forEach(ds::addPrimitive);
    135135
    136136        OsmDataLayer layer1 = new OsmDataLayer(ds, "layer1", null);
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionComboBoxTest.java

    r32519 r36064  
    88import javax.swing.JFrame;
    99
    10 import org.junit.Ignore;
     10import org.junit.jupiter.api.Disabled;
    1111import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1717 *
    1818 */
    19 @Ignore("no test")
     19@Disabled("no test")
    2020public class TurnRestrictionComboBoxTest extends JFrame {
    2121
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorModelUnitTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertTrue;
    7 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.assertThrows;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8import static org.junit.jupiter.api.Assertions.fail;
    89import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.FROM;
    910import static org.openstreetmap.josm.plugins.turnrestrictions.editor.TurnRestrictionLegRole.TO;
     
    1314import java.util.Collections;
    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;
    1818import org.openstreetmap.josm.data.coor.LatLon;
    1919import org.openstreetmap.josm.data.osm.DataSet;
     
    2121import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2222import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     23import org.openstreetmap.josm.data.osm.PrimitiveId;
    2324import org.openstreetmap.josm.data.osm.Relation;
    2425import org.openstreetmap.josm.data.osm.RelationMember;
     
    2627import org.openstreetmap.josm.data.osm.Way;
    2728import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    28 import org.openstreetmap.josm.testutils.JOSMTestRules;
     29import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2930
    3031/**
    3132 * This is a unit test for {@link TurnRestrictionEditorModel}
    3233 */
    33 public class TurnRestrictionEditorModelUnitTest {
    34 
    35     @Rule
    36     public JOSMTestRules rules = new JOSMTestRules().preferences();
     34@BasicPreferences
     35class TurnRestrictionEditorModelUnitTest {
    3736
    3837    private final NavigationControler navigationControlerMock = new NavigationControler() {
     
    114113    }
    115114
    116     @Before
     115    @BeforeEach
    117116    public void setUp() {
    118117        ds = new DataSet();
     
    124123     * Test the constructor
    125124     */
    126     @Test(expected = IllegalArgumentException.class)
    127     public void testConstructor1() {
    128         new TurnRestrictionEditorModel(null, navigationControlerMock);
     125    @Test
     126    void testConstructor1() {
     127        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(null, navigationControlerMock));
    129128    }
    130129
     
    132131     * Test the constructor
    133132     */
    134     @Test(expected = IllegalArgumentException.class)
    135     public void testConstructor2() {
    136         new TurnRestrictionEditorModel(layer, null);
    137     }
    138 
    139     @Test
    140     public void testPopulateEmptyTurnRestriction() {
     133    @Test
     134    void testConstructor2() {
     135        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionEditorModel(layer, null));
     136    }
     137
     138    @Test
     139    void testPopulateEmptyTurnRestriction() {
    141140        // an "empty" turn restriction with a public id
    142141        Relation r = new Relation(1);
     
    156155     */
    157156    @Test
    158     public void test_populate_SimpleStandardTurnRestriction() {
     157    void testPopulateSimpleStandardTurnRestriction() {
    159158        buildDataSet1();
    160159        model.populate(rel(1));
     
    162161        assertEquals(Collections.singleton(way(2)), model.getTurnRestrictionLeg(FROM));
    163162        assertEquals(Collections.singleton(way(3)), model.getTurnRestrictionLeg(TO));
    164         assertEquals(Arrays.asList(node(22)), model.getVias());
     163        assertEquals(Collections.singletonList(node(22)), model.getVias());
    165164        assertEquals("no_left_turn", model.getRestrictionTagValue());
    166165        assertEquals("", model.getExcept().getValue());
     
    168167
    169168    @Test
    170     public void setFrom() {
     169    void testSetFrom() {
    171170        buildDataSet1();
    172171        model.populate(rel(1));
     
    178177        // set another way as from
    179178        model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way(4).getPrimitiveId());
    180         assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TurnRestrictionLegRole.FROM));
     179        assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(FROM));
    181180
    182181        // delete the/all members with role 'from'
    183182        model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, null);
    184         assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.FROM).isEmpty());
    185 
    186         try {
    187             // can't add a node as 'from'
    188             model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node(21).getPrimitiveId());
    189             fail();
    190         } catch (IllegalArgumentException e) {
    191             // OK
    192             System.out.println(e.getMessage());
    193         }
    194 
    195         try {
    196             // can't set a way as 'from' if it isn't part of the dataset
    197             model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, new Way().getPrimitiveId());
    198             fail();
    199         } catch (IllegalStateException e) {
    200             // OK
    201             System.out.println(e.getMessage());
    202         }
    203     }
    204 
    205     @Test
    206     public void setTo() {
     183        assertTrue(model.getTurnRestrictionLeg(FROM).isEmpty());
     184
     185        // can't add a node as 'from'
     186        PrimitiveId node = node(21).getPrimitiveId();
     187        assertThrows(IllegalArgumentException.class,
     188                () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, node));
     189
     190        // can't set a way as 'from' if it isn't part of the dataset
     191        PrimitiveId way = new Way().getPrimitiveId();
     192        assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.FROM, way));
     193    }
     194
     195    @Test
     196    void setTo() {
    207197        buildDataSet1();
    208198        model.populate(rel(1));
     
    214204        // set another way as from
    215205        model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way(4).getPrimitiveId());
    216         assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TurnRestrictionLegRole.TO));
     206        assertEquals(Collections.singleton(way(4)), model.getTurnRestrictionLeg(TO));
    217207
    218208        // delete the/all members with role 'from'
    219209        model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, null);
    220         assertTrue(model.getTurnRestrictionLeg(TurnRestrictionLegRole.TO).isEmpty());
    221 
    222         try {
    223             // can't add a node as 'from'
    224             model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node(21).getPrimitiveId());
    225             fail();
    226         } catch (IllegalArgumentException e) {
    227             // OK
    228             System.out.println(e.getMessage());
    229         }
    230 
    231         try {
    232             // can't set a way as 'from' if it isn't part of the dataset
    233             model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, new Way().getPrimitiveId());
    234             fail();
    235         } catch (IllegalStateException e) {
    236             // OK
    237             System.out.println(e.getMessage());
    238         }
     210        assertTrue(model.getTurnRestrictionLeg(TO).isEmpty());
     211
     212        PrimitiveId node = node(21).getPrimitiveId();
     213        assertThrows(IllegalArgumentException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, node));
     214
     215        PrimitiveId way = new Way().getPrimitiveId();
     216        assertThrows(IllegalStateException.class, () -> model.setTurnRestrictionLeg(TurnRestrictionLegRole.TO, way));
    239217    }
    240218
     
    269247
    270248        // one node as via - OK
    271         model.setVias(Arrays.asList(node(22)));
    272         assertEquals(Arrays.asList(node(22)), model.getVias());
     249        model.setVias(Collections.singletonList(node(22)));
     250        assertEquals(Collections.singletonList(node(22)), model.getVias());
    273251
    274252        // pass in null as vias -> remove all vias
     
    291269        // null values in the list of vias are skipped
    292270        model.setVias(Arrays.asList(null, node(22)));
    293         assertEquals(Arrays.asList(node(22)), model.getVias());
     271        assertEquals(Collections.singletonList(node(22)), model.getVias());
    294272
    295273        try {
    296274            // an object which doesn't belong to the same dataset can't be a via
    297             model.setVias(Arrays.asList(new Node(LatLon.ZERO)));
     275            model.setVias(Collections.singletonList(new Node(LatLon.ZERO)));
    298276            fail();
    299277        } catch (IllegalArgumentException e) {
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionEditorTest.java

    r32519 r36064  
    44import javax.swing.JFrame;
    55
    6 import org.junit.Ignore;
     6import org.junit.jupiter.api.Disabled;
    77import org.openstreetmap.josm.data.osm.DataSet;
    88import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1111 *
    1212 */
    13 @Ignore("no test")
     13@Disabled("no test")
    1414public class TurnRestrictionEditorTest extends JFrame {
    1515
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorTest.java

    r34148 r36064  
    1717import javax.swing.JScrollPane;
    1818
    19 import org.junit.Ignore;
     19import org.junit.jupiter.api.Disabled;
    2020import org.openstreetmap.josm.data.coor.LatLon;
    2121import org.openstreetmap.josm.data.osm.DataSet;
     
    3434 * {@see TurnRestrictionLegEditor}
    3535 */
    36 @Ignore("no test")
     36@Disabled("no test")
    3737public class TurnRestrictionLegEditorTest extends JFrame {
    3838
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionLegEditorUnitTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    54
    6 import org.junit.Before;
    7 import org.junit.Rule;
    8 import org.junit.Test;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
     7
     8import org.junit.jupiter.api.BeforeEach;
     9import org.junit.jupiter.api.Test;
    910import org.openstreetmap.josm.data.osm.DataSet;
    1011import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    11 import org.openstreetmap.josm.testutils.JOSMTestRules;
     12import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1213
    1314/**
    1415 * Unit test for the {@link TurnRestrictionLegEditor}
    1516 */
    16 public class TurnRestrictionLegEditorUnitTest {
    17 
    18     @Rule
    19     public JOSMTestRules rules = new JOSMTestRules().preferences();
    20 
     17@BasicPreferences
     18class TurnRestrictionLegEditorUnitTest {
    2119    private DataSet ds;
    2220    private OsmDataLayer layer;
    2321    private TurnRestrictionEditorModel model;
    2422
    25     @Before
     23    @BeforeEach
    2624    public void setUp() {
    2725        ds = new DataSet();
     
    4341
    4442    @Test
    45     public void testConstructor1() {
     43    void testConstructor1() {
    4644        TurnRestrictionLegEditor editor = new TurnRestrictionLegEditor(model, TurnRestrictionLegRole.FROM);
    4745        assertEquals(model, editor.getModel());
     
    4947    }
    5048
    51     @Test(expected = IllegalArgumentException.class)
    52     public void testConstructor2() {
    53         new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM);
     49    @Test
     50    void testConstructor2() {
     51        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(null, TurnRestrictionLegRole.FROM));
    5452    }
    5553
    56     @Test(expected = IllegalArgumentException.class)
    57     public void testConstructor3() {
    58         new TurnRestrictionLegEditor(model, null);
     54    @Test
     55    void testConstructor3() {
     56        assertThrows(IllegalArgumentException.class, () -> new TurnRestrictionLegEditor(model, null));
    5957    }
    6058}
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeRendererTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    77
    88import javax.swing.JLabel;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
    12 import org.openstreetmap.josm.testutils.JOSMTestRules;
     10import org.junit.jupiter.api.Test;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1312
    14 public class TurnRestrictionTypeRendererTest {
    15 
    16     @Rule
    17     public JOSMTestRules rules = new JOSMTestRules().preferences();
    18 
     13@BasicPreferences
     14class TurnRestrictionTypeRendererTest {
    1915    @Test
    20     public void test_Constructor() {
     16    void testConstructor() {
    2117        TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer();
    2218
     
    2622
    2723    @Test
    28     public void test_getListCellRendererComponent_1() {
     24    void testGetListCellRendererComponent1() {
    2925        TurnRestrictionTypeRenderer renderer = new TurnRestrictionTypeRenderer();
    3026
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/TurnRestrictionTypeTest.java

    r32925 r36064  
    22package org.openstreetmap.josm.plugins.turnrestrictions.editor;
    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
    7 import org.junit.Test;
     7import org.junit.jupiter.api.Test;
    88
    9 public class TurnRestrictionTypeTest {
     9
     10class TurnRestrictionTypeTest {
    1011
    1112    @Test
    12     public void test_fromTagValue() {
     13    void testFromTagValue() {
    1314
    1415        TurnRestrictionType type = TurnRestrictionType.fromTagValue("no_left_turn");
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/VehicleExceptionEditorTest.java

    r32519 r36064  
    77import javax.swing.JFrame;
    88
    9 import org.junit.Ignore;
     9import org.junit.jupiter.api.Disabled;
    1010import org.openstreetmap.josm.data.osm.DataSet;
    1111import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    1616 *
    1717 */
    18 @Ignore("no test")
     18@Disabled("no test")
    1919public class VehicleExceptionEditorTest extends JFrame {
    2020    TurnRestrictionEditorModel model;
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/ViaListTest.java

    r32519 r36064  
    1111import javax.swing.JList;
    1212
    13 import org.junit.Ignore;
     13import org.junit.jupiter.api.Disabled;
    1414import org.openstreetmap.josm.data.coor.LatLon;
    1515import org.openstreetmap.josm.data.osm.DataSet;
     
    2323 *
    2424 */
    25 @Ignore("no test")
     25@Disabled("no test")
    2626public class ViaListTest extends JFrame {
    2727
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/qa/IssuesViewTest.java

    r32519 r36064  
    1111import javax.swing.JScrollPane;
    1212
    13 import org.junit.Ignore;
     13import org.junit.jupiter.api.Disabled;
    1414import org.openstreetmap.josm.data.osm.DataSet;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    2020 * Simple test application for layout and functionality of the issues view.
    2121 */
    22 @Ignore("no test")
     22@Disabled("no test")
    2323public class IssuesViewTest extends JFrame {
    2424    private IssuesModel model;
Note: See TracChangeset for help on using the changeset viewer.