Changeset 18870 in josm for trunk/test/functional


Ignore:
Timestamp:
2023-10-16T15:19:07+02:00 (13 months ago)
Author:
taylor.smock
Message:

See #16567: Update to JUnit 5

This converts most tests to use @Annotations. There are also some performance
improvements as it relates to tests.

Location:
trunk/test/functional/org/openstreetmap/josm
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java

    r18294 r18870  
    1212
    1313import org.junit.jupiter.api.Test;
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    1514import org.openstreetmap.josm.data.osm.DataSet;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1716import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1817import org.openstreetmap.josm.io.OsmReader;
    19 import org.openstreetmap.josm.testutils.JOSMTestRules;
    20 
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2219
    2320/**
    2421 * Test of boundaries OSM file.
    2522 */
     23@BasicPreferences
    2624class BoundariesTestIT {
    2725
     
    4644            "US-PR", "US-RI", "US-SC", "US-SD", "US-TN", "US-TX", "US-UM", "US-UT", "US-VT", "US-VA", "US-VI", "US-WA", "US-WV", "US-WI",
    4745            "US-WY");
    48 
    49     /**
    50      * Setup test.
    51      */
    52     @RegisterExtension
    53     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public JOSMTestRules test = new JOSMTestRules().preferences();
    5546
    5647    /**
  • trunk/test/functional/org/openstreetmap/josm/data/imagery/ImageryCompareTestIT.java

    r17275 r18870  
    77
    88import org.junit.jupiter.api.Test;
    9 import org.junit.jupiter.api.extension.RegisterExtension;
     9import org.junit.jupiter.api.Timeout;
    1010import org.openstreetmap.josm.spi.preferences.Config;
    11 import org.openstreetmap.josm.testutils.JOSMTestRules;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1212import org.openstreetmap.josm.tools.HttpClient;
    13 
    14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1513
    1614/**
     
    1816 * See <a href="https://josm.openstreetmap.de/wiki/ImageryCompare">JOSM wiki</a>
    1917 */
     18@BasicPreferences
     19@Timeout(60)
    2020class ImageryCompareTestIT {
    2121
    2222    private static final String BLACK_PREFIX = "<pre style=\"margin:3px;color:black\">";
    2323    private static final String RED_PREFIX = "<pre style=\"margin:3px;color:red\">";
    24 
    25     /**
    26      * Setup test.
    27      */
    28     @RegisterExtension
    29     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().preferences().timeout(60000);
    3124
    3225    /**
  • trunk/test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java

    r18723 r18870  
    1010import java.util.List;
    1111
     12import org.junit.jupiter.api.Test;
     13import org.junit.jupiter.api.Timeout;
     14import org.openstreetmap.josm.data.coor.LatLon;
     15import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
     16import org.openstreetmap.josm.data.validation.tests.TagChecker;
     17import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
     18import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     20import org.openstreetmap.josm.tools.HttpClient;
     21
    1222import jakarta.json.Json;
    1323import jakarta.json.JsonObject;
     
    1525import jakarta.json.JsonValue;
    1626
    17 import org.junit.jupiter.api.Test;
    18 import org.junit.jupiter.api.extension.RegisterExtension;
    19 import org.openstreetmap.josm.data.coor.LatLon;
    20 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    21 import org.openstreetmap.josm.data.validation.tests.TagChecker;
    22 import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    23 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    24 import org.openstreetmap.josm.testutils.JOSMTestRules;
    25 import org.openstreetmap.josm.tools.HttpClient;
    26 import org.xml.sax.SAXException;
    27 
    28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    29 
    3027/**
    3128 * Various integration tests with Taginfo.
    3229 */
     30@BasicPreferences
     31@Timeout(20)
    3332class TaginfoTestIT {
    34 
    35     /**
    36      * Setup test.
    37      */
    38     @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20000);
    41 
    4233    /**
    4334     * Checks that popular tags are known (i.e included in internal presets, or deprecated, or explicitely ignored)
    44      * @throws SAXException if any XML parsing error occurs
    4535     * @throws IOException if any I/O error occurs
    4636     * @throws ParseException if any MapCSS parsing error occurs
    4737     */
    4838    @Test
    49     void testCheckPopularTags() throws SAXException, IOException, ParseException {
     39    void testCheckPopularTags() throws IOException, ParseException {
    5040        TaggingPresets.readFromPreferences();
    5141        new TagChecker().initialize();
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    r17276 r18870  
    2828import javax.imageio.ImageIO;
    2929
    30 import org.junit.jupiter.api.extension.RegisterExtension;
    3130import org.junit.jupiter.params.ParameterizedTest;
    3231import org.junit.jupiter.params.provider.MethodSource;
     
    4039import org.openstreetmap.josm.io.IllegalDataException;
    4140import org.openstreetmap.josm.io.OsmReader;
    42 import org.openstreetmap.josm.testutils.JOSMTestRules;
     41import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     42import org.openstreetmap.josm.testutils.annotations.Projection;
    4343import org.openstreetmap.josm.tools.ColorHelper;
    4444import org.openstreetmap.josm.tools.Utils;
    45 
    46 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    4745
    4846/**
     
    5250 * @author Michael Zangl
    5351 */
     52@BasicPreferences
     53@Projection
    5454public class MapCSSRendererTest {
    5555    private static final String TEST_DATA_BASE = "/renderer/";
     
    5959    private static final Bounds AREA_DEFAULT = new Bounds(0, 0, 1, 1);
    6060    private static final int IMAGE_SIZE = 256;
    61 
    62     /**
    63      * Minimal test rules required
    64      */
    65     @RegisterExtension
    66     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    67     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
    6861
    6962    // development flag - set to true in order to update all reference images
  • trunk/test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java

    r17809 r18870  
    1010import java.awt.image.BufferedImage;
    1111import java.io.File;
     12import java.io.IOException;
    1213import java.io.InputStream;
    1314import java.util.IdentityHashMap;
    1415
    1516import org.junit.jupiter.api.AfterAll;
     17import org.junit.jupiter.api.BeforeAll;
    1618import org.junit.jupiter.api.BeforeEach;
    1719import org.junit.jupiter.api.Test;
    18 import org.junit.jupiter.api.extension.RegisterExtension;
     20import org.junit.jupiter.api.Timeout;
    1921import org.openstreetmap.josm.data.Bounds;
    2022import org.openstreetmap.josm.data.osm.DataSet;
     
    2729import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2830import org.openstreetmap.josm.io.Compression;
     31import org.openstreetmap.josm.io.IllegalDataException;
    2932import org.openstreetmap.josm.io.OsmReader;
    30 import org.openstreetmap.josm.testutils.JOSMTestRules;
     33import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     34import org.openstreetmap.josm.testutils.annotations.Main;
     35import org.openstreetmap.josm.testutils.annotations.Projection;
    3136import org.openstreetmap.josm.tools.Pair;
    32 
    33 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3437
    3538/**
    3639 * Test {@link StyleCache}.
    3740 */
     41@BasicPreferences
     42@Main
     43@org.openstreetmap.josm.testutils.annotations.MapPaintStyles
     44@Projection
     45@Timeout(60)
    3846class StyleCacheTest {
    3947
     
    4755    private static DataSet dsCity2;
    4856
    49     /**
    50      * The test rules used for this test.
    51      */
    52     @RegisterExtension
    53     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().mapStyles().timeout(60000);
     57    @BeforeAll
     58    static void beforeAll() throws IllegalDataException, IOException {
     59        try (InputStream in = Compression.getUncompressedFileInputStream(new File("nodist/data/neubrandenburg.osm.bz2"))) {
     60            dsCity = OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
     61        }
     62        dsCity2 = new DataSet(dsCity);
     63    }
    5564
    5665    /**
     
    6170    public void load() throws Exception {
    6271        img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB);
    63         try (InputStream in = Compression.getUncompressedFileInputStream(new File("nodist/data/neubrandenburg.osm.bz2"))) {
    64             dsCity = OsmReader.parseDataSet(in, NullProgressMonitor.INSTANCE);
    65         }
    66         dsCity2 = new DataSet(dsCity);
    6772    }
    6873
     
    97102     * Verifies, that the intern pool is not growing when repeatedly rendering the
    98103     * same set of primitives (and clearing the calculated styles each time).
    99      *
     104     * <p>
    100105     * If it grows, this is an indication that the {@code equals} and {@code hashCode}
    101106     * implementation is broken and two identical objects are not recognized as equal
    102107     * or produce different hash codes.
    103      *
     108     * <p>
    104109     * The opposite problem (different objects are mistaken as equal) has more visible
    105110     * consequences for the user (wrong rendering on the map) and is not recognized by
     
    135140     * Verifies, that the number of {@code StyleElementList} instances stored
    136141     * for all the rendered primitives is actually low (as intended).
    137      *
     142     * <p>
    138143     * Two primitives with the same style should share one {@code StyleElementList}
    139144     * instance for the cached style elements. This is verified by counting all
Note: See TracChangeset for help on using the changeset viewer.