Changeset 36193 in osm for applications


Ignore:
Timestamp:
2023-11-06T16:17:31+01:00 (14 months ago)
Author:
taylor.smock
Message:

See #16567: Upgrade to JUnit 5

This updates plugins to use the JUnit 5 annotations

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

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/ImportImagePlugin/test/unit/org/openstreetmap/josm/plugins/ImportImagePlugin/ImageLayerTest.java

    r36013 r36193  
    99
    1010import org.junit.jupiter.api.Test;
    11 import org.junit.jupiter.api.extension.RegisterExtension;
    1211import org.openstreetmap.josm.TestUtils;
    1312import org.openstreetmap.josm.gui.MainApplication;
    1413import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1514import org.openstreetmap.josm.io.OsmReader;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1715import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     16import org.openstreetmap.josm.testutils.annotations.Projection;
    1817
    1918/**
     
    2221 */
    2322@BasicPreferences
     23@Projection
    2424class ImageLayerTest {
    25 
    26     /**
    27      * Setup test.
    28      */
    29     @RegisterExtension
    30     static JOSMTestRules rules = new JOSMTestRules().projection();
    31 
    3225    /**
    3326     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/14894">#14894</a>
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideDataTest.java

    r36065 r36193  
    2525@Main
    2626class StreetsideDataTest {
    27 
    28   /*@Rule
    29   public JOSMTestRules rules = new StreetsideTestRules().platform();*/
    3027
    3128  private StreetsideData data;
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/StreetsideLayerTest.java

    r36065 r36193  
    33
    44import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertInstanceOf;
    56import static org.junit.jupiter.api.Assertions.assertNotNull;
    67import static org.junit.jupiter.api.Assertions.assertThrows;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
    8 
    9 import java.awt.GraphicsEnvironment;
    109
    1110import org.junit.jupiter.api.Test;
     
    6968  void testGetInfoComponent() {
    7069    Object comp = StreetsideLayer.getInstance().getInfoComponent();
    71     assertTrue(comp instanceof String);
     70    assertInstanceOf(String.class, comp);
    7271    assertTrue(((String) comp).length() >= 9);
    7372  }
  • applications/editors/josm/plugins/MicrosoftStreetside/test/unit/org/openstreetmap/josm/plugins/streetside/utils/TestUtil.java

    r36065 r36193  
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertTrue;
    6 import static org.junit.jupiter.api.Assertions.fail;
    76
    8 import java.awt.GraphicsEnvironment;
    97import java.lang.reflect.Constructor;
    108import java.lang.reflect.Field;
     
    1210import java.lang.reflect.Method;
    1311import java.lang.reflect.Modifier;
    14 import java.util.logging.Level;
    1512
    16 import org.junit.runners.model.InitializationError;
    17 import org.openstreetmap.josm.testutils.JOSMTestRules;
    18 import org.openstreetmap.josm.tools.Logging;
    19 import org.openstreetmap.josm.tools.Utils;
     13import org.openstreetmap.josm.tools.JosmRuntimeException;
    2014
    2115/**
     
    3731      return result;
    3832    } catch (NoSuchFieldException | SecurityException | IllegalArgumentException | IllegalAccessException e) {
    39       fail(e.getLocalizedMessage());
     33      throw new JosmRuntimeException(e);
    4034    }
    41     return null;
    4235  }
    4336
     
    5245      return getAccessibleField(object.getClass(), name).get(object);
    5346    } catch (IllegalAccessException | SecurityException e) {
    54       fail(e.getLocalizedMessage());
     47      throw new JosmRuntimeException(e);
    5548    }
    56     return null;
    5749  }
    5850
     
    8072      }
    8173    } catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
    82       fail(e.getLocalizedMessage());
    83     }
    84   }
    85 
    86   public static class StreetsideTestRules extends JOSMTestRules {
    87     @Override
    88     protected void before() throws InitializationError, ReflectiveOperationException {
    89       Logging.getLogger().setFilter(record -> record.getLevel().intValue() >= Level.WARNING.intValue() || record.getSourceClassName().startsWith("org.openstreetmap.josm.plugins.streetside"));
    90       Utils.updateSystemProperty("java.util.logging.SimpleFormatter.format", "%1$tF %1$tT.%1$tL %2$s %4$s: %5$s%6$s%n");
    91       final String isHeadless = Boolean.toString(GraphicsEnvironment.isHeadless());
    92       super.before();
    93       System.setProperty("java.awt.headless", isHeadless);
     74      throw new JosmRuntimeException(e);
    9475    }
    9576  }
  • applications/editors/josm/plugins/comfort0/test/unit/net/simon04/comfort0/EditLevel0LActionTest.java

    r35934 r36193  
    1212
    1313import org.junit.jupiter.api.Test;
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    1514import org.openstreetmap.josm.command.ChangePropertyCommand;
    1615import org.openstreetmap.josm.command.MoveCommand;
     
    2221import org.openstreetmap.josm.data.osm.PrimitiveData;
    2322import org.openstreetmap.josm.data.osm.TagMap;
    24 import org.openstreetmap.josm.testutils.JOSMTestRules;
    25 
    26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     24import org.openstreetmap.josm.testutils.annotations.Projection;
    2725
    2826import net.simon04.comfort0.level0l.parsergen.Level0LParser;
    2927import net.simon04.comfort0.level0l.parsergen.ParseException;
    30 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3128
    3229@BasicPreferences
     30@Projection
    3331class EditLevel0LActionTest {
    34 
    35     /**
    36      * Setup rule
    37      */
    38     @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     JOSMTestRules test = new JOSMTestRules().projection();
    41 
    4232    private SequenceCommand buildChangeCommands(DataSet dataSet) throws ParseException {
    4333        final String level0l = "node 1831881213: 54.0900666, 12.2539381 #Neu Broderstorf (54.0900666, 12.2539381)\n" +
  • applications/editors/josm/plugins/comfort0/test/unit/net/simon04/comfort0/level0l/parsergen/Level0LParserTest.java

    r35934 r36193  
    88import java.util.List;
    99
    10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1110import org.junit.jupiter.api.Test;
    1211import org.openstreetmap.josm.data.osm.NodeData;
     
    1514import org.openstreetmap.josm.data.osm.RelationData;
    1615import org.openstreetmap.josm.data.osm.WayData;
    17 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1816import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1917
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/datasets/DataSetUpdaterTest.java

    r36064 r36193  
    1313import org.junit.jupiter.api.Test;
    1414import org.junit.jupiter.api.Timeout;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.data.osm.DataSet;
     
    2019import org.openstreetmap.josm.plugins.opendata.core.datasets.DataSetUpdater;
    2120import org.openstreetmap.josm.plugins.opendata.core.io.archive.ZipReader;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
    2321import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2422import org.openstreetmap.josm.testutils.annotations.Projection;
     
    2826 */
    2927@BasicPreferences
     28@org.openstreetmap.josm.testutils.annotations.OsmApi(org.openstreetmap.josm.testutils.annotations.OsmApi.APIType.DEV)
    3029@Projection
    3130@Timeout(value = 1, unit = TimeUnit.MINUTES)
    3231class DataSetUpdaterTest {
    33 
    34     /**
    35      * Setup test.
    36      */
    37     @RegisterExtension
    38     JOSMTestRules rules = new JOSMTestRules().devAPI();
    39 
    4032    /**
    4133     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/11166">#11166</a>
  • applications/editors/josm/plugins/turnrestrictions/test/unit/org/openstreetmap/josm/plugins/turnrestrictions/editor/AllEditorTests.java

    r36064 r36193  
    44import org.junit.platform.suite.api.SelectClasses;
    55
    6 import junit.framework.TestCase;
    76import org.junit.platform.suite.api.Suite;
    87
     
    1615    ExceptValueModelTest.class
    1716})
    18 public class AllEditorTests extends TestCase{}
     17public class AllEditorTests {}
Note: See TracChangeset for help on using the changeset viewer.