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

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

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

Location:
trunk/test/unit/org/openstreetmap/josm/gui/datatransfer
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/ClipboardUtilsTest.java

    r16182 r17275  
    22package org.openstreetmap.josm.gui.datatransfer;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
    7 import static org.junit.Assert.assertSame;
    8 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertSame;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99import static org.junit.Assume.assumeTrue;
    1010
     
    1717import java.io.IOException;
    1818
    19 import org.junit.Rule;
    20 import org.junit.Test;
     19import org.junit.jupiter.api.extension.RegisterExtension;
     20import org.junit.jupiter.api.Test;
    2121import org.openstreetmap.josm.testutils.JOSMTestRules;
    2222
     
    2828 * @author Michael Zangl
    2929 */
    30 public class ClipboardUtilsTest {
     30class ClipboardUtilsTest {
    3131    private static final class ThrowIllegalStateClipboard extends Clipboard {
    3232        private int failingAccesses = 3;
     
    7070     * No dependencies
    7171     */
    72     @Rule
     72    @RegisterExtension
    7373    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    7474    public JOSMTestRules test = new JOSMTestRules();
     
    7878     */
    7979    @Test
    80     public void testGetClipboard() {
     80    void testGetClipboard() {
    8181        Clipboard c = ClipboardUtils.getClipboard();
    8282        assertNotNull(c);
     
    8888     */
    8989    @Test
    90     public void testCopyPasteString() {
     90    void testCopyPasteString() {
    9191        ClipboardUtils.copyString("");
    9292        assertEquals("", ClipboardUtils.getClipboardStringContent());
     
    102102     */
    103103    @Test
    104     public void testGetContentIllegalState() {
     104    void testGetContentIllegalState() {
    105105        ThrowIllegalStateClipboard throwingClipboard = new ThrowIllegalStateClipboard("test");
    106106
     
    118118     */
    119119    @Test
    120     public void testSystemSelectionDoesNotFail() {
     120    void testSystemSelectionDoesNotFail() {
    121121        assumeTrue(GraphicsEnvironment.isHeadless());
    122122        assertNull(ClipboardUtils.getSystemSelection());
     
    128128     */
    129129    @Test
    130     public void testUtilityClass() throws ReflectiveOperationException {
     130    void testUtilityClass() throws ReflectiveOperationException {
    131131        UtilityClassTestUtil.assertUtilityClassWellDefined(ClipboardUtils.class);
    132132    }
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/LayerTransferableTest.java

    r10605 r17275  
    22package org.openstreetmap.josm.gui.datatransfer;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertSame;
    7 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertSame;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
     8import static org.junit.jupiter.api.Assertions.assertThrows;
    89
    910import java.awt.datatransfer.DataFlavor;
     
    1112import java.util.Arrays;
    1213
    13 import org.junit.Before;
    14 import org.junit.Test;
     14import org.junit.jupiter.api.BeforeEach;
     15import org.junit.jupiter.api.Test;
    1516import org.openstreetmap.josm.gui.datatransfer.LayerTransferable.Data;
    1617import org.openstreetmap.josm.gui.layer.Layer;
     
    2425 * @since 10605
    2526 */
    26 public class LayerTransferableTest {
     27class LayerTransferableTest {
    2728    private TestLayer layer1;
    2829    private TestLayer layer2;
     
    3233     * Set up test data
    3334     */
    34     @Before
     35    @BeforeEach
    3536    public void createTestData() {
    3637        layer1 = new LayerManagerTest.TestLayer();
     
    4546     */
    4647    @Test
    47     public void testLayerData() {
     48    void testLayerData() {
    4849        Data data = new Data(manager, Arrays.<Layer>asList(layer1, layer2));
    4950
     
    5960     */
    6061    @Test
    61     public void testSupportedDataFlavor() {
     62    void testSupportedDataFlavor() {
    6263        LayerTransferable transferable = new LayerTransferable(manager, Arrays.<Layer>asList(layer1, layer2));
    6364
     
    7576     */
    7677    @Test
    77     public void testTransferData() throws Exception {
     78    void testTransferData() throws Exception {
    7879        LayerTransferable transferable = new LayerTransferable(manager, Arrays.<Layer>asList(layer1, layer2));
    7980
     
    8889    /**
    8990     * Test {@link LayerTransferable#getTransferData(DataFlavor)} for unsupported {@link DataFlavor}
    90      * @throws Exception if any error occurs
    9191     */
    92     @Test(expected = UnsupportedFlavorException.class)
    93     public void testTransferDataUnsupported() throws Exception {
     92    @Test
     93    void testTransferDataUnsupported() {
    9494        LayerTransferable transferable = new LayerTransferable(manager, Arrays.<Layer>asList(layer1, layer2));
    9595
    96         transferable.getTransferData(DataFlavor.imageFlavor);
     96        assertThrows(UnsupportedFlavorException.class, () -> transferable.getTransferData(DataFlavor.imageFlavor));
    9797    }
    9898}
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java

    r14138 r17275  
    22package org.openstreetmap.josm.gui.datatransfer;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    77import java.util.Collections;
    88
    9 import org.junit.Rule;
    10 import org.junit.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
     10import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.actions.CopyAction;
    1212import org.openstreetmap.josm.data.coor.LatLon;
     
    2323 * Unit tests of {@link OsmTransferHandler} class.
    2424 */
    25 public class OsmTransferHandlerTest {
     25class OsmTransferHandlerTest {
    2626    /**
    2727     * Prefs to use OSM primitives
    2828     */
    29     @Rule
     29    @RegisterExtension
    3030    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3131    public JOSMTestRules test = new JOSMTestRules().preferences().projection().main();
     
    3737     */
    3838    @Test
    39     public void testPasteOn() {
     39    void testPasteOn() {
    4040        DataSet ds1 = new DataSet();
    4141        Node n1 = new Node(new LatLon(43, 1));
     
    6363     */
    6464    @Test
    65     public void testPasteTags() {
     65    void testPasteTags() {
    6666        Node n = new Node(LatLon.ZERO);
    6767        MainApplication.getLayerManager().addLayer(new OsmDataLayer(new DataSet(n), "testPasteTags", null));
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferableTest.java

    r10604 r17275  
    22package org.openstreetmap.josm.gui.datatransfer;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    78
    89import java.awt.datatransfer.DataFlavor;
     
    1314import java.util.List;
    1415
    15 import org.junit.Rule;
    16 import org.junit.Test;
     16import org.junit.jupiter.api.Test;
     17import org.junit.jupiter.api.extension.RegisterExtension;
    1718import org.openstreetmap.josm.data.osm.Node;
    1819import org.openstreetmap.josm.data.osm.NodeData;
     
    2728 * Unit tests of {@link PrimitiveTransferable} class.
    2829 */
    29 public class PrimitiveTransferableTest {
     30class PrimitiveTransferableTest {
    3031    /**
    3132     * Prefs to use OSM primitives
    3233     */
    33     @Rule
     34    @RegisterExtension
    3435    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3536    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    3940     */
    4041    @Test
    41     public void testGetTransferDataFlavors() {
     42    void testGetTransferDataFlavors() {
    4243        List<DataFlavor> flavors = Arrays.asList(new PrimitiveTransferable(null).getTransferDataFlavors());
    4344        int ptd = flavors.indexOf(PrimitiveTransferData.DATA_FLAVOR);
     
    5758     */
    5859    @Test
    59     public void testIsDataFlavorSupported() {
     60    void testIsDataFlavorSupported() {
    6061        assertTrue(new PrimitiveTransferable(null).isDataFlavorSupported(PrimitiveTransferData.DATA_FLAVOR));
    6162        assertFalse(new PrimitiveTransferable(null).isDataFlavorSupported(DataFlavor.imageFlavor));
     
    6768     */
    6869    @Test
    69     public void testGetTransferDataNominal() throws UnsupportedFlavorException {
     70    void testGetTransferDataNominal() throws UnsupportedFlavorException {
    7071        PrimitiveTransferData data = PrimitiveTransferData.getData(Collections.singleton(new Node(1)));
    7172        PrimitiveTransferable pt = new PrimitiveTransferable(data);
     
    8384    /**
    8485     * Test of {@link PrimitiveTransferable#getTransferData} method - error case.
    85      * @throws UnsupportedFlavorException always
    8686     */
    87     @Test(expected = UnsupportedFlavorException.class)
    88     public void testGetTransferDataError() throws UnsupportedFlavorException {
     87    @Test
     88    void testGetTransferDataError() {
    8989        PrimitiveTransferData data = PrimitiveTransferData.getData(Collections.singleton(new Node(1)));
    90         new PrimitiveTransferable(data).getTransferData(DataFlavor.imageFlavor);
     90        assertThrows(UnsupportedFlavorException.class, () -> new PrimitiveTransferable(data).getTransferData(DataFlavor.imageFlavor));
    9191    }
    9292}
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/RelationMemberTransferableTest.java

    r10962 r17275  
    22package org.openstreetmap.josm.gui.datatransfer;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    78import static org.openstreetmap.josm.gui.datatransfer.RelationMemberTransferable.RELATION_MEMBER_DATA;
    89
     
    1213import java.util.Collections;
    1314
    14 import org.junit.Rule;
    15 import org.junit.Test;
     15import org.junit.jupiter.api.Test;
     16import org.junit.jupiter.api.extension.RegisterExtension;
    1617import org.openstreetmap.josm.data.osm.Node;
    1718import org.openstreetmap.josm.data.osm.PrimitiveData;
     
    2627 * Unit tests of {@link RelationMemberTransferable} class.
    2728 */
    28 public class RelationMemberTransferableTest {
     29class RelationMemberTransferableTest {
    2930
    3031    /**
    3132     * Setup tests
    3233     */
    33     @Rule
     34    @RegisterExtension
    3435    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3536    public JOSMTestRules test = new JOSMTestRules();
     
    3940     */
    4041    @Test
    41     public void testGetTransferDataFlavors() {
     42    void testGetTransferDataFlavors() {
    4243        DataFlavor[] flavors = new RelationMemberTransferable(Collections.<RelationMember>emptyList()).getTransferDataFlavors();
    4344        assertEquals(3, flavors.length);
     
    5152     */
    5253    @Test
    53     public void testIsDataFlavorSupported() {
     54    void testIsDataFlavorSupported() {
    5455        RelationMemberTransferable transferable = new RelationMemberTransferable(Collections.<RelationMember>emptyList());
    5556        assertTrue(transferable.isDataFlavorSupported(RELATION_MEMBER_DATA));
     
    6364     */
    6465    @Test
    65     public void testGetTransferDataNominal() throws UnsupportedFlavorException {
     66    void testGetTransferDataNominal() throws UnsupportedFlavorException {
    6667        RelationMemberTransferable rmt = new RelationMemberTransferable(Collections.singleton(new RelationMember("test", new Node(1))));
    6768        assertEquals("node 1 test # incomplete\n", rmt.getTransferData(DataFlavor.stringFlavor));
     
    8081    /**
    8182     * Test of {@link RelationMemberTransferable#getTransferData} method - error case.
    82      * @throws UnsupportedFlavorException always
    8383     */
    84     @Test(expected = UnsupportedFlavorException.class)
    85     public void testGetTransferDataError() throws UnsupportedFlavorException {
    86         new RelationMemberTransferable(Collections.singleton(new RelationMember(null, new Node(1)))).getTransferData(null);
     84    @Test
     85    void testGetTransferDataError() {
     86        assertThrows(UnsupportedFlavorException.class,
     87                () -> new RelationMemberTransferable(Collections.singleton(new RelationMember(null, new Node(1)))).getTransferData(null));
    8788    }
    8889}
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/TagTransferableTest.java

    r11931 r17275  
    22package org.openstreetmap.josm.gui.datatransfer;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    78
    89import java.awt.datatransfer.DataFlavor;
    910import java.awt.datatransfer.UnsupportedFlavorException;
    10 import java.io.IOException;
    1111import java.util.HashMap;
    1212import java.util.Map;
    1313
    14 import org.junit.Rule;
    15 import org.junit.Test;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
    1616import org.openstreetmap.josm.gui.datatransfer.data.TagTransferData;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    2222 * Unit tests of {@link TagTransferable} class.
    2323 */
    24 public class TagTransferableTest {
     24class TagTransferableTest {
    2525
    2626    /**
    2727     * Setup tests
    2828     */
    29     @Rule
     29    @RegisterExtension
    3030    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3131    public JOSMTestRules test = new JOSMTestRules();
     
    3535     */
    3636    @Test
    37     public void testIsDataFlavorSupported() {
     37    void testIsDataFlavorSupported() {
    3838        TagTransferable tt = new TagTransferable(null);
    3939        assertTrue(tt.isDataFlavorSupported(TagTransferData.FLAVOR));
     
    4848     */
    4949    @Test
    50     public void testGetTransferDataNominal() throws Exception {
     50    void testGetTransferDataNominal() throws Exception {
    5151        Map<String, String> tags = new HashMap<>();
    5252        tags.put("foo", "bar");
     
    5858    /**
    5959     * Test of {@link TagTransferable#getTransferData} method - error case.
    60      * @throws UnsupportedFlavorException always
    61      * @throws IOException never
    6260     */
    63     @Test(expected = UnsupportedFlavorException.class)
    64     public void testGetTransferDataError() throws UnsupportedFlavorException, IOException {
    65         new TagTransferable(null).getTransferData(null);
     61    @Test
     62    void testGetTransferDataError() {
     63        assertThrows(UnsupportedFlavorException.class, () -> new TagTransferable(null).getTransferData(null));
    6664    }
    6765}
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/data/PrimitiveTagTransferDataTest.java

    r10737 r17275  
    22package org.openstreetmap.josm.gui.datatransfer.data;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    6 import static org.junit.Assert.assertTrue;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    88import java.util.Arrays;
    99import java.util.Map;
    1010
    11 import org.junit.Rule;
    12 import org.junit.Test;
     11import org.junit.jupiter.api.extension.RegisterExtension;
     12import org.junit.jupiter.api.Test;
    1313import org.openstreetmap.josm.data.osm.Node;
    1414import org.openstreetmap.josm.data.osm.NodeData;
     
    2626 * @author Michael Zangl
    2727 */
    28 public class PrimitiveTagTransferDataTest {
     28class PrimitiveTagTransferDataTest {
    2929    /**
    3030     * Prefs only required because of the dependencies of OSM primitives.
    3131     */
    32     @Rule
     32    @RegisterExtension
    3333    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3434    public JOSMTestRules test = new JOSMTestRules().preferences();
     
    4242     */
    4343    @Test
    44     public void testPrimitiveTagTransferDataPrimitiveTransferData() {
     44    void testPrimitiveTagTransferDataPrimitiveTransferData() {
    4545        PrimitiveTagTransferData data = new PrimitiveTagTransferData(PrimitiveTransferData.getData(Arrays.asList(new Node(), new Node())));
    4646        assertEquals(2, data.getSourcePrimitiveCount(OsmPrimitiveType.NODE));
     
    5353     */
    5454    @Test
    55     public void testIsHeterogeneousSource() {
     55    void testIsHeterogeneousSource() {
    5656        // 0 item
    5757        assertFalse(isHeterogeneousSource());
     
    7474     */
    7575    @Test
    76     public void testGetForPrimitives() {
     76    void testGetForPrimitives() {
    7777        PrimitiveTagTransferData data = createTestData();
    7878        TagCollection forNode = data.getForPrimitives(OsmPrimitiveType.NODE);
     
    100100     */
    101101    @Test
    102     public void testGetSourcePrimitiveCount() {
     102    void testGetSourcePrimitiveCount() {
    103103        PrimitiveTagTransferData data = createTestData();
    104104        assertEquals(2, data.getSourcePrimitiveCount(OsmPrimitiveType.NODE));
     
    111111     */
    112112    @Test
    113     public void testGetStatistics() {
     113    void testGetStatistics() {
    114114        PrimitiveTagTransferData data = createTestData();
    115115        Map<OsmPrimitiveType, Integer> stats = data.getStatistics();
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/importers/OsmLinkPasterTest.java

    r11282 r17275  
    22package org.openstreetmap.josm.gui.datatransfer.importers;
    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.Rule;
    8 import org.junit.Test;
     7import org.junit.jupiter.api.extension.RegisterExtension;
     8import org.junit.jupiter.api.Test;
    99import org.openstreetmap.josm.data.coor.LatLon;
    1010import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    1616 * @author Michael Zangl
    1717 */
    18 public class OsmLinkPasterTest {
     18class OsmLinkPasterTest {
    1919    /**
    2020     * No dependencies
    2121     */
    22     @Rule
     22    @RegisterExtension
    2323    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2424    public JOSMTestRules test = new JOSMTestRules();
     
    2828     */
    2929    @Test
    30     public void testParseLatLon() {
     30    void testParseLatLon() {
    3131        assertEquals(new LatLon(51.71873, 8.76164),
    3232                OsmLinkPaster.parseLatLon("https://www.openstreetmap.org/#map=17/51.71873/8.76164"));
Note: See TracChangeset for help on using the changeset viewer.