Ticket #21139: 21139.4.patch

File 21139.4.patch, 272.4 KB (added by taylor.smock, 5 years ago)
  • ivy.xml

    diff --git a/ivy.xml b/ivy.xml
    index d6fa0b3232..30a8d98a4b 100644
    a b  
    6060        <dependency conf="test->default" org="com.github.tomakehurst" name="wiremock" rev="2.27.2"/>
    6161        <dependency conf="test->default" org="io.github.classgraph" name="classgraph" rev="4.8.110"/>
    6262        <dependency conf="test->default" org="org.junit.platform" name="junit-platform-launcher" rev="1.7.2"/>
     63        <dependency conf="test->default" org="org.junit.platform" name="junit-platform-suite-api" rev="1.7.2"/>
    6364        <dependency conf="test->default" org="org.junit.vintage" name="junit-vintage-engine" rev="5.7.2"/>
    6465        <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-params" rev="5.7.2"/>
    6566        <dependency conf="test->default" org="org.junit.jupiter" name="junit-jupiter-api" rev="5.7.2"/>
  • test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java

    diff --git a/test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java b/test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java
    index d4734744a8..c3ffd340e0 100644
    a b import org.openstreetmap.josm.io.OsmReader;  
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
    2020
    2121import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     22import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2223
    2324/**
    2425 * Test of boundaries OSM file.
    2526 */
     27@IntegrationTest
    2628class BoundariesTestIT {
    2729
    2830    private static final List<String> RETIRED_ISO3166_1_CODES = Arrays.asList(
  • test/functional/org/openstreetmap/josm/data/imagery/ImageryCompareTestIT.java

    diff --git a/test/functional/org/openstreetmap/josm/data/imagery/ImageryCompareTestIT.java b/test/functional/org/openstreetmap/josm/data/imagery/ImageryCompareTestIT.java
    index 60ca4fbcee..ea2467d52e 100644
    a b import static org.junit.jupiter.api.Assertions.fail;  
    66import java.net.URL;
    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;
     12import org.openstreetmap.josm.testutils.annotations.HTTP;
     13import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    1214import org.openstreetmap.josm.tools.HttpClient;
    1315
    14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    15 
    1616/**
    1717 * Automatic test of imagery synchronization between JOSM and ELI.
    1818 * See <a href="https://josm.openstreetmap.de/wiki/ImageryCompare">JOSM wiki</a>
    1919 */
     20@IntegrationTest
     21@Timeout(20)
     22@HTTP
     23@BasicPreferences
    2024class ImageryCompareTestIT {
    2125
    2226    private static final String BLACK_PREFIX = "<pre style=\"margin:3px;color:black\">";
    2327    private static final String RED_PREFIX = "<pre style=\"margin:3px;color:red\">";
    2428
    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);
    31 
    3229    /**
    3330     * Test of imagery entries.
    3431     * @throws Exception if an error occurs
  • test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java

    diff --git a/test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java b/test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java
    index d153334831..2c97e062dd 100644
    a b import javax.json.JsonReader;  
    1515import javax.json.JsonValue;
    1616
    1717import org.junit.jupiter.api.Test;
    18 import org.junit.jupiter.api.extension.RegisterExtension;
     18import org.junit.jupiter.api.Timeout;
    1919import org.openstreetmap.josm.data.coor.LatLon;
    2020import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    2121import org.openstreetmap.josm.data.validation.tests.TagChecker;
    2222import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    2323import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    24 import org.openstreetmap.josm.testutils.JOSMTestRules;
     24import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     25import org.openstreetmap.josm.testutils.annotations.HTTP;
     26import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2527import org.openstreetmap.josm.tools.HttpClient;
    2628import org.xml.sax.SAXException;
    2729
    28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    29 
    3030/**
    3131 * Various integration tests with Taginfo.
    3232 */
     33@Timeout(value = 20)
     34@BasicPreferences
     35@HTTP
     36@IntegrationTest
    3337class 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 
    4238    /**
    4339     * Checks that popular tags are known (i.e included in internal presets, or deprecated, or explicitely ignored)
    4440     * @throws SAXException if any XML parsing error occurs
  • test/functional/org/openstreetmap/josm/gui/GettingStartedTest.java

    diff --git a/test/functional/org/openstreetmap/josm/gui/GettingStartedTest.java b/test/functional/org/openstreetmap/josm/gui/GettingStartedTest.java
    index 6c7a9ed0db..ddf273d32e 100644
    a b import static org.junit.jupiter.api.Assertions.assertNotEquals;  
    55
    66import java.io.IOException;
    77
    8 import org.junit.jupiter.api.Test;
    9 import org.junit.jupiter.api.BeforeAll;
    108import org.junit.jupiter.api.Disabled;
    11 import org.openstreetmap.josm.JOSMFixture;
     9import org.junit.jupiter.api.Test;
     10import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     11import org.openstreetmap.josm.testutils.annotations.HTTP;
    1212
    1313/**
    1414 * Tests the {@link GettingStarted} class.
    1515 */
     16@BasicPreferences
     17@HTTP
    1618class GettingStartedTest {
    1719
    18     /**
    19      * Setup test.
    20      */
    21     @BeforeAll
    22     public static void init() {
    23         JOSMFixture.createFunctionalTestFixture().init();
    24     }
    25 
    2620    /**
    2721     * Tests that image links are replaced.
    2822     *
  • test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java

    diff --git a/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java b/test/functional/org/openstreetmap/josm/gui/mappaint/MapCSSRendererTest.java
    index 97afd4d5b9..da4507b0be 100644
    a b public class MapCSSRendererTest {  
    6464     */
    6565    @RegisterExtension
    6666    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    67     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     67    public JOSMTestRules test = new JOSMTestRules().projection();
    6868
    6969    // development flag - set to true in order to update all reference images
    7070    private static final boolean UPDATE_ALL = false;
  • test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java

    diff --git a/test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java b/test/functional/org/openstreetmap/josm/gui/mappaint/StyleCacheTest.java
    index 6bd117d1dc..59dc91df17 100644
    a b import org.openstreetmap.josm.gui.progress.NullProgressMonitor;  
    2828import org.openstreetmap.josm.io.Compression;
    2929import org.openstreetmap.josm.io.OsmReader;
    3030import org.openstreetmap.josm.testutils.JOSMTestRules;
     31import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3132import org.openstreetmap.josm.tools.Pair;
    3233
    3334import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3536/**
    3637 * Test {@link StyleCache}.
    3738 */
     39@BasicPreferences
    3840class StyleCacheTest {
    3941
    4042    private static final int IMG_WIDTH = 1400;
    class StyleCacheTest {  
    5153     */
    5254    @RegisterExtension
    5355    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().mapStyles().timeout(60000);
     56    public JOSMTestRules test = new JOSMTestRules().main().projection().mapStyles().timeout(60000);
    5557
    5658    /**
    5759     * Load the test data that is required.
  • test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java

    diff --git a/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java b/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java
    index f5ac350e3d..f8f9045f95 100644
    a b import org.junit.jupiter.api.BeforeAll;  
    2929import org.junit.jupiter.api.BeforeEach;
    3030import org.junit.jupiter.api.Test;
    3131import org.junit.jupiter.api.Timeout;
    32 import org.junit.jupiter.api.extension.RegisterExtension;
    33 import org.openstreetmap.josm.JOSMFixture;
    3432import org.openstreetmap.josm.TestUtils;
    3533import org.openstreetmap.josm.data.coor.LatLon;
    3634import org.openstreetmap.josm.data.osm.Changeset;
    import org.openstreetmap.josm.data.osm.RelationMember;  
    4341import org.openstreetmap.josm.data.osm.Way;
    4442import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    4543import org.openstreetmap.josm.spi.preferences.Config;
    46 import org.openstreetmap.josm.testutils.JOSMTestRules;
     44import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     45import org.openstreetmap.josm.testutils.annotations.Main;
     46import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    4747
    4848import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    4949
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    5252 */
    5353@SuppressFBWarnings(value = "CRLF_INJECTION_LOGS")
    5454@Timeout(value = 60, unit = TimeUnit.SECONDS)
     55@BasicPreferences
     56@OsmApiType(OsmApiType.APIType.DEV)
     57@Main
    5558class MultiFetchServerObjectReaderTest {
    5659    private static final Logger logger = Logger.getLogger(MultiFetchServerObjectReader.class.getName());
    5760
    58     /**
    59      * Setup test.
    60      */
    61     @RegisterExtension
    62     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    63     public JOSMTestRules test = new JOSMTestRules().preferences();
    64 
    6561    /**
    6662     * builds a large data set to be used later for testing MULTI FETCH on the server
    6763     *
    class MultiFetchServerObjectReaderTest {  
    163159            return;
    164160        }
    165161        logger.info("initializing ...");
    166         JOSMFixture.createFunctionalTestFixture().init();
    167162
    168163        Config.getPref().put("osm-server.auth-method", "basic");
    169164
  • test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    diff --git a/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java b/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java
    index 15cca85efe..39227ad8e3 100644
    a b import java.util.logging.Logger;  
    2525import org.junit.jupiter.api.BeforeAll;
    2626import org.junit.jupiter.api.BeforeEach;
    2727import org.junit.jupiter.api.Test;
    28 import org.openstreetmap.josm.JOSMFixture;
    2928import org.openstreetmap.josm.TestUtils;
    3029import org.openstreetmap.josm.data.APIDataSet;
    3130import org.openstreetmap.josm.data.coor.LatLon;
    import org.openstreetmap.josm.data.projection.ProjectionRegistry;  
    4241import org.openstreetmap.josm.data.projection.Projections;
    4342import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    4443import org.openstreetmap.josm.spi.preferences.Config;
     44import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     45import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    4546import org.openstreetmap.josm.tools.Logging;
    4647
    4748import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    5152 * @since 1806
    5253 */
    5354@SuppressFBWarnings(value = "CRLF_INJECTION_LOGS")
     55@FullPreferences
     56@OsmApiType(OsmApiType.APIType.DEV)
    5457class OsmServerBackreferenceReaderTest {
    5558    private static final Logger logger = Logger.getLogger(OsmServerBackreferenceReader.class.getName());
    5659
    class OsmServerBackreferenceReaderTest {  
    165168        }
    166169        logger.info("initializing ...");
    167170
    168         JOSMFixture.createFunctionalTestFixture().init();
    169 
    170171        Config.getPref().put("osm-server.auth-method", "basic");
    171172
    172173        // don't use atomic upload, the test API server can't cope with large diff uploads
  • test/functional/org/openstreetmap/josm/tools/ImageProviderTestIT.java

    diff --git a/test/functional/org/openstreetmap/josm/tools/ImageProviderTestIT.java b/test/functional/org/openstreetmap/josm/tools/ImageProviderTestIT.java
    index 16be1d91c9..9904953772 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
    1010import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     11import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    1112
    1213/**
    1314 * Integration tests of {@link ImageProvider} class.
    1415 */
     16@IntegrationTest
    1517class ImageProviderTestIT {
    1618
    1719    /**
  • test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java

    diff --git a/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java b/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/AbstractMapRendererPerformanceTestParent.java
    index fe040014b8..5cb6a2bdb8 100644
    a b import org.openstreetmap.josm.io.Compression;  
    2626import org.openstreetmap.josm.io.OsmReader;
    2727
    2828import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     29import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2930
    3031/**
    3132 * Abstract superclass of {@code StyledMapRendererPerformanceTest} and {@code WireframeMapRendererPerformanceTest}.
    3233 */
    33 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     34@Timeout(value = 15, unit = TimeUnit.MINUTES)
     35@BasicPreferences
    3436abstract class AbstractMapRendererPerformanceTestParent {
    3537
    3638    private static final int IMG_WIDTH = 1400;
  • test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java

    diff --git a/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java b/test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java
    index ded650f02e..f95fc24e6f 100644
    a b import org.junit.jupiter.api.BeforeAll;  
    1111import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
    1212
    1313import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     14import org.openstreetmap.josm.testutils.annotations.FullPreferences;
    1415
    1516/**
    1617 * Performance test of {@code StyledMapRenderer}.
    1718 */
     19@FullPreferences
    1820class StyledMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent {
    1921
    2022    @BeforeAll
  • test/performance/org/openstreetmap/josm/data/validation/ValidationTaskPerformanceTest.java

    diff --git a/test/performance/org/openstreetmap/josm/data/validation/ValidationTaskPerformanceTest.java b/test/performance/org/openstreetmap/josm/data/validation/ValidationTaskPerformanceTest.java
    index 25d9295d12..d4311a6ba0 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.validation;
    33
     4import static org.junit.jupiter.api.Assertions.assertTrue;
     5
     6import java.util.Collection;
     7import java.util.List;
     8import java.util.stream.Collectors;
     9
    410import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    511import org.junit.jupiter.api.BeforeEach;
    612import org.junit.jupiter.api.Test;
    import org.openstreetmap.josm.gui.MainApplication;  
    1319import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1420import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1521import org.openstreetmap.josm.testutils.JOSMTestRules;
    16 
    17 import java.util.Collection;
    18 import java.util.List;
    19 import java.util.stream.Collectors;
    20 
    21 import static org.junit.jupiter.api.Assertions.assertTrue;
     22import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2223
    2324/**
    2425 * Performance test of {@code ValidationTask}.
    2526 */
     27@BasicPreferences
    2628class ValidationTaskPerformanceTest {
    2729
    2830    private List<org.openstreetmap.josm.data.validation.Test> tests;
    class ValidationTaskPerformanceTest {  
    3234     */
    3335    @RegisterExtension
    3436    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences();
     37    public JOSMTestRules test = new JOSMTestRules().projection().territories();
    3638
    3739    /**
    3840     * Setup test.
  • test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java

    diff --git a/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java b/test/performance/org/openstreetmap/josm/gui/mappaint/MapRendererPerformanceTest.java
    index 430740e618..2171d88aa3 100644
    a b import java.util.EnumMap;  
    1616import java.util.List;
    1717import java.util.Locale;
    1818import java.util.Map;
     19import java.util.concurrent.TimeUnit;
    1920import java.util.stream.Collectors;
    2021
    2122import javax.imageio.ImageIO;
    2223
     24import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2325import org.junit.Assert;
    2426import org.junit.jupiter.api.AfterAll;
    2527import org.junit.jupiter.api.BeforeAll;
    2628import org.junit.jupiter.api.Test;
     29import org.junit.jupiter.api.Timeout;
    2730import org.junit.jupiter.api.extension.RegisterExtension;
    28 import org.openstreetmap.josm.JOSMFixture;
    2931import org.openstreetmap.josm.PerformanceTestUtils;
    3032import org.openstreetmap.josm.TestUtils;
    3133import org.openstreetmap.josm.data.Bounds;
    import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;  
    4345import org.openstreetmap.josm.gui.mappaint.mapcss.Selector;
    4446import org.openstreetmap.josm.gui.mappaint.styleelement.StyleElement;
    4547import org.openstreetmap.josm.testutils.JOSMTestRules;
    46 
    47 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     48import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    4849
    4950/**
    5051 * Performance test of map renderer.
    5152 */
     53@Timeout(value = 15, unit = TimeUnit.MINUTES)
     54@BasicPreferences
    5255public class MapRendererPerformanceTest {
    5356
    5457    private static final boolean DUMP_IMAGE = false; // dump images to file for debugging purpose
    public class MapRendererPerformanceTest {  
    8487     */
    8588    @RegisterExtension
    8689    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    87     public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().preferences().timeout(15 * 60 * 1000);
     90    public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection();
    8891
    8992    /**
    9093     * Initializes test environment.
    public class MapRendererPerformanceTest {  
    9295     */
    9396    @BeforeAll
    9497    public static void load() throws Exception {
    95         JOSMFixture.createPerformanceTestFixture().init(true);
    96 
    9798        img = new BufferedImage(IMG_WIDTH, IMG_HEIGHT, BufferedImage.TYPE_INT_ARGB);
    9899        g = (Graphics2D) img.getGraphics();
    99100        g.setClip(0, 0, IMG_WIDTH, IMG_HEIGHT);
  • test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.java

    diff --git a/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.java b/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSPerformanceTest.java
    index 504daea82d..1b79dc4de3 100644
    a b import java.io.IOException;  
    1010import java.util.Collection;
    1111
    1212import org.junit.jupiter.api.Test;
    13 import org.junit.jupiter.api.BeforeAll;
    14 import org.openstreetmap.josm.JOSMFixture;
    1513import org.openstreetmap.josm.PerformanceTestUtils;
    1614import org.openstreetmap.josm.data.Bounds;
    1715import org.openstreetmap.josm.data.osm.DataSet;
    import org.openstreetmap.josm.data.preferences.sources.SourceType;  
    2119import org.openstreetmap.josm.gui.NavigatableComponent;
    2220import org.openstreetmap.josm.gui.mappaint.MapRendererPerformanceTest;
    2321import org.openstreetmap.josm.io.IllegalDataException;
     22import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2423
    2524/**
    2625 * This performance test measures the time for a full run of MapPaintVisitor.visitAll()
    2726 * against a test data set using a test style.
    2827 *
    2928 */
     29@BasicPreferences
    3030class MapCSSPerformanceTest {
    3131
    3232    /* ------------------------ configuration section  ---------------------------- */
    class MapCSSPerformanceTest {  
    4747          }
    4848    }
    4949
    50     /**
    51      * Setup test.
    52      */
    53     @BeforeAll
    54     public static void createJOSMFixture() {
    55         JOSMFixture.createPerformanceTestFixture().init(true);
    56     }
    57 
    5850    long timed(Runnable callable) {
    5951        long before = System.currentTimeMillis();
    6052        callable.run();
  • test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java

    diff --git a/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java b/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java
    index 21241668dd..073d720f06 100644
    a b package org.openstreetmap.josm.gui.mappaint.mapcss;  
    33
    44import java.util.concurrent.TimeUnit;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    87import org.junit.jupiter.api.Timeout;
    9 import org.openstreetmap.josm.JOSMFixture;
    108import org.openstreetmap.josm.PerformanceTestUtils;
    119import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer;
    1210import org.openstreetmap.josm.data.osm.OsmDataGenerator;
    1311import org.openstreetmap.josm.data.osm.OsmDataGenerator.KeyValueDataGenerator;
    1412import org.openstreetmap.josm.gui.mappaint.MultiCascade;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1514
    1615/**
    1716 * Tests how fast {@link MapCSSStyleSource} finds the right style candidates for one object.
    1817 * @author Michael Zangl
    1918 */
    20 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     19@Timeout(value = 15, unit = TimeUnit.MINUTES)
     20@BasicPreferences
    2121class MapCSSStyleSourceFilterTest {
    2222
    2323    private static final int TEST_RULE_COUNT = 10000;
    class MapCSSStyleSourceFilterTest {  
    8080
    8181    private static final int APPLY_CALLS = 100000;
    8282
    83     /**
    84      * Prepare the test.
    85      */
    86     @BeforeAll
    87     public static void createJOSMFixture() {
    88         JOSMFixture.createPerformanceTestFixture().init(true);
    89     }
    90 
    9183    /**
    9284     * Time how long it takes to evaluate [key=value] rules
    9385     */
  • test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java

    diff --git a/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java b/test/performance/org/openstreetmap/josm/io/OsmReaderPerformanceTest.java
    index e9a1a1c78f..542c88f275 100644
    a b import java.io.IOException;  
    1111import java.io.InputStream;
    1212import java.util.concurrent.TimeUnit;
    1313
    14 import org.junit.jupiter.api.BeforeAll;
    1514import org.junit.jupiter.api.Test;
    1615import org.junit.jupiter.api.Timeout;
    17 import org.openstreetmap.josm.JOSMFixture;
    1816import org.openstreetmap.josm.PerformanceTestUtils;
    1917import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer;
    2018import org.openstreetmap.josm.data.osm.DataSet;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2120
    2221/**
    2322 * This test tests how fast we are at reading an OSM file.
    import org.openstreetmap.josm.data.osm.DataSet;  
    2625 *
    2726 * @author Michael Zangl
    2827 */
    29 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     28@Timeout(value = 15, unit = TimeUnit.MINUTES)
     29@BasicPreferences
    3030class OsmReaderPerformanceTest {
    3131    private static final int TIMES = 4;
    3232
    33     /**
    34      * Prepare the test.
    35      */
    36     @BeforeAll
    37     public static void createJOSMFixture() {
    38         JOSMFixture.createPerformanceTestFixture().init(true);
    39     }
    40 
    4133    /**
    4234     * Simulates a plain read of a .osm.bz2 file (from memory)
    4335     * @throws Exception if an error occurs
  • test/performance/org/openstreetmap/josm/io/OsmWriterPerformanceTest.java

    diff --git a/test/performance/org/openstreetmap/josm/io/OsmWriterPerformanceTest.java b/test/performance/org/openstreetmap/josm/io/OsmWriterPerformanceTest.java
    index 8835650fe8..975a7a416e 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io;
    33
    4 import org.junit.jupiter.api.BeforeAll;
     4import java.io.PrintWriter;
     5import java.io.StringWriter;
     6import java.util.concurrent.TimeUnit;
     7
    58import org.junit.jupiter.api.BeforeEach;
    69import org.junit.jupiter.api.Test;
    710import org.junit.jupiter.api.Timeout;
    8 import org.openstreetmap.josm.JOSMFixture;
    911import org.openstreetmap.josm.PerformanceTestUtils;
    1012import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer;
    1113import org.openstreetmap.josm.data.osm.DataSet;
    12 
    13 import java.io.PrintWriter;
    14 import java.io.StringWriter;
    15 import java.util.concurrent.TimeUnit;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1615
    1716/**
    1817 * This test tests how fast we are at writing an OSM file.
    1918 * <p>
    2019 * For this, we use the neubrandenburg-file, which is a good real world example of an OSM file.
    2120 */
    22 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     21@Timeout(value = 15, unit = TimeUnit.MINUTES)
     22@BasicPreferences
    2323class OsmWriterPerformanceTest {
    2424    private static final int TIMES = 4;
    2525    private DataSet neubrandenburgDataSet;
    2626
    27     /**
    28      * Prepare the test.
    29      */
    30     @BeforeAll
    31     public static void createJOSMFixture() {
    32         JOSMFixture.createPerformanceTestFixture().init(true);
    33     }
    34 
    3527    /**
    3628     * Setup test
    3729     * @throws Exception if an error occurs
  • test/unit/org/openstreetmap/josm/TestUtils.java

    diff --git a/test/unit/org/openstreetmap/josm/TestUtils.java b/test/unit/org/openstreetmap/josm/TestUtils.java
    index c30e05388d..266ebe22f8 100644
    a b import java.io.IOException;  
    1616import java.io.InputStream;
    1717import java.lang.reflect.Field;
    1818import java.lang.reflect.Method;
     19import java.net.Authenticator;
     20import java.net.PasswordAuthentication;
    1921import java.security.AccessController;
    2022import java.security.PrivilegedAction;
    2123import java.time.Instant;
    import org.openstreetmap.josm.gui.progress.ProgressMonitor;  
    5355import org.openstreetmap.josm.gui.progress.ProgressTaskId;
    5456import org.openstreetmap.josm.gui.util.GuiHelper;
    5557import org.openstreetmap.josm.io.Compression;
     58import org.openstreetmap.josm.io.OsmApi;
     59import org.openstreetmap.josm.io.auth.CredentialsAgentException;
     60import org.openstreetmap.josm.io.auth.JosmPreferencesCredentialAgent;
    5661import org.openstreetmap.josm.testutils.FakeGraphics;
    5762import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    5863import org.openstreetmap.josm.testutils.mockers.WindowMocker;
    5964import org.openstreetmap.josm.tools.JosmRuntimeException;
     65import org.openstreetmap.josm.tools.Logging;
    6066import org.openstreetmap.josm.tools.ReflectionUtils;
    6167import org.openstreetmap.josm.tools.Utils;
    6268import org.openstreetmap.josm.tools.WikiReader;
    6369
    6470import com.github.tomakehurst.wiremock.WireMockServer;
    6571import com.github.tomakehurst.wiremock.core.WireMockConfiguration;
    66 
    6772import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    6873import io.github.classgraph.ClassGraph;
    6974import io.github.classgraph.ClassInfoList;
    public final class TestUtils {  
    646651     * @return {@code true} if {@code osm.username} and {@code osm.password} have been defined on the command line
    647652     */
    648653    public static boolean areCredentialsProvided() {
    649         return Utils.getSystemProperty("osm.username") != null && Utils.getSystemProperty("osm.password") != null;
     654        final String username = Utils.getSystemProperty("osm.username");
     655        final String password = Utils.getSystemProperty("osm.password");
     656        if (username != null && password != null) {
     657            try {
     658                new JosmPreferencesCredentialAgent().store(Authenticator.RequestorType.SERVER,
     659                        OsmApi.getOsmApi().getHost(), new PasswordAuthentication(username, password.toCharArray()));
     660                return true;
     661            } catch (CredentialsAgentException e) {
     662                Logging.error("Credentials could not be stored");
     663            }
     664        }
     665        return false;
    650666    }
    651667
    652668    /**
  • test/unit/org/openstreetmap/josm/actions/AboutActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/AboutActionTest.java b/test/unit/org/openstreetmap/josm/actions/AboutActionTest.java
    index 51a4535692..dd6da352e1 100644
    a b import org.junit.jupiter.api.Test;  
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
    1010import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1112
    1213/**
    1314 * Unit tests for class {@link AboutAction}.
    1415 */
     16@BasicPreferences
    1517final class AboutActionTest {
    1618
    1719    /**
  • test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java b/test/unit/org/openstreetmap/josm/actions/AlignInLineActionTest.java
    index 77f2149805..b907ca891a 100644
    a b import org.openstreetmap.josm.data.osm.Node;  
    1818import org.openstreetmap.josm.data.osm.Way;
    1919import org.openstreetmap.josm.gui.MainApplication;
    2020import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2122
    2223import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2324
    2425/**
    2526 * Unit tests for class {@link AlignInLineAction}.
    2627 */
     28@BasicPreferences
    2729final class AlignInLineActionTest {
    2830
    2931    /**
  • test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java b/test/unit/org/openstreetmap/josm/actions/CreateMultipolygonActionTest.java
    index 495fec7007..03b3b516a5 100644
    a b import org.openstreetmap.josm.gui.layer.Layer;  
    3030import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3131import org.openstreetmap.josm.io.OsmReader;
    3232import org.openstreetmap.josm.testutils.JOSMTestRules;
     33import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     34import org.openstreetmap.josm.testutils.annotations.HTTP;
     35import org.openstreetmap.josm.testutils.annotations.Territories;
    3336import org.openstreetmap.josm.tools.Pair;
    3437import org.openstreetmap.josm.tools.SubclassFilteredCollection;
    3538
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3841/**
    3942 * Unit test of {@link CreateMultipolygonAction}
    4043 */
     44@BasicPreferences
     45@HTTP
     46@Territories(Territories.Initialize.ALL)
    4147class CreateMultipolygonActionTest {
    4248
    4349    /**
    class CreateMultipolygonActionTest {  
    4551     */
    4652    @RegisterExtension
    4753    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    48     public JOSMTestRules test = new JOSMTestRules().projection().main().preferences().mapStyles();
     54    public JOSMTestRules test = new JOSMTestRules().projection().main().mapStyles();
    4955
    5056    private static Map<String, String> getRefToRoleMap(Relation relation) {
    5157        Map<String, String> refToRole = new TreeMap<>();
  • test/unit/org/openstreetmap/josm/actions/ExitActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java b/test/unit/org/openstreetmap/josm/actions/ExitActionTest.java
    index c6c4780728..a60d33ea24 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    1313import org.openstreetmap.josm.gui.io.SaveLayersDialog;
    1414import org.openstreetmap.josm.gui.progress.swing.ProgressMonitorExecutor;
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
     16import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1617import org.openstreetmap.josm.tools.ImageProvider;
    1718
    1819import com.ginsberg.junit.exit.ExpectSystemExitWithStatus;
    import mockit.MockUp;  
    2526/**
    2627 * Unit tests for class {@link ExitAction}.
    2728 */
     29@BasicPreferences
    2830final class ExitActionTest {
    2931
    3032    /**
  • test/unit/org/openstreetmap/josm/actions/FullscreenToggleActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/FullscreenToggleActionTest.java b/test/unit/org/openstreetmap/josm/actions/FullscreenToggleActionTest.java
    index e03f5a4cc7..1d62fbd117 100644
    a b import org.junit.jupiter.api.Test;  
    66import org.openstreetmap.josm.testutils.JOSMTestRules;
    77
    88import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     9import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    910
    1011/**
    1112 * Test {@link FullscreenToggleAction}
    1213 */
     14@BasicPreferences
    1315class FullscreenToggleActionTest {
    1416    /**
    1517     * Setup test.
    class FullscreenToggleActionTest {  
    2931        action.actionPerformed(null);
    3032    }
    3133}
     34
  • test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java b/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java
    index a6630f2861..6b095ebda6 100644
    a b import org.openstreetmap.josm.gui.progress.NullProgressMonitor;  
    3535import org.openstreetmap.josm.io.IllegalDataException;
    3636import org.openstreetmap.josm.io.OsmReader;
    3737import org.openstreetmap.josm.testutils.JOSMTestRules;
     38import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     39import org.openstreetmap.josm.testutils.annotations.HTTP;
     40import org.openstreetmap.josm.testutils.annotations.Territories;
    3841import org.openstreetmap.josm.tools.MultiMap;
    3942import org.openstreetmap.josm.tools.Utils;
    4043
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    4346/**
    4447 * Unit tests of {@link JoinAreasAction} class.
    4548 */
     49@BasicPreferences
     50@HTTP
     51@Territories(Territories.Initialize.ALL)
    4652class JoinAreasActionTest {
    4753
    4854    /**
    class JoinAreasActionTest {  
    5056     */
    5157    @RegisterExtension
    5258    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    53     public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
     59    public JOSMTestRules test = new JOSMTestRules().main().projection().territories();
    5460
    5561    /**
    5662     * Non-regression test for bug #9599.
    class JoinAreasActionTest {  
    270276        return n1.hasEqualSemanticAttributes(n2);
    271277    }
    272278}
     279
  • test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/JoinNodeWayActionTest.java
    index 680ffad9ce..148f033e3b 100644
    a b import org.openstreetmap.josm.gui.layer.Layer;  
    2727import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2828import org.openstreetmap.josm.io.OsmReader;
    2929import org.openstreetmap.josm.testutils.JOSMTestRules;
     30import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     31import org.openstreetmap.josm.testutils.annotations.HTTP;
     32import org.openstreetmap.josm.testutils.annotations.Territories;
    3033import org.openstreetmap.josm.tools.Geometry;
    3134
    3235import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3437/**
    3538 * Unit tests for class {@link JoinNodeWayAction}.
    3639 */
     40@BasicPreferences
     41@HTTP
     42@Territories(Territories.Initialize.ALL)
    3743final class JoinNodeWayActionTest {
    3844    /**
    3945     * Setup test.
    4046     */
    4147    @RegisterExtension
    4248    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    43     public JOSMTestRules test = new JOSMTestRules().projection().main().preferences();
     49    public JOSMTestRules test = new JOSMTestRules().projection().main();
    4450
    4551    private void setupMapView(DataSet ds) {
    4652        // setup a reasonable size for the edit window
    final class JoinNodeWayActionTest {  
    243249    }
    244250
    245251}
     252
  • test/unit/org/openstreetmap/josm/actions/MergeLayerActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/MergeLayerActionTest.java b/test/unit/org/openstreetmap/josm/actions/MergeLayerActionTest.java
    index f29c869887..acec378b36 100644
    a b import org.openstreetmap.josm.gui.layer.LayerManagerTest.TestLayer;  
    2020import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2121import org.openstreetmap.josm.gui.widgets.JosmComboBox;
    2222import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2324import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    2425import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2526
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2829/**
    2930 * Unit tests for class {@link MergeLayerAction}.
    3031 */
     32@BasicPreferences
    3133public class MergeLayerActionTest {
    3234
    3335    /**
    public class MergeLayerActionTest {  
    123125        assertEquals("Select target layer", invocationLogEntry[2]);
    124126    }
    125127}
     128
  • test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java b/test/unit/org/openstreetmap/josm/actions/PurgeActionTest.java
    index a201b227b8..f9e0278aaf 100644
    a b import org.openstreetmap.josm.io.OsmReader;  
    2020import org.openstreetmap.josm.testutils.JOSMTestRules;
    2121
    2222import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     24import org.openstreetmap.josm.testutils.annotations.HTTP;
     25import org.openstreetmap.josm.testutils.annotations.Territories;
    2326
    2427/**
    2528 * Unit tests for class {@link PurgeAction}.
    2629 */
     30@BasicPreferences
     31@HTTP
     32@Territories(Territories.Initialize.ALL)
    2733class PurgeActionTest {
    2834
    2935    /**
    class PurgeActionTest {  
    3137     */
    3238    @RegisterExtension
    3339    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().main();
     40    public JOSMTestRules test = new JOSMTestRules().main().projection();
    3541
    3642    /**
    3743     * Non-regression test for ticket #12038.
    class PurgeActionTest {  
    6571        }
    6672    }
    6773}
     74
  • test/unit/org/openstreetmap/josm/actions/SelectAllActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/SelectAllActionTest.java b/test/unit/org/openstreetmap/josm/actions/SelectAllActionTest.java
    index 73508d5c86..dcd9fd9072 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    1010import org.openstreetmap.josm.testutils.JOSMTestRules;
    1111
    1212import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1314
    1415/**
    1516 * Unit tests for class {@link SelectAllAction}.
    1617 */
     18@BasicPreferences
    1719final class SelectAllActionTest {
    1820
    1921    /**
    final class SelectAllActionTest {  
    2123     */
    2224    @RegisterExtension
    2325    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    24     public JOSMTestRules rules = new JOSMTestRules().preferences().projection().main();
     26    public JOSMTestRules rules = new JOSMTestRules().projection().main();
    2527
    2628    /**
    2729     * Unit test of {@link SelectAllAction#actionPerformed} method.
    final class SelectAllActionTest {  
    3638        assertEquals(6, ds.getSelected().size());
    3739    }
    3840}
     41
  • test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java b/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java
    index c3e709b7fe..d24eed62f5 100644
    a b import org.openstreetmap.josm.testutils.JOSMTestRules;  
    2121
    2222import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2323import net.trajano.commons.testing.UtilityClassTestUtil;
     24import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2425
    2526/**
    2627 * Unit tests for class {@link SelectByInternalPointAction}.
    2728 */
     29@BasicPreferences
    2830final class SelectByInternalPointActionTest {
    2931
    3032    /**
    final class SelectByInternalPointActionTest {  
    3234     */
    3335    @RegisterExtension
    3436    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules rules = new JOSMTestRules().preferences().projection().main();
     37    public JOSMTestRules rules = new JOSMTestRules().projection().main();
    3638
    3739    /**
    3840     * Tests that {@code SelectByInternalPointAction} satisfies utility class criteria.
    final class SelectByInternalPointActionTest {  
    126128        assertEquals(4, ds.getSelected().size());
    127129    }
    128130}
     131
  • test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java b/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java
    index a224244dba..7551f874c7 100644
    a b import org.openstreetmap.josm.gui.layer.TMSLayer;  
    1111import org.openstreetmap.josm.testutils.JOSMTestRules;
    1212
    1313import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1415
    1516/**
    1617 * Unit tests for class {@link SessionLoadAction}.
    1718 */
     19@BasicPreferences
    1820class SessionLoadActionTest {
    1921
    2022    /**
    class SessionLoadActionTest {  
    3537                ImageryType.TMS.getTypeString(), null, null))));
    3638    }
    3739}
     40
  • test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/SimplifyWayActionTest.java
    index 65842499e7..1fccfbc3de 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    2929import org.openstreetmap.josm.io.IllegalDataException;
    3030import org.openstreetmap.josm.io.OsmReader;
    3131import org.openstreetmap.josm.testutils.JOSMTestRules;
     32import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3233import org.openstreetmap.josm.tools.Utils;
    3334
    3435import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3637/**
    3738 * Unit tests for class {@link SimplifyWayAction}.
    3839 */
     40@BasicPreferences
    3941final class SimplifyWayActionTest {
    4042
    4143    /** Class under test. */
    final class SimplifyWayActionTest {  
    107109        assertEquals(Collections.singleton(n1), deleteCommands.iterator().next().getParticipatingPrimitives());
    108110    }
    109111}
     112
  • test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/SplitWayActionTest.java
    index c7941c5707..31d43cdb87 100644
    a b import org.openstreetmap.josm.data.osm.Way;  
    2020import org.openstreetmap.josm.testutils.JOSMTestRules;
    2121
    2222import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2324
    2425/**
    2526 * Unit tests for class {@link SplitWayAction}.
    2627 */
     28@BasicPreferences
    2729final class SplitWayActionTest {
    2830
    2931    /**
    final class SplitWayActionTest {  
    132134        assertSame(4, dataSet.getWays().size(), String.format("Found %d ways after split action instead of 4.", dataSet.getWays().size()));
    133135    }
    134136}
     137
  • test/unit/org/openstreetmap/josm/actions/UnGlueActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/UnGlueActionTest.java b/test/unit/org/openstreetmap/josm/actions/UnGlueActionTest.java
    index de2f9cb541..739f99606f 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
    1717
    1818import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1920
    2021/**
    2122 * Unit tests for class {@link UnGlueAction}.
    2223 */
     24@BasicPreferences
    2325final class UnGlueActionTest {
    2426
    2527    /** Class under test. */
    final class UnGlueActionTest {  
    3032     */
    3133    @RegisterExtension
    3234    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    33     public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
     35    public JOSMTestRules test = new JOSMTestRules().main().projection();
    3436
    3537    /**
    3638     * Setup test.
    final class UnGlueActionTest {  
    142144        }
    143145    }
    144146}
     147
  • test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskTest.java b/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskTest.java
    index d5c514c34a..0876596848 100644
    a b import java.util.concurrent.ExecutionException;  
    1010import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1314
    1415/**
    1516 * Unit tests for class {@link DownloadOsmTask}.
    1617 */
    1718@BasicWiremock
     19@BasicPreferences
    1820class DownloadOsmTaskTest extends AbstractDownloadTaskTestParent {
    1921
    2022    /**
  • test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskListTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskListTest.java b/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadTaskListTest.java
    index 21d4f7bf55..db00f25610 100644
    a b import java.awt.geom.Area;  
    88import java.util.Collections;
    99
    1010import org.junit.jupiter.api.Test;
    11 import org.junit.jupiter.api.extension.RegisterExtension;
    1211import org.openstreetmap.josm.data.Bounds;
    1312import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1513
    16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1715
    1816/**
    1917 * Unit tests for class {@link DownloadTaskList}.
    2018 */
     19@BasicPreferences
    2120class DownloadTaskListTest {
    22 
    23     /**
    24      * Setup test.
    25      */
    26     @RegisterExtension
    27     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    28     public JOSMTestRules test = new JOSMTestRules();
    29 
    3021    /**
    3122     * Unit test of {@code DownloadTaskList#DownloadTaskList}.
    3223     */
    class DownloadTaskListTest {  
    5344        assertTrue(list.getDownloadedPrimitives().isEmpty());
    5445    }
    5546}
     47
  • test/unit/org/openstreetmap/josm/actions/mapmode/AddNoteActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/AddNoteActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/AddNoteActionTest.java
    index 397e2526f8..145dc0defb 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515
    1616import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1718
    1819/**
    1920 * Unit tests for class {@link AddNoteAction}.
    2021 */
     22@BasicPreferences
    2123class AddNoteActionTest {
    2224
    2325    /**
    class AddNoteActionTest {  
    4648        }
    4749    }
    4850}
     51
  • test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java
    index 5573a73f23..7be9d47520 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616
    1717import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1819
    1920/**
    2021 * Unit tests for class {@link DeleteAction}.
    2122 */
     23@BasicPreferences
    2224class DeleteActionTest {
    2325
    2426    /**
    class DeleteActionTest {  
    5557        TestUtils.superficialEnumCodeCoverage(DeleteMode.class);
    5658    }
    5759}
     60
  • test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/DrawActionTest.java
    index 1907155524..5ad0f10f64 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    2828import org.openstreetmap.josm.testutils.JOSMTestRules;
    2929
    3030import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     31import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3132
    3233/**
    3334 * Unit tests for class {@link DrawAction}.
    3435 */
     36@BasicPreferences
    3537class DrawActionTest {
    3638
    3739    /**
    class DrawActionTest {  
    103105        }
    104106    }
    105107}
     108
  • test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java
    index fbc4dec9ef..2452a1ca85 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616
    1717import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1819
    1920/**
    2021 * Unit tests for class {@link ExtrudeAction}.
    2122 */
     23@BasicPreferences
    2224class ExtrudeActionTest {
    2325
    2426    /**
    class ExtrudeActionTest {  
    5557        TestUtils.superficialEnumCodeCoverage(Mode.class);
    5658    }
    5759}
     60
  • test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java
    index a31055d93c..0ab7735024 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616
    1717import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1819
    1920/**
    2021 * Unit tests for class {@link ImproveWayAccuracyAction}.
    2122 */
     23@BasicPreferences
    2224class ImproveWayAccuracyActionTest {
    2325
    2426    /**
    class ImproveWayAccuracyActionTest {  
    5557        TestUtils.superficialEnumCodeCoverage(State.class);
    5658    }
    5759}
     60
  • test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
    index 0087a928ac..ea54d3fe85 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
    1717
    1818import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1920
    2021/**
    2122 * Unit tests for class {@link ParallelWayAction}.
    2223 */
     24@BasicPreferences
    2325class ParallelWayActionTest {
    2426
    2527    /**
    class ParallelWayActionTest {  
    6466        TestUtils.superficialEnumCodeCoverage(Modifier.class);
    6567    }
    6668}
     69
  • test/unit/org/openstreetmap/josm/actions/mapmode/PlayHeadDragModeTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/PlayHeadDragModeTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/PlayHeadDragModeTest.java
    index 23fa6922f3..836471a8a4 100644
    a b import org.openstreetmap.josm.gui.layer.markerlayer.PlayHeadMarker;  
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515
    1616import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1718
    1819/**
    1920 * Unit tests for class {@link PlayHeadDragMode}.
    2021 */
     22@BasicPreferences
    2123class PlayHeadDragModeTest {
    2224
    2325    /**
    class PlayHeadDragModeTest {  
    4648        }
    4749    }
    4850}
     51
  • test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java b/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
    index 046ba5d151..cb111aa958 100644
    a b import org.openstreetmap.josm.gui.layer.MainLayerManager;  
    2626import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2727import org.openstreetmap.josm.spi.preferences.Config;
    2828import org.openstreetmap.josm.testutils.JOSMTestRules;
     29import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2930import org.openstreetmap.josm.tools.ReflectionUtils;
    3031
    3132import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3334/**
    3435 * Unit tests for class {@link SelectAction}.
    3536 */
     37@BasicPreferences
    3638class SelectActionTest {
    3739
    3840    boolean nodesMerged;
    class SelectActionTest {  
    161163        TestUtils.superficialEnumCodeCoverage(SelectActionCursor.class);
    162164    }
    163165}
     166
  • test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java

    diff --git a/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java b/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java
    index a60e8211fa..a8c3cf9327 100644
    a b import org.openstreetmap.josm.data.osm.Way;  
    2222import org.openstreetmap.josm.testutils.JOSMTestRules;
    2323
    2424import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     25import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2526
    2627/**
    2728 * Unit tests for class {@link FixDataHook}.
    2829 */
     30@BasicPreferences
    2931class FixDataHookTest {
    3032
    3133    /**
    class FixDataHookTest {  
    127129        assertTrue(r2.hasKey("space_both"));
    128130    }
    129131}
     132
  • test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java

    diff --git a/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java b/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java
    index 6e724d8ec4..1dd480cb86 100644
    a b import org.openstreetmap.josm.io.OsmReader;  
    3131import org.openstreetmap.josm.testutils.JOSMTestRules;
    3232
    3333import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     34import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3435
    3536/**
    3637 * Unit tests for class {@link SplitWayCommand}.
    3738 */
     39@BasicPreferences
    3840final class SplitWayCommandTest {
    3941
    4042    /**
    final class SplitWayCommandTest {  
    4244     */
    4345    @RegisterExtension
    4446    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    45     public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
     47    public JOSMTestRules test = new JOSMTestRules().main().projection();
    4648
    4749    /**
    4850     * Unit test of {@link SplitWayCommand#findVias}.
    final class SplitWayCommandTest {  
    434436    }
    435437
    436438}
     439
  • test/unit/org/openstreetmap/josm/data/osm/NodeDataTest.java

    diff --git a/test/unit/org/openstreetmap/josm/data/osm/NodeDataTest.java b/test/unit/org/openstreetmap/josm/data/osm/NodeDataTest.java
    index 88c3300f6e..0760332e44 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.data.osm;
    33
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    45import static org.junit.jupiter.api.Assertions.assertNull;
    56import static org.junit.jupiter.api.Assertions.assertTrue;
    67
    import java.io.IOException;  
    1011import java.io.ObjectInputStream;
    1112import java.io.ObjectOutputStream;
    1213
    13 import org.junit.Assert;
    1414import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.data.coor.LatLon;
     16import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1617
    1718import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1819
     20@BasicPreferences
    1921class NodeDataTest {
    2022
    2123    @SuppressFBWarnings(value = "OBJECT_DESERIALIZATION")
    class NodeDataTest {  
    3739        data.setVersion(14);
    3840        data.setChangesetId(314159);
    3941        final NodeData readData = serializeUnserialize(data);
    40         Assert.assertEquals(data.toString(), readData.toString());
     42        assertEquals(data.toString(), readData.toString());
    4143    }
    4244
    4345    /**
  • test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java b/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java
    index 74b6876655..16c24a685a 100644
    a b import java.util.regex.Pattern;  
    4949import org.junit.jupiter.api.extension.RegisterExtension;
    5050import org.junit.jupiter.api.Test;
    5151import org.openstreetmap.josm.testutils.JOSMTestRules;
     52import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    5253import org.openstreetmap.josm.tools.Logging;
    5354
    5455import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    5859 *
    5960 * @version $Revision: 1723861 $
    6061 */
     62@IntegrationTest
    6163class DomainValidatorTestIT {
    6264
    6365    /**
  • test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java

    diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/CrossingWaysTest.java
    index 30f5e8f8d4..5fdce35a12 100644
    a b import org.openstreetmap.josm.data.validation.tests.CrossingWays.SelfCrossing;  
    2525import org.openstreetmap.josm.data.validation.tests.CrossingWays.Ways;
    2626import org.openstreetmap.josm.io.OsmReader;
    2727import org.openstreetmap.josm.testutils.JOSMTestRules;
     28import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2829
    2930import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3031
    3132/**
    3233 * Unit test of {@link CrossingWays}.
    3334 */
     35@BasicPreferences
    3436class CrossingWaysTest {
    3537
    3638    /**
    class CrossingWaysTest {  
    3840     */
    3941    @RegisterExtension
    4042    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    41     public JOSMTestRules rule = new JOSMTestRules().preferences().projection();
     43    public JOSMTestRules rule = new JOSMTestRules().projection();
    4244
    4345    private static Way newUsableWay(String tags) {
    4446        return TestUtils.newWay(tags, new Node(LatLon.NORTH_POLE), new Node(LatLon.ZERO));
  • test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java
    index 102f5f3118..46f2ca0f91 100644
    a b import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;  
    4242import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    4343import org.openstreetmap.josm.io.OsmReader;
    4444import org.openstreetmap.josm.testutils.JOSMTestRules;
     45import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    4546import org.openstreetmap.josm.tools.Logging;
    4647
    4748import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    4950/**
    5051 * JUnit Test of {@link MapCSSTagChecker}.
    5152 */
     53@BasicPreferences
    5254class MapCSSTagCheckerTest {
    5355
    5456    /**
    class MapCSSTagCheckerTest {  
    5658     */
    5759    @RegisterExtension
    5860    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    59     public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences();
     61    public JOSMTestRules test = new JOSMTestRules().projection().territories();
    6062
    6163    /**
    6264     * Setup test.
  • test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java

    diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/MultipolygonTestTest.java
    index 3d3dd861b7..a97c7114b7 100644
    a b import org.openstreetmap.josm.io.OsmReader;  
    1515import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616
    1717import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1819
    1920/**
    2021 * JUnit Test of Multipolygon validation test.
    2122 */
     23@BasicPreferences
    2224class MultipolygonTestTest {
    2325
    2426
    class MultipolygonTestTest {  
    2729     */
    2830    @RegisterExtension
    2931    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().projection().mapStyles().presets().main().preferences();
     32    public JOSMTestRules test = new JOSMTestRules().projection().mapStyles().presets().main();
    3133
    3234    /**
    3335     * Test all error cases manually created in multipolygon.osm.
    class MultipolygonTestTest {  
    7072        }
    7173    }
    7274}
     75
  • test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java
    index ab467d180a..0f3aff2ba1 100644
    a b import org.openstreetmap.josm.data.validation.TestError;  
    2323import org.openstreetmap.josm.testutils.JOSMTestRules;
    2424
    2525import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2627
    2728/**
    2829 * JUnit Test of {@link TagChecker}.
    2930 */
     31@BasicPreferences
    3032class TagCheckerTest {
    3133
    3234    /**
    class TagCheckerTest {  
    391393        assertFalse(TagChecker.containsUnusualUnicodeCharacter("name", "Yuułuʔiłʔatḥ Lands"));
    392394    }
    393395}
     396
  • test/unit/org/openstreetmap/josm/data/validation/tests/TurnRestrictionTestTest.java

    diff --git a/test/unit/org/openstreetmap/josm/data/validation/tests/TurnRestrictionTestTest.java b/test/unit/org/openstreetmap/josm/data/validation/tests/TurnRestrictionTestTest.java
    index e036a42c73..73337822aa 100644
    a b import org.junit.jupiter.api.Test;  
    66import org.openstreetmap.josm.testutils.JOSMTestRules;
    77
    88import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     9import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    910
    1011/**
    1112 * JUnit Test of turn restriction validation test.
    1213 */
     14@BasicPreferences
    1315class TurnRestrictionTestTest {
    1416
    1517    private static final TurnrestrictionTest TURNRESTRICTION_TEST = new TurnrestrictionTest();
    class TurnRestrictionTestTest {  
    3335                name -> name.startsWith("E"), TURNRESTRICTION_TEST, RELATION_TEST);
    3436    }
    3537}
     38
  • test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java b/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
    index 7afa85a3cc..ede06c3684 100644
    a b import org.openstreetmap.josm.plugins.PluginListParseException;  
    4444import org.openstreetmap.josm.plugins.PluginListParser;
    4545import org.openstreetmap.josm.spi.preferences.Config;
    4646import org.openstreetmap.josm.testutils.JOSMTestRules;
     47import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    4748import org.openstreetmap.josm.tools.Logging;
    4849import org.openstreetmap.josm.tools.PlatformManager;
    4950import org.openstreetmap.josm.tools.Shortcut;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    5354/**
    5455 * Unit tests of {@link MainApplication} class.
    5556 */
     57@BasicPreferences
    5658public class MainApplicationTest {
    5759
    5860    /**
  • test/unit/org/openstreetmap/josm/gui/MapScalerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/MapScalerTest.java b/test/unit/org/openstreetmap/josm/gui/MapScalerTest.java
    index eed8d2c0c2..bb80a7215d 100644
    a b import org.openstreetmap.josm.data.osm.DataSet;  
    1414import org.openstreetmap.josm.gui.MapScaler.AccessibleMapScaler;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1718
    1819import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1920
    2021/**
    2122 * Unit tests of {@link MapScaler} class.
    2223 */
     24@BasicPreferences
    2325class MapScalerTest {
    2426
    2527    /**
  • test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java b/test/unit/org/openstreetmap/josm/gui/NavigatableComponentTest.java
    index bced2a293c..5d8964c8c0 100644
    a b import org.openstreetmap.josm.data.coor.LatLon;  
    2424import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2525import org.openstreetmap.josm.gui.util.GuiHelper;
    2626import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2728
    2829import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2930
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3233 * @author Michael Zangl
    3334 *
    3435 */
     36@BasicPreferences
    3537class NavigatableComponentTest {
    3638
    3739    private static final class NavigatableComponentMock extends NavigatableComponent {
    class NavigatableComponentTest {  
    5557     */
    5658    @RegisterExtension
    5759    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    58     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     60    public JOSMTestRules test = new JOSMTestRules().projection();
    5961
    6062    /**
    6163     * Create a new, fresh {@link NavigatableComponent}
  • test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java b/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java
    index 53fa17f273..aec7b65fb2 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    1818import org.junit.jupiter.api.Test;
    1919import org.openstreetmap.josm.TestUtils;
    2020import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2122import org.openstreetmap.josm.tools.Logging;
    2223import org.openstreetmap.josm.tools.ReflectionUtils;
    2324
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3940 *
    4041 * @see <a href="https://josm.openstreetmap.de/ticket/6301">#6301</a>
    4142 */
     43@BasicPreferences
    4244class TableCellRendererTest {
    4345
    4446    // list of classes that cannot be easily tested and are verified either manually or another unit tests
  • test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java b/test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java
    index c58dcc28b9..c1b02094e1 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1818import org.openstreetmap.josm.testutils.JOSMTestRules;
    1919
    2020import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2122
    2223/**
    2324 * Unit tests of {@link OsmTransferHandler} class.
    2425 */
     26// Prefs for OSM primitives
     27@BasicPreferences
    2528class OsmTransferHandlerTest {
    26     /**
    27      * Prefs to use OSM primitives
    28      */
    2929    @RegisterExtension
    3030    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    31     public JOSMTestRules test = new JOSMTestRules().preferences().projection().main();
     31    public JOSMTestRules test = new JOSMTestRules().projection().main();
    3232
    3333    private final OsmTransferHandler transferHandler = new OsmTransferHandler();
    3434
    class OsmTransferHandlerTest {  
    7272        assertEquals("ok", n.get("test"));
    7373    }
    7474}
     75
  • test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java
    index 56a49140ec..da81bee6d4 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
    1717
    1818import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1920
    2021/**
    2122 * Unit tests of {@link CommandStackDialog} class.
    2223 */
     24@BasicPreferences
    2325class CommandStackDialogTest {
    2426
    2527    /**
    class CommandStackDialogTest {  
    2729     */
    2830    @RegisterExtension
    2931    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
     32    public JOSMTestRules test = new JOSMTestRules().main().projection();
    3133
    3234    /**
    3335     * Unit test of {@link CommandStackDialog} class - empty case.
    class CommandStackDialogTest {  
    113115        }
    114116    }
    115117}
     118
  • test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java
    index 26eca27009..33b544da57 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    2121import org.openstreetmap.josm.testutils.JOSMTestRules;
    2222
    2323import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     24import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2425
    2526/**
    2627 * Unit tests of {@link ConflictDialog} class.
    2728 */
     29@BasicPreferences
    2830class ConflictDialogTest {
    2931
    3032    /**
    class ConflictDialogTest {  
    7375        cp.visit(r);
    7476    }
    7577}
     78
  • test/unit/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialogTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/InspectPrimitiveDialogTest.java
    index b338d3f330..ff2d873346 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    2323import org.openstreetmap.josm.testutils.JOSMTestRules;
    2424
    2525import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2627
    2728/**
    2829 * Unit tests of {@link InspectPrimitiveDialog} class.
    2930 */
     31@BasicPreferences
    3032class InspectPrimitiveDialogTest {
    3133
    3234    /**
    class InspectPrimitiveDialogTest {  
    170172        }
    171173    }
    172174}
     175
  • test/unit/org/openstreetmap/josm/gui/dialogs/MapPaintDialogTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/MapPaintDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/MapPaintDialogTest.java
    index e395bf7378..e37b587ae7 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    99import org.openstreetmap.josm.testutils.JOSMTestRules;
    1010
    1111import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     12import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1213
    1314/**
    1415 * Unit tests of {@link MapPaintDialog} class.
    1516 */
     17@BasicPreferences
    1618class MapPaintDialogTest {
    1719
    1820    /**
    class MapPaintDialogTest {  
    3133        MainApplication.getMap().mapPaintDialog.new InfoAction().actionPerformed(null);
    3234    }
    3335}
     36
  • test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java
    index c2399a6aa3..7bec43b9cf 100644
    a b  
    22package org.openstreetmap.josm.gui.dialogs;
    33
    44import static java.util.concurrent.TimeUnit.MILLISECONDS;
    5 import static org.junit.Assert.assertArrayEquals;
    6 import static org.junit.Assert.assertEquals;
    7 import static org.junit.Assert.assertFalse;
    8 import static org.junit.Assert.assertTrue;
    9 import static org.junit.Assert.fail;
     5import static org.junit.jupiter.api.Assertions.assertArrayEquals;
     6import static org.junit.jupiter.api.Assertions.assertEquals;
     7import static org.junit.jupiter.api.Assertions.assertFalse;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
     9import static org.junit.jupiter.api.Assertions.fail;
    1010import static org.openstreetmap.josm.tools.I18n.tr;
    1111
    1212import java.awt.Color;
    import javax.swing.JMenuItem;  
    2727import javax.swing.JPopupMenu;
    2828
    2929import org.awaitility.Awaitility;
    30 import org.junit.Rule;
    31 import org.junit.Test;
     30import org.junit.jupiter.api.Test;
     31import org.junit.jupiter.api.extension.RegisterExtension;
    3232import org.openstreetmap.josm.TestUtils;
    3333import org.openstreetmap.josm.data.Bounds;
    3434import org.openstreetmap.josm.data.DataSource;
    import org.openstreetmap.josm.gui.util.GuiHelper;  
    4848import org.openstreetmap.josm.spi.preferences.Config;
    4949import org.openstreetmap.josm.testutils.ImagePatternMatching;
    5050import org.openstreetmap.josm.testutils.JOSMTestRules;
     51import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     52import org.openstreetmap.josm.testutils.annotations.FakeImagery;
    5153
    5254import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    5355
    5456/**
    5557 * Unit tests of {@link MinimapDialog} class.
    5658 */
    57 public class MinimapDialogTest {
     59@BasicPreferences
     60@FakeImagery
     61class MinimapDialogTest {
    5862
    5963    /**
    6064     * Setup tests
    6165     */
    62     @Rule
     66    @RegisterExtension
    6367    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    64     public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().fakeImagery();
     68    public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection();
    6569
    6670    /**
    6771     * Unit test of {@link MinimapDialog} class.
    6872     */
    6973    @Test
    70     public void testMinimapDialog() {
     74    void testMinimapDialog() {
    7175        MinimapDialog dlg = new MinimapDialog();
    7276        dlg.showDialog();
    7377        assertTrue(dlg.isVisible());
    public class MinimapDialogTest {  
    101105                boolean isSelected = ((JMenuItem) c).isSelected();
    102106                assertEquals(equalText, isSelected);
    103107                if (equalText) {
    104                     assertFalse("Second selected source found", found);
     108                    assertFalse(found, "Second selected source found");
    105109                    found = true;
    106110                }
    107111            }
    108112        }
    109         assertTrue("Selected source not found in menu", found);
     113        assertTrue(found, "Selected source not found in menu");
    110114    }
    111115
    112116    protected void clickSourceMenuItemByLabel(final String label) {
    public class MinimapDialogTest {  
    198202     * @throws Exception if any error occurs
    199203     */
    200204    @Test
    201     public void testSourceSwitching() throws Exception {
     205    void testSourceSwitching() throws Exception {
    202206        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    203207        // (not that there's a data layer for it to use)
    204208
    public class MinimapDialogTest {  
    245249     * @throws Exception if any error occurs
    246250     */
    247251    @Test
    248     public void testRefreshSourcesRetainsSelection() throws Exception {
     252    void testRefreshSourcesRetainsSelection() throws Exception {
    249253        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    250254        // (not that there's a data layer for it to use)
    251255
    public class MinimapDialogTest {  
    283287     * @throws Exception if any error occurs
    284288     */
    285289    @Test
    286     public void testRemovedSourceStillSelected() throws Exception {
     290    void testRemovedSourceStillSelected() throws Exception {
    287291        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    288292        // (not that there's a data layer for it to use)
    289293
    public class MinimapDialogTest {  
    316320     * @throws Exception if any error occurs
    317321     */
    318322    @Test
    319     public void testTileSourcesFromCurrentLayers() throws Exception {
     323    void testTileSourcesFromCurrentLayers() throws Exception {
    320324        // relevant prefs starting out empty, should choose the first (ImageryLayerInfo) source and have shown download area enabled
    321325        // (not that there's a data layer for it to use)
    322326
    public class MinimapDialogTest {  
    450454     * @throws Exception if any error occurs
    451455     */
    452456    @Test
    453     public void testSourcePrefObeyed() throws Exception {
     457    void testSourcePrefObeyed() throws Exception {
    454458        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    455459
    456460        this.setUpMiniMap();
    public class MinimapDialogTest {  
    477481     * @throws Exception if any error occurs
    478482     */
    479483    @Test
    480     public void testSourcePrefInvalid() throws Exception {
     484    void testSourcePrefInvalid() throws Exception {
    481485        Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles");
    482486
    483487        this.setUpMiniMap();
    public class MinimapDialogTest {  
    499503     * @throws Exception if any error occurs
    500504     */
    501505    @Test
    502     public void testViewportAspectRatio() throws Exception {
     506    void testViewportAspectRatio() throws Exception {
    503507        // Add a test layer to the layer manager to get the MapFrame & MapView
    504508        MainApplication.getLayerManager().addLayer(new TestLayer());
    505509
    public class MinimapDialogTest {  
    545549        // (within a tolerance for numerical error) the number of pixels on the left of the viewport marker
    546550        // should equal the number on the right
    547551        assertTrue(
    548             "Viewport marker not horizontally centered",
    549             Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4
     552            Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4,
     553            "Viewport marker not horizontally centered"
    550554        );
    551555
    552556        Matcher colMatcher = ImagePatternMatching.columnMatch(
    public class MinimapDialogTest {  
    560564        // (within a tolerance for numerical error) the number of pixels on the top of the viewport marker
    561565        // should equal the number on the bottom
    562566        assertTrue(
    563             "Viewport marker not vertically centered",
    564             Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4
     567            Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4,
     568            "Viewport marker not vertically centered"
    565569        );
    566570
    567571        // (within a tolerance for numerical error) the viewport marker should be square
    568572        assertTrue(
    569             "Viewport marker not square",
    570             Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4
     573            Math.abs(colMatcher.group(2).length() - rowMatcher.group(2).length()) < 4,
     574            "Viewport marker not square"
    571575        );
    572576
    573577        // now change the mapView size
    public class MinimapDialogTest {  
    590594            true
    591595        );
    592596        assertTrue(
    593             "Viewport marker not horizontally centered",
    594             Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4
     597            Math.abs(rowMatcher.group(1).length() - rowMatcher.group(3).length()) < 4,
     598            "Viewport marker not horizontally centered"
    595599        );
    596600
    597601        colMatcher = ImagePatternMatching.columnMatch(
    public class MinimapDialogTest {  
    602606            true
    603607        );
    604608        assertTrue(
    605             "Viewport marker not vertically centered",
    606             Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4
     609            Math.abs(colMatcher.group(1).length() - colMatcher.group(3).length()) < 4,
     610            "Viewport marker not vertically centered"
    607611        );
    608612
    609613        try {
    public class MinimapDialogTest {  
    613617        }
    614618
    615619        assertTrue(
    616             "Viewport marker not 2:1 aspect ratio",
    617             Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5
     620            Math.abs(colMatcher.group(2).length() - (rowMatcher.group(2).length()*2.0)) < 5,
     621            "Viewport marker not 2:1 aspect ratio"
    618622        );
    619623    }
    620624
    public class MinimapDialogTest {  
    623627        boolean afterSeparator = false;
    624628        for (Component c: menu.getComponents()) {
    625629            if (JPopupMenu.Separator.class.isInstance(c)) {
    626                 assertFalse("More than one separator before target item", afterSeparator);
     630                assertFalse(afterSeparator, "More than one separator before target item");
    627631                afterSeparator = true;
    628632            } else if (((JMenuItem) c).getText().equals(tr("Show downloaded area"))) {
    629                 assertTrue("Separator not found before target item", afterSeparator);
    630                 assertTrue("Target item doesn't appear to be a JCheckBoxMenuItem", JCheckBoxMenuItem.class.isInstance(c));
     633                assertTrue(afterSeparator, "Separator not found before target item");
     634                assertTrue(JCheckBoxMenuItem.class.isInstance(c), "Target item doesn't appear to be a JCheckBoxMenuItem");
    631635                return (JCheckBoxMenuItem) c;
    632636            }
    633637        }
    public class MinimapDialogTest {  
    640644     * @throws Exception if any error occurs
    641645     */
    642646    @Test
    643     public void testShowDownloadedArea() throws Exception {
     647    void testShowDownloadedArea() throws Exception {
    644648        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    645649        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false);
    646650
    public class MinimapDialogTest {  
    799803     * @throws Exception if any error occurs
    800804     */
    801805    @Test
    802     public void testShowDownloadedAreaLayerSwitching() throws Exception {
     806    void testShowDownloadedAreaLayerSwitching() throws Exception {
    803807        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    804808        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true);
    805809
  • test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanelTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanelTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanelTest.java
    index 146c5a3bad..2b94122872 100644
    a b import org.openstreetmap.josm.testutils.JOSMTestRules;  
    88import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    99import org.junit.jupiter.api.Test;
    1010import org.junit.jupiter.api.extension.RegisterExtension;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1112
    1213/**
    1314 * Unit tests of {@link ChangesetContentPanel} class.
    1415 */
     16@BasicPreferences
    1517class ChangesetContentPanelTest {
    1618
    1719    /**
    class ChangesetContentPanelTest {  
    1921     */
    2022    @RegisterExtension
    2123    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    22     public JOSMTestRules test = new JOSMTestRules().preferences().main();
     24    public JOSMTestRules test = new JOSMTestRules().main();
    2325
    2426    /**
    2527     * Unit test of {@link ChangesetContentPanel#ChangesetContentPanel}.
    class ChangesetContentPanelTest {  
    2931        assertNotNull(new ChangesetContentPanel());
    3032    }
    3133}
     34
  • test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java
    index 62febb878c..62cbc6606a 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.dialogs.layer;
    33
    4 import static org.junit.Assert.assertEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66
    7 import org.junit.Before;
    8 import org.junit.Rule;
    9 import org.junit.Test;
     7import org.junit.jupiter.api.BeforeEach;
     8import org.junit.jupiter.api.Test;
     9import org.junit.jupiter.api.extension.RegisterExtension;
    1010import org.openstreetmap.josm.data.imagery.ImageryInfo;
    1111import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
    1212import org.openstreetmap.josm.data.osm.DataSet;
    import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
    1818
    1919import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     21import org.openstreetmap.josm.testutils.annotations.FakeImagery;
    2022
    2123/**
    2224 * Test class for {@link CycleLayerDownAction}
    2325 *
    2426 * @author Taylor Smock
    2527 */
    26 public class CycleLayerActionTest {
     28@BasicPreferences
     29@FakeImagery
     30class CycleLayerActionTest {
    2731    /** Layers need a projection */
    28     @Rule
     32    @RegisterExtension
    2933    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().fakeImagery();
     34    public JOSMTestRules test = new JOSMTestRules().main().projection();
    3135
    3236    private CycleLayerDownAction cycleDown;
    3337    private CycleLayerUpAction cycleUp;
    public class CycleLayerActionTest {  
    3640    /**
    3741     * Set up common items (make layers, etc.)
    3842     */
    39     @Before
     43    @BeforeEach
    4044    public void setUp() {
    4145        cycleDown = new CycleLayerDownAction();
    4246        cycleUp = new CycleLayerUpAction();
    public class CycleLayerActionTest {  
    5054     * Test going down from the bottom
    5155     */
    5256    @Test
    53     public void testDownBottom() {
     57    void testDownBottom() {
    5458        manager.setActiveLayer(manager.getLayers().get(0));
    5559        cycleDown.actionPerformed(null);
    5660        assertEquals(manager.getLayers().size() - 1, manager.getLayers().indexOf(manager.getActiveLayer()));
    public class CycleLayerActionTest {  
    6064     * Check going up from the top
    6165     */
    6266    @Test
    63     public void testUpTop() {
     67    void testUpTop() {
    6468        manager.setActiveLayer(manager.getLayers().get(manager.getLayers().size() - 1));
    6569        cycleUp.actionPerformed(null);
    6670        assertEquals(0, manager.getLayers().indexOf(manager.getActiveLayer()));
    public class CycleLayerActionTest {  
    7074     * Check going down
    7175     */
    7276    @Test
    73     public void testDown() {
     77    void testDown() {
    7478        manager.setActiveLayer(manager.getLayers().get(3));
    7579        cycleDown.actionPerformed(null);
    7680        assertEquals(2, manager.getLayers().indexOf(manager.getActiveLayer()));
    public class CycleLayerActionTest {  
    8084     * Check going up
    8185     */
    8286    @Test
    83     public void testUp() {
     87    void testUp() {
    8488        manager.setActiveLayer(manager.getLayers().get(3));
    8589        cycleUp.actionPerformed(null);
    8690        assertEquals(4, manager.getLayers().indexOf(manager.getActiveLayer()));
    public class CycleLayerActionTest {  
    9094     * Test no layers
    9195     */
    9296    @Test
    93     public void testNoLayers() {
     97    void testNoLayers() {
    9498        manager.getLayers().forEach(manager::removeLayer);
    9599        cycleUp.actionPerformed(null);
    96100        cycleDown.actionPerformed(null);
    public class CycleLayerActionTest {  
    101105     * Test with an aerial imagery layer
    102106     */
    103107    @Test
    104     public void testWithAerialImagery() {
     108    void testWithAerialImagery() {
    105109        final ImageryInfo magentaTilesInfo = ImageryLayerInfo.instance.getLayers().stream()
    106110                .filter(i -> i.getName().equals("Magenta Tiles")).findAny().get();
    107111        ImageryLayer imageryLayer = ImageryLayer.create(magentaTilesInfo);
  • test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/layer/DuplicateActionTest.java
    index 0e95c82738..eb55970417 100644
    a b import static org.junit.jupiter.api.Assertions.assertNull;  
    88
    99import java.io.InputStream;
    1010
     11import org.junit.jupiter.api.extension.RegisterExtension;
    1112import org.openstreetmap.josm.TestUtils;
    1213import org.openstreetmap.josm.gui.MainApplication;
    1314import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1415import org.openstreetmap.josm.io.OsmReader;
     16import org.openstreetmap.josm.testutils.JOSMTestRules;
    1517import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1618
    1719import org.junit.jupiter.api.Test;
    import org.junit.jupiter.api.Test;  
    2224// TMS layer needs prefs. Platform for LayerListDialog shortcuts.
    2325@BasicPreferences
    2426class DuplicateActionTest {
     27    // Needed for layer cleanup
     28    @RegisterExtension
     29    JOSMTestRules rules = new JOSMTestRules();
    2530    /**
    2631     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/4539">#4539</a>.
    2732     * @throws Exception if an error occurs
    class DuplicateActionTest {  
    2934    @Test
    3035    void testTicket4539() throws Exception {
    3136        try (InputStream is = TestUtils.getRegressionDataStream(4539, "josm_error_#4539.osm.zip")) {
    32             OsmDataLayer layer = new OsmDataLayer(OsmReader.parseDataSet(is, null), null, null);
     37            OsmDataLayer layer = new OsmDataLayer(OsmReader.parseDataSet(is, null), "DuplicateActionTest#testTicket4539", null);
    3338            OsmDataLayer editLayer = MainApplication.getLayerManager().getEditLayer();
    3439            assertNull(editLayer);
    3540            try {
  • test/unit/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/layer/LayerVisibilityActionTest.java
    index 1ee10011a2..a9f09a16ce 100644
    a b import org.openstreetmap.josm.gui.layer.TMSLayerTest;  
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
    1717
    1818import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1920
    2021/**
    2122 * Unit tests of {@link LayerVisibilityAction} class.
    2223 */
     24@BasicPreferences
    2325class LayerVisibilityActionTest {
    2426    /**
    2527     * TMS layer needs prefs. Platform for LayerListDialog shortcuts.
    2628     */
    2729    @RegisterExtension
    2830    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    29     public JOSMTestRules test = new JOSMTestRules().preferences().projection().main();
     31    public JOSMTestRules test = new JOSMTestRules().projection().main();
    3032
    3133    /**
    3234     * Unit test of {@link LayerVisibilityAction} class.
    class LayerVisibilityActionTest {  
    9597        assertEquals(1.0, layer.getOpacity(), 1e-15);
    9698    }
    9799}
     100
  • test/unit/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRendererTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRendererTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/properties/PropertiesCellRendererTest.java
    index 61dd6b0dfc..8789edaa7d 100644
    a b package org.openstreetmap.josm.gui.dialogs.properties;  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import java.util.function.IntFunction;
    7 
    86import javax.swing.JLabel;
    97import javax.swing.JTable;
    108import javax.swing.table.DefaultTableModel;
     9import java.util.function.IntFunction;
    1110
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    1311import org.junit.jupiter.api.Test;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
    15 
    16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     12import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1713
    1814/**
    1915 * Unit tests of {@link PropertiesCellRenderer} class.
    2016 */
     17@BasicPreferences
    2118class PropertiesCellRendererTest {
    22 
    23     /**
    24      * Setup test.
    25      */
    26     @RegisterExtension
    27     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    28     public JOSMTestRules test = new JOSMTestRules().preferences();
    29 
    3019    /**
    3120     * Test of color rendering.
    3221     */
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java
    index ac2a9d4628..0863e616cb 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    2222import org.openstreetmap.josm.gui.tagging.TagEditorPanel;
    2323import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2526import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2627
    2728import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2930/**
    3031 * Unit tests of {@link GenericRelationEditor} class.
    3132 */
     33@BasicPreferences
    3234public class GenericRelationEditorTest {
    3335
    3436    /**
    public class GenericRelationEditorTest {  
    3638     */
    3739    @RegisterExtension
    3840    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    39     public JOSMTestRules test = new JOSMTestRules().preferences().main();
     41    public JOSMTestRules test = new JOSMTestRules().main();
    4042
    4143    /**
    4244     * Returns a new relation editor for unit tests.
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorActionTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorActionTest.java
    index 90bd4ec9e7..6ea4fb20f6 100644
    a b import org.openstreetmap.josm.gui.tagging.TagEditorModel;  
    2323import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    2424import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler;
    2525import org.openstreetmap.josm.testutils.JOSMTestRules;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2627
    2728import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2829
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3132 * @author Michael Zangl
    3233 */
    3334@Disabled
     35@BasicPreferences
    3436public abstract class AbstractRelationEditorActionTest {
    3537    /**
    3638     * Platform for tooltips.
    3739     */
    3840    @RegisterExtension
    3941    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().preferences().main();
     42    public JOSMTestRules test = new JOSMTestRules().main();
    4143
    4244    protected OsmDataLayer layer;
    4345
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/RelationEditorActionsTest.java
    index 398de3afc8..1197c8bb3c 100644
    a b import javax.swing.text.JTextComponent;  
    1414import org.junit.jupiter.api.Test;
    1515import org.openstreetmap.josm.TestUtils;
    1616import org.openstreetmap.josm.gui.ConditionalOptionPaneUtil;
     17import org.openstreetmap.josm.testutils.annotations.I18n;
    1718import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    1819
    1920import mockit.Mock;
    import mockit.MockUp;  
    2223/**
    2324 * Unit tests for relation editor actions.
    2425 */
     26@I18n
    2527class RelationEditorActionsTest extends AbstractRelationEditorActionTest {
    2628
    2729    /**
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
    index c48563391a..19d6cb4a6a 100644
    a b import org.openstreetmap.josm.gui.progress.NullProgressMonitor;  
    1818import org.openstreetmap.josm.io.IllegalDataException;
    1919import org.openstreetmap.josm.io.OsmReader;
    2020import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2122
    2223import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2324
    2425/**
    2526 * Unit tests of {@link RelationSorter} class.
    2627 */
     28@BasicPreferences
    2729class RelationSorterTest {
    2830
    2931    private final RelationSorter sorter = new RelationSorter();
    class RelationSorterTest {  
    3436     */
    3537    @RegisterExtension
    3638    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    37     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     39    public JOSMTestRules test = new JOSMTestRules().projection();
    3840
    3941    /**
    4042     * Load the test data set
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java b/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
    index 624b829e22..e0d30efcc3 100644
    a b import org.openstreetmap.josm.gui.progress.NullProgressMonitor;  
    2424import org.openstreetmap.josm.io.IllegalDataException;
    2525import org.openstreetmap.josm.io.OsmReader;
    2626import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2728
    2829import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2930
    3031/**
    3132 * Unit tests of {@link WayConnectionTypeCalculator} class.
    3233 */
     34@BasicPreferences
    3335class WayConnectionTypeCalculatorTest {
    3436
    3537    private final RelationSorter sorter = new RelationSorter();
    class WayConnectionTypeCalculatorTest {  
    4143     */
    4244    @RegisterExtension
    4345    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    44     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     46    public JOSMTestRules test = new JOSMTestRules().projection();
    4547
    4648    /**
    4749     * Load the test data set
  • test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java b/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java
    index 0eb9f795bb..2293527eee 100644
    a b import org.junit.jupiter.api.Test;  
    1212import org.junit.jupiter.api.extension.RegisterExtension;
    1313import org.openstreetmap.josm.TestUtils;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1516import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    1617import org.openstreetmap.josm.tools.LanguageInfo.LocaleType;
    1718import org.openstreetmap.josm.tools.PlatformHook;
    import mockit.Mocked;  
    2526/**
    2627 * Unit tests of {@link HelpBrowser} class.
    2728 */
     29@BasicPreferences
    2830class HelpBrowserTest {
    2931
    3032    static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help";
    class HelpBrowserTest {  
    3638     */
    3739    @RegisterExtension
    3840    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    39     static JOSMTestRules test = new JOSMTestRules().preferences().https();
     41    static JOSMTestRules test = new JOSMTestRules().https();
    4042
    4143    static IHelpBrowser newHelpBrowser() {
    4244        return new IHelpBrowser() {
  • test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserModelTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserModelTest.java b/test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserModelTest.java
    index 2be15c5a66..6331442a04 100644
    a b import org.openstreetmap.josm.data.osm.history.History;  
    1717import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
    1818import org.openstreetmap.josm.data.osm.history.HistoryNode;
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2021
    2122import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2223
    import java.awt.Color;  
    2526/**
    2627 * Unit tests of {@link HistoryBrowserModel} class.
    2728 */
     29@BasicPreferences
    2830class HistoryBrowserModelTest {
    2931
    3032    /**
    class HistoryBrowserModelTest {  
    3234     */
    3335    @RegisterExtension
    3436    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(30000);
     37    public JOSMTestRules test = new JOSMTestRules().devAPI().timeout(30000);
    3638
    3739    /**
    3840     * Test for {@link HistoryBrowserModel#HistoryBrowserModel}.
  • test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java b/test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java
    index 86997dfbce..917aedf335 100644
    a b import org.openstreetmap.josm.io.OsmHistoryReader;  
    2222import org.openstreetmap.josm.io.OsmServerHistoryReader;
    2323import org.openstreetmap.josm.io.OsmTransferException;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2526import org.xml.sax.SAXException;
    2627
    2728import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2930/**
    3031 * Unit tests of {@link HistoryLoadTask} class.
    3132 */
     33@BasicPreferences
    3234class HistoryLoadTaskTest {
    3335
    3436    /**
    class HistoryLoadTaskTest {  
    3638     */
    3739    @RegisterExtension
    3840    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    39     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000);
     41    public JOSMTestRules test = new JOSMTestRules().devAPI().timeout(20000);
    4042
    4143    /**
    4244     * Unit test of {@link HistoryLoadTask#getLoadingMessage}
  • test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java b/test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java
    index 16d0dcf978..2eac67759f 100644
    a b import org.openstreetmap.josm.TestUtils;  
    1919import org.openstreetmap.josm.data.UserIdentityManager;
    2020import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard;
    2121import org.openstreetmap.josm.testutils.JOSMTestRules;
     22import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2223import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2324import org.openstreetmap.josm.testutils.mockers.WindowMocker;
    2425import org.openstreetmap.josm.tools.UserCancelException;
    import mockit.MockUp;  
    3132/**
    3233 * Unit tests of {@link DownloadOpenChangesetsTask} class.
    3334 */
     35@BasicPreferences
    3436class DownloadOpenChangesetsTaskTest {
    3537
    3638    /**
    class DownloadOpenChangesetsTaskTest {  
    3840     */
    3941    @RegisterExtension
    4042    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    41     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI();
     43    public JOSMTestRules test = new JOSMTestRules().devAPI();
    4244
    4345    /**
    4446     * OAuth wizard mocker.
  • test/unit/org/openstreetmap/josm/gui/io/DownloadPrimitivesTaskTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/io/DownloadPrimitivesTaskTest.java b/test/unit/org/openstreetmap/josm/gui/io/DownloadPrimitivesTaskTest.java
    index 47695f6758..43e197c602 100644
    a b import org.openstreetmap.josm.data.osm.OsmPrimitiveType;  
    1414import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1718
    1819import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1920
    2021/**
    2122 * Unit tests of {@link DownloadPrimitivesTask} class.
    2223 */
     24@BasicPreferences
    2325class DownloadPrimitivesTaskTest {
    2426
    2527    /**
    class DownloadPrimitivesTaskTest {  
    2729     */
    2830    @RegisterExtension
    2931    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000);
     32    public JOSMTestRules test = new JOSMTestRules().devAPI().timeout(20000);
    3133
    3234    /**
    3335     * Test of {@link DownloadPrimitivesTask} class.
  • test/unit/org/openstreetmap/josm/gui/io/UploadDialogModelTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/io/UploadDialogModelTest.java b/test/unit/org/openstreetmap/josm/gui/io/UploadDialogModelTest.java
    index 9223ca87dd..bb08f7221c 100644
    a b import org.junit.jupiter.api.Test;  
    1010
    1111import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1314
    1415/**
    1516 * Unit tests of {@link UploadDialogModel} class.
    1617 */
     18@BasicPreferences
    1719public class UploadDialogModelTest {
    1820    /**
    1921     * Setup tests
    2022     */
    2123    @RegisterExtension
    22     public JOSMTestRules test = new JOSMTestRules().preferences().main();
     24    public JOSMTestRules test = new JOSMTestRules().main();
    2325
    2426    /**
    2527     * Test of {@link UploadDialogModel}.
  • test/unit/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanelTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanelTest.java b/test/unit/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanelTest.java
    index 2f46704710..84a910aa56 100644
    a b import org.junit.jupiter.api.Test;  
    88import org.openstreetmap.josm.io.UploadStrategy;
    99import org.openstreetmap.josm.io.UploadStrategySpecification;
    1010import org.openstreetmap.josm.testutils.JOSMTestRules;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1112
    1213import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1314
    1415/**
    1516 * Unit tests of {@link UploadStrategySelectionPanel} class.
    1617 */
     18@BasicPreferences
    1719class UploadStrategySelectionPanelTest {
    1820
    1921    /**
    class UploadStrategySelectionPanelTest {  
    2123     */
    2224    @RegisterExtension
    2325    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    24     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI();
     26    public JOSMTestRules test = new JOSMTestRules().devAPI();
    2527
    2628    /**
    2729     * Test of {@link UploadStrategySelectionPanel#UploadStrategySelectionPanel}.
  • test/unit/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/AbstractTileSourceLayerTest.java
    index 14ebf64641..a13482bc04 100644
    a b import org.openstreetmap.josm.data.osm.DataSet;  
    3232import org.openstreetmap.josm.gui.MainApplication;
    3333import org.openstreetmap.josm.gui.layer.imagery.ImageryFilterSettings;
    3434import org.openstreetmap.josm.testutils.JOSMTestRules;
     35import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3536
    3637import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3738
    3839/**
    3940 * Test of the base {@link AbstractTileSourceLayer} class
    4041 */
     42@BasicPreferences
    4143class AbstractTileSourceLayerTest {
    4244
    4345    /**
  • test/unit/org/openstreetmap/josm/gui/layer/AutosaveTaskTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/AutosaveTaskTest.java b/test/unit/org/openstreetmap/josm/gui/layer/AutosaveTaskTest.java
    index fa84a4ae91..6ada037c62 100644
    a b import org.openstreetmap.josm.data.osm.Node;  
    2929import org.openstreetmap.josm.gui.MainApplication;
    3030import org.openstreetmap.josm.gui.layer.AutosaveTask.AutosaveLayerInfo;
    3131import org.openstreetmap.josm.testutils.JOSMTestRules;
     32import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3233
    3334import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3435
    3536/**
    3637 * Unit tests for class {@link AutosaveTask}.
    3738 */
     39@BasicPreferences
    3840class AutosaveTaskTest {
    3941    /**
    4042     * We need preferences and a home directory for this.
    4143     */
    4244    @RegisterExtension
    4345    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    44     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     46    public JOSMTestRules test = new JOSMTestRules().projection();
    4547
    4648    private AutosaveTask task;
    4749
  • test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java
    index 98fe1f676d..74d921f986 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    3535import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    3636import org.openstreetmap.josm.io.GpxReaderTest;
    3737import org.openstreetmap.josm.testutils.JOSMTestRules;
     38import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3839import org.openstreetmap.josm.tools.date.DateUtils;
    3940import org.xml.sax.SAXException;
    4041
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    4344/**
    4445 * Unit tests of {@link GpxLayer} class.
    4546 */
     47@BasicPreferences
    4648public class GpxLayerTest {
    4749
    4850    /**
  • test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java
    index 102a629a5e..d3f8160e3a 100644
    a b import org.junit.jupiter.api.Test;  
    1414import org.junit.jupiter.api.extension.RegisterExtension;
    1515import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1718
    1819import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1920
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2122 * Test of the base {@link Layer} class
    2223 * @author Michael Zangl
    2324 */
     25@BasicPreferences
    2426class LayerTest {
    2527    /**
    2628     * We need projection
    2729     */
    2830    @RegisterExtension
    2931    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     32    public JOSMTestRules test = new JOSMTestRules().projection();
    3133
    3234    private Layer testLayer;
    3335
  • test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java
    index 7629c1318d..70f46f655e 100644
    a b import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;  
    3535import org.openstreetmap.josm.io.IllegalDataException;
    3636import org.openstreetmap.josm.io.OsmReader;
    3737import org.openstreetmap.josm.testutils.JOSMTestRules;
     38import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3839import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    3940import org.openstreetmap.josm.tools.Logging;
    4041
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    4344/**
    4445 * Unit tests of {@link OsmDataLayer} class.
    4546 */
     47@BasicPreferences
    4648class OsmDataLayerTest {
    4749
    4850    /**
  • test/unit/org/openstreetmap/josm/gui/layer/TMSLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/TMSLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/TMSLayerTest.java
    index e1c21890e7..f448860786 100644
    a b import org.openstreetmap.josm.data.imagery.ImageryInfo;  
    99import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    1010import org.openstreetmap.josm.gui.MainApplication;
    1111import org.openstreetmap.josm.testutils.JOSMTestRules;
     12import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1213
    1314import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1415
    1516/**
    1617 * Unit tests of {@link TMSLayer} class.
    1718 */
     19@BasicPreferences
    1820public class TMSLayerTest {
    1921
    2022    /**
  • test/unit/org/openstreetmap/josm/gui/layer/ValidatorLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/ValidatorLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/ValidatorLayerTest.java
    index 0f1f9444f3..759a8ef880 100644
    a b import static org.junit.jupiter.api.Assertions.assertFalse;  
    66import static org.junit.jupiter.api.Assertions.assertNotNull;
    77import static org.junit.jupiter.api.Assertions.assertTrue;
    88
    9 import org.junit.jupiter.api.extension.RegisterExtension;
    109import org.junit.jupiter.api.Test;
     10import org.junit.jupiter.api.extension.RegisterExtension;
    1111import org.openstreetmap.josm.data.osm.DataSet;
    1212import org.openstreetmap.josm.gui.MainApplication;
    1313import org.openstreetmap.josm.testutils.JOSMTestRules;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1415
    1516import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1617
    1718/**
    1819 * Unit tests of {@link ValidatorLayer} class.
    1920 */
     21@BasicPreferences
    2022class ValidatorLayerTest {
    2123
    2224    /**
  • test/unit/org/openstreetmap/josm/gui/layer/WMSLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/WMSLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/WMSLayerTest.java
    index b3a72a5129..bbfbb3f773 100644
    a b import org.openstreetmap.josm.data.imagery.ImageryInfo;  
    1010import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    1111import org.openstreetmap.josm.gui.MainApplication;
    1212import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1314
    1415import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1516
    1617/**
    1718 * Unit tests of {@link WMSLayer} class.
    1819 */
     20@BasicPreferences
    1921class WMSLayerTest {
    2022
    2123    /**
  • test/unit/org/openstreetmap/josm/gui/layer/WMTSLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/WMTSLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/WMTSLayerTest.java
    index 225dd0bc6a..af264a0538 100644
    a b package org.openstreetmap.josm.gui.layer;  
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.jupiter.api.extension.RegisterExtension;
    76import org.junit.jupiter.api.Test;
     7import org.junit.jupiter.api.Timeout;
    88import org.openstreetmap.josm.data.imagery.ImageryInfo;
    99import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    10 import org.openstreetmap.josm.testutils.JOSMTestRules;
    11 
    12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     10import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1311
    1412/**
    1513 * Unit tests of {@link WMTSLayer} class.
    1614 */
     15@BasicPreferences
     16@Timeout(20)
    1717class WMTSLayerTest {
    18 
    19     /**
    20      * Setup tests
    21      */
    22     @RegisterExtension
    23     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    24     public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20000);
    25 
    2618    /**
    2719     * Unit test of {@link WMTSLayer#WMTSLayer}.
    2820     */
  • test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java b/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImagesLoaderTest.java
    index 23f26d730e..c46015e625 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    1616import org.openstreetmap.josm.gui.layer.GpxLayer;
    1717import org.openstreetmap.josm.io.GpxReader;
    1818import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1920
    2021import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2122
    2223/**
    2324 * Unit tests of {@link ImagesLoader} class.
    2425 */
     26@BasicPreferences
    2527class ImagesLoaderTest {
    2628
    2729    /**
    28      * We need prefs for this.
     30     * We need prefs for this. And it also cleans up the layers.
    2931     */
    3032    @RegisterExtension
    3133    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    32     public JOSMTestRules test = new JOSMTestRules().preferences();
     34    public JOSMTestRules test = new JOSMTestRules();
    3335
    3436    /**
    3537     * Unit test of {@link ImagesLoader} class.
  • test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java b/test/unit/org/openstreetmap/josm/gui/layer/gpx/ConvertToDataLayerActionTest.java
    index a824478ab3..32eb057cff 100644
    a b import java.util.Objects;  
    1515import java.util.stream.Collectors;
    1616
    1717import org.junit.jupiter.api.Test;
    18 import org.junit.jupiter.api.extension.RegisterExtension;
    1918import org.openstreetmap.josm.TestUtils;
    2019import org.openstreetmap.josm.data.coor.LatLon;
    2120import org.openstreetmap.josm.data.gpx.GpxData;
    import org.openstreetmap.josm.io.GpxReaderTest;  
    2827import org.openstreetmap.josm.io.IllegalDataException;
    2928import org.openstreetmap.josm.io.OsmReader;
    3029import org.openstreetmap.josm.spi.preferences.Config;
    31 import org.openstreetmap.josm.testutils.JOSMTestRules;
     30import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3231import org.xml.sax.SAXException;
    3332
    34 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    35 
    3633/**
    3734 * Unit tests of {@link ConvertToDataLayerAction} class.
    3835 */
     36@BasicPreferences
    3937public class ConvertToDataLayerActionTest {
    40 
    41     /**
    42      * Setup test.
    43      */
    44     @RegisterExtension
    45     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    46     public JOSMTestRules test = new JOSMTestRules();
    47 
    4838    /**
    4939     * Tests a conversion from a GPX marker layer to a OSM dataset
    5040     * @throws Exception if the parsing fails
  • test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java b/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java
    index d0ccb1be8b..67242fbb15 100644
    a b  
    22package org.openstreetmap.josm.gui.layer.gpx;
    33
    44import static java.util.concurrent.TimeUnit.MILLISECONDS;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertNotNull;
    7 import static org.junit.Assert.assertNull;
    8 import static org.junit.Assert.assertTrue;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertNotNull;
     7import static org.junit.jupiter.api.Assertions.assertNull;
     8import static org.junit.jupiter.api.Assertions.assertTrue;
    99
    1010import java.util.Collections;
     11import java.util.List;
    1112
    1213import org.awaitility.Awaitility;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     14import org.junit.jupiter.api.Test;
     15import org.junit.jupiter.api.extension.RegisterExtension;
     16import org.openstreetmap.josm.TestUtils;
    1517import org.openstreetmap.josm.actions.MergeLayerActionTest.MergeLayerExtendedDialogMocker;
    1618import org.openstreetmap.josm.data.gpx.GpxData;
    1719import org.openstreetmap.josm.gui.MainApplication;
    1820import org.openstreetmap.josm.gui.layer.GpxLayerTest;
    1921import org.openstreetmap.josm.gui.layer.TMSLayer;
    2022import org.openstreetmap.josm.gui.layer.gpx.DownloadWmsAlongTrackAction.PrecacheWmsTask;
    21 import org.openstreetmap.josm.TestUtils;
    2223import org.openstreetmap.josm.testutils.JOSMTestRules;
    23 import org.openstreetmap.josm.testutils.TileSourceRule;
     24import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     25import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
     26import org.openstreetmap.josm.testutils.annotations.FakeImagery;
     27import org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource;
    2428import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2529
     30import com.github.tomakehurst.wiremock.WireMockServer;
     31
    2632import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2733
    2834/**
    2935 * Unit tests of {@link DownloadWmsAlongTrackAction} class.
    3036 */
    31 public class DownloadWmsAlongTrackActionTest {
     37@BasicPreferences
     38@FakeImagery
     39class DownloadWmsAlongTrackActionTest {
    3240
    3341    /**
    3442     * Setup test.
    3543     */
    36     @Rule
     44    @RegisterExtension
    3745    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3846    public JOSMTestRules test = new JOSMTestRules().main().projection().fakeImagery().timeout(20000);
    3947
    public class DownloadWmsAlongTrackActionTest {  
    4149     * Test action without layer.
    4250     */
    4351    @Test
    44     public void testNoLayer() {
     52    void testNoLayer() {
    4553        TestUtils.assumeWorkingJMockit();
    4654        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(
    4755            Collections.singletonMap("There are no imagery layers.", 0)
    public class DownloadWmsAlongTrackActionTest {  
    6068     * @throws Exception if an error occurs
    6169     */
    6270    @Test
    63     public void testTMSLayer() throws Exception {
     71    void testTMSLayer(@BasicWiremock final WireMockServer wireMockServer,
     72            @FakeImagery final List<ConstSource> constSources) throws Exception {
    6473        TestUtils.assumeWorkingJMockit();
    6574        final MergeLayerExtendedDialogMocker edMocker = new MergeLayerExtendedDialogMocker();
    6675        edMocker.getMockResultMap().put("Please select the imagery layer.", "Download");
    6776
    68         final TileSourceRule tileSourceRule = this.test.getTileSourceRule();
    69 
    7077        final TMSLayer layer = new TMSLayer(
    71             tileSourceRule.getSourcesList().get(0).getImageryInfo(tileSourceRule.port())
     78                constSources.get(0).getImageryInfo(wireMockServer)
    7279        );
    7380        try {
    7481            MainApplication.getLayerManager().addLayer(layer);
  • test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java b/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java
    index 839fbdd7dc..72a9f32abb 100644
    a b import java.util.List;  
    1111import java.util.Map;
    1212import java.util.stream.Collectors;
    1313
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    1514import org.junit.jupiter.api.Test;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.data.gpx.GpxData;
    1817import org.openstreetmap.josm.gui.layer.GpxLayer;
    1918import org.openstreetmap.josm.gui.layer.gpx.GpxDrawHelper.ColorMode;
    2019import org.openstreetmap.josm.io.GpxReaderTest;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2221import org.openstreetmap.josm.tools.ColorHelper;
    2322import org.xml.sax.SAXException;
    2423
    25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    26 
    2724/**
    2825 * Unit tests of {@link GpxDrawHelper} class.
    2926 */
     27@BasicPreferences
    3028class GpxDrawHelperTest {
    31 
    32     /**
    33      * Setup test.
    34      */
    35     @RegisterExtension
    36     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    37     public JOSMTestRules test = new JOSMTestRules();
    38 
    3929    /**
    4030     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12312">#12312</a>.
    4131     * @throws IOException if any I/O error occurs
  • test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/AudioMarkerTest.java
    index ea04e500e3..7d7b0edc91 100644
    a b import org.openstreetmap.josm.JOSMFixture;  
    1212import org.openstreetmap.josm.data.coor.LatLon;
    1313import org.openstreetmap.josm.data.gpx.GpxData;
    1414import org.openstreetmap.josm.data.gpx.WayPoint;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1516
    1617/**
    1718 * Unit tests of {@link AudioMarker} class.
    1819 */
     20@BasicPreferences
    1921class AudioMarkerTest {
    2022
    2123    /**
  • test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/ImageMarkerTest.java
    index 0df5962e39..4cc210bf3d 100644
    a b import static org.junit.jupiter.api.Assertions.assertEquals;  
    66import java.net.MalformedURLException;
    77import java.net.URL;
    88
    9 import org.junit.jupiter.api.BeforeAll;
    109import org.junit.jupiter.api.Test;
    11 import org.openstreetmap.josm.JOSMFixture;
    1210import org.openstreetmap.josm.data.coor.LatLon;
    1311import org.openstreetmap.josm.data.gpx.GpxData;
    1412import org.openstreetmap.josm.data.gpx.WayPoint;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1514
    1615/**
    1716 * Unit tests of {@link ImageMarker} class.
    1817 */
     18@BasicPreferences
    1919class ImageMarkerTest {
    20 
    21     /**
    22      * Setup tests
    23      */
    24     @BeforeAll
    25     public static void setUpBeforeClass() {
    26         JOSMFixture.createUnitTestFixture().init();
    27     }
    28 
    2920    /**
    3021     * Unit test of {@link ImageMarker#ImageMarker}.
    3122     * @throws MalformedURLException never
  • test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java
    index c6931ec939..bba9167890 100644
    a b import org.openstreetmap.josm.gui.MapFrame;  
    2222import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    2323import org.openstreetmap.josm.spi.preferences.Config;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2526
    2627import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2728
    2829/**
    2930 * Unit tests of {@link MarkerLayer} class.
    3031 */
     32@BasicPreferences
    3133class MarkerLayerTest {
    3234
    3335    /**
    class MarkerLayerTest {  
    3537     */
    3638    @RegisterExtension
    3739    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().main().preferences().projection();
     40    public JOSMTestRules test = new JOSMTestRules().main().projection();
    3941
    4042    /**
    4143     * Setup tests
  • test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java b/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java
    index 21ce309d49..5acc1dbb4f 100644
    a b import org.openstreetmap.josm.data.coor.LatLon;  
    1212import org.openstreetmap.josm.data.gpx.GpxData;
    1313import org.openstreetmap.josm.data.gpx.WayPoint;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1516import org.openstreetmap.josm.tools.PlatformManager;
    1617import org.openstreetmap.josm.tools.PlatformHook;
    1718
    import mockit.Mocked;  
    2425/**
    2526 * Unit tests of {@link WebMarker} class.
    2627 */
     28@BasicPreferences
    2729class WebMarkerTest {
    2830
    2931    /**
    class WebMarkerTest {  
    3133     */
    3234    @RegisterExtension
    3335    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().preferences().https();
     36    public JOSMTestRules test = new JOSMTestRules().https();
    3537
    3638    /**
    3739     * Unit test of {@link WebMarker#WebMarker}.
  • test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java b/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/AllMapCSSTests.java
    index bbb7fe4ea1..6d040e3089 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.mappaint.mapcss;
    33
    4 import org.junit.runner.RunWith;
    5 import org.junit.runners.Suite;
     4import org.junit.platform.suite.api.SelectClasses;
    65
    76/**
    87 * All MapCSS tests.
    98 */
    10 @RunWith(Suite.class)
    11 @Suite.SuiteClasses({
     9@SelectClasses({
    1210    KeyValueConditionTest.class,
    1311    ParsingLinkSelectorTest.class,
    1412    KeyConditionTest.class,
  • test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTestIT.java b/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTestIT.java
    index 6db613fbe7..5561a0a99c 100644
    a b import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser;  
    88import org.openstreetmap.josm.testutils.JOSMTestRules;
    99
    1010import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     11import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    1112
    1213/**
    1314 * Integration tests of {@link MapCSSParser}.
    1415 */
     16@IntegrationTest
    1517class MapCSSParserTestIT {
    1618
    1719    /**
  • test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/advanced/ExportProfileActionTest.java
    index f9be2da17a..dc36fb24e2 100644
    a b import org.junit.jupiter.api.Test;  
    1010import org.openstreetmap.josm.TestUtils;
    1111import org.openstreetmap.josm.data.Preferences;
    1212import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1314import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    1415
    1516import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    1718/**
    1819 * Unit tests of {@link ExportProfileAction} class.
    1920 */
     21@BasicPreferences
    2022class ExportProfileActionTest {
    2123    /**
    2224     * Setup tests
    2325     */
    2426    @RegisterExtension
    2527    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    26     public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT();
     28    public JOSMTestRules test = new JOSMTestRules().assertionsInEDT();
    2729
    2830    /**
    2931     * Unit test of {@link ExportProfileAction#actionPerformed}.
  • test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/advanced/PreferencesTableTest.java
    index 2264a2fe05..cd6c540c9d 100644
    a b import org.openstreetmap.josm.gui.ExtendedDialog;  
    1717import org.openstreetmap.josm.gui.preferences.advanced.PreferencesTable.AllSettingsTableModel;
    1818import org.openstreetmap.josm.spi.preferences.StringSetting;
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2021import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    2122import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2223
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2526/**
    2627 * Unit tests of {@link PreferencesTable} class.
    2728 */
     29@BasicPreferences
    2830class PreferencesTableTest {
    2931    /**
    3032     * Setup tests
    3133     */
    3234    @RegisterExtension
    3335    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT();
     36    public JOSMTestRules test = new JOSMTestRules().assertionsInEDT();
    3537
    3638    private static PrefEntry newPrefEntry(String value) {
    3739        StringSetting val = new StringSetting(value);
  • test/unit/org/openstreetmap/josm/gui/preferences/display/ColorPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/ColorPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/ColorPreferenceTest.java
    index 3cc1540cb4..6627aa4bb5 100644
    a b package org.openstreetmap.josm.gui.preferences.display;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link ColorPreference} class.
    1312 */
     13@BasicPreferences
    1414class ColorPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link ColorPreference#ColorPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/display/DisplayPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/DisplayPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/DisplayPreferenceTest.java
    index 7d95ab5400..eefb29741c 100644
    a b package org.openstreetmap.josm.gui.preferences.display;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link DisplayPreference} class.
    1312 */
     13@BasicPreferences
    1414class DisplayPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link DisplayPreference#DisplayPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/display/DrawingPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/DrawingPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/DrawingPreferenceTest.java
    index c8036c2d31..b882415357 100644
    a b package org.openstreetmap.josm.gui.preferences.display;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link DrawingPreference} class.
    1312 */
     13@BasicPreferences
    1414class DrawingPreferenceTest {
    1515
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2416    /**
    2517     * Unit test of {@link DrawingPreference#DrawingPreference}.
    2618     */
  • test/unit/org/openstreetmap/josm/gui/preferences/display/GPXPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/GPXPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/GPXPreferenceTest.java
    index 7346bb118c..4c1fa12965 100644
    a b package org.openstreetmap.josm.gui.preferences.display;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link GPXPreference} class.
    1312 */
     13@BasicPreferences
    1414class GPXPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link GPXPreference.Factory}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/display/LafPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/LafPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/LafPreferenceTest.java
    index bb0e1e37f7..16145335a5 100644
    a b package org.openstreetmap.josm.gui.preferences.display;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link LafPreference} class.
    1312 */
     13@BasicPreferences
    1414class LafPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link LafPreference#LafPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/display/LanguagePreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/display/LanguagePreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/display/LanguagePreferenceTest.java
    index f1ff6df7b2..8844d1856e 100644
    a b package org.openstreetmap.josm.gui.preferences.display;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link LanguagePreference} class.
    1312 */
     13@BasicPreferences
    1414class LanguagePreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link LanguagePreference#LanguagePreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTest.java
    index fe01b7e3b6..d1467f6d89 100644
    a b import org.openstreetmap.josm.TestUtils;  
    1212import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
    1313import org.openstreetmap.josm.spi.preferences.Config;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1516
    1617import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1718
    1819/**
    1920 * Unit tests of {@link ImageryPreference} class.
    2021 */
     22@BasicPreferences
    2123class ImageryPreferenceTest {
    2224
    2325    /**
  • test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java
    index e667e2310b..6d2d350108 100644
    a b import org.openstreetmap.josm.data.projection.Projections;  
    6565import org.openstreetmap.josm.io.imagery.ApiKeyProvider;
    6666import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException;
    6767import org.openstreetmap.josm.testutils.JOSMTestRules;
     68import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    6869import org.openstreetmap.josm.tools.HttpClient;
    6970import org.openstreetmap.josm.tools.HttpClient.Response;
    7071import org.openstreetmap.josm.tools.Logging;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    7576/**
    7677 * Integration tests of {@link ImageryPreference} class.
    7778 */
     79@IntegrationTest
    7880public class ImageryPreferenceTestIT {
    7981
    8082    private static final String ERROR_SEP = " -> ";
  • test/unit/org/openstreetmap/josm/gui/preferences/map/BackupPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/BackupPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/BackupPreferenceTest.java
    index 12ddd6c475..2f54b22edc 100644
    a b package org.openstreetmap.josm.gui.preferences.map;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link BackupPreference} class.
    1312 */
     13@BasicPreferences
    1414class BackupPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link BackupPreference#BackupPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java
    index e3e668c0a7..913f2a0497 100644
    a b import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCas  
    2525import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule;
    2626import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    2727import org.openstreetmap.josm.testutils.JOSMTestRules;
     28import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2829import org.openstreetmap.josm.tools.ImageProvider;
    2930
    3031import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3233/**
    3334 * Integration tests of {@link MapPaintPreference} class.
    3435 */
     36@IntegrationTest
    3537class MapPaintPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    3638
    3739    /**
  • test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTest.java
    index 74bdb1d8c5..d341635d41 100644
    a b package org.openstreetmap.josm.gui.preferences.map;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link TaggingPresetPreference} class.
    1312 */
     13@BasicPreferences
    1414class TaggingPresetPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link TaggingPresetPreference#TaggingPresetPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java
    index 3e714bd3c8..871524deb7 100644
    a b import java.util.HashSet;  
    1414import java.util.List;
    1515import java.util.Locale;
    1616import java.util.Set;
     17import java.util.concurrent.TimeUnit;
    1718
    1819import org.junit.jupiter.api.BeforeAll;
     20import org.junit.jupiter.api.Timeout;
    1921import org.junit.jupiter.api.extension.RegisterExtension;
    2022import org.junit.jupiter.params.ParameterizedTest;
    2123import org.junit.jupiter.params.provider.MethodSource;
    import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetsTest;  
    2830import org.openstreetmap.josm.gui.tagging.presets.items.Link;
    2931import org.openstreetmap.josm.spi.preferences.Config;
    3032import org.openstreetmap.josm.testutils.JOSMTestRules;
     33import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     34import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    3135import org.openstreetmap.josm.tools.HttpClient;
    3236import org.openstreetmap.josm.tools.HttpClient.Response;
    3337import org.openstreetmap.josm.tools.ImageProvider;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3943/**
    4044 * Integration tests of {@link TaggingPresetPreference} class.
    4145 */
     46@IntegrationTest
     47@BasicPreferences
     48@Timeout(value = 20, unit = TimeUnit.MINUTES)
    4249class TaggingPresetPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    4350
    4451    /**
    class TaggingPresetPreferenceTestIT extends AbstractExtendedSourceEntryTestCase  
    4653     */
    4754    @RegisterExtension
    4855    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    49     public static JOSMTestRules test = new JOSMTestRules().https().timeout(10000*120).parameters();
     56    public static JOSMTestRules test = new JOSMTestRules().https().parameters();
    5057
    5158    /**
    5259     * Setup test
  • test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceHighLevelTest.java
    index 1bdab05056..0df7137c36 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.preferences.plugin;
    33
    4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
    54import static java.util.concurrent.TimeUnit.MILLISECONDS;
    6 import static org.junit.Assert.assertEquals;
    7 import static org.junit.Assert.assertFalse;
    8 import static org.junit.Assert.assertTrue;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertTrue;
    98
    109import java.awt.Component;
    1110import java.io.File;
    import java.util.stream.Collectors;  
    1817
    1918import javax.swing.JOptionPane;
    2019
     20import com.github.tomakehurst.wiremock.WireMockServer;
     21import com.github.tomakehurst.wiremock.client.WireMock;
     22import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     23import mockit.MockUp;
    2124import org.awaitility.Awaitility;
    22 import org.junit.After;
    23 import org.junit.Before;
    24 import org.junit.Rule;
    25 import org.junit.Test;
     25import org.junit.jupiter.api.AfterEach;
     26import org.junit.jupiter.api.BeforeEach;
     27import org.junit.jupiter.api.Test;
     28import org.junit.jupiter.api.extension.RegisterExtension;
    2629import org.openstreetmap.josm.TestUtils;
    2730import org.openstreetmap.josm.data.Preferences;
    2831import org.openstreetmap.josm.gui.preferences.PreferenceTabbedPane;
    import org.openstreetmap.josm.plugins.PluginProxy;  
    3336import org.openstreetmap.josm.spi.preferences.Config;
    3437import org.openstreetmap.josm.testutils.JOSMTestRules;
    3538import org.openstreetmap.josm.testutils.PluginServer;
     39import org.openstreetmap.josm.testutils.annotations.AssumeRevision;
     40import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     41import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
    3642import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
    3743import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    3844
    39 import com.github.tomakehurst.wiremock.client.WireMock;
    40 import com.github.tomakehurst.wiremock.junit.WireMockRule;
    41 
    42 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    43 import mockit.MockUp;
    44 
    4545/**
    4646 * Higher level tests of {@link PluginPreference} class.
    4747 */
    48 public class PluginPreferenceHighLevelTest {
     48@AssumeRevision("Revision: 10000\n")
     49@BasicPreferences(true)
     50@BasicWiremock
     51class PluginPreferenceHighLevelTest {
    4952    /**
    5053     * Setup test.
    5154     */
    52     @Rule
     55    @RegisterExtension
    5356    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public JOSMTestRules test = new JOSMTestRules().assumeRevision(
    55         "Revision: 10000\n"
    56     ).preferences().main().assertionsInEDT();
     57    public JOSMTestRules test = new JOSMTestRules().main().assertionsInEDT();
    5758
    5859    /**
    5960     * Plugin server mock.
    6061     */
    61     @Rule
    62     public WireMockRule pluginServerRule = new WireMockRule(
    63         options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot())
    64     );
     62    @BasicWiremock
     63    public WireMockServer pluginServerRule;
    6564
    6665    /**
    6766     * Setup test.
    6867     * @throws ReflectiveOperationException never
    6968     */
    70     @Before
     69    @BeforeEach
    7170    public void setUp() throws ReflectiveOperationException {
    7271
    7372        // some other tests actually go ahead and load plugins (notably at time of writing,
    public class PluginPreferenceHighLevelTest {  
    106105     * Tear down.
    107106     * @throws ReflectiveOperationException never
    108107     */
    109     @After
     108    @AfterEach
    110109    public void tearDown() throws ReflectiveOperationException {
    111110        // restore actual PluginHandler#pluginList
    112111        @SuppressWarnings("unchecked")
    public class PluginPreferenceHighLevelTest {  
    135134     * @throws Exception never
    136135     */
    137136    @Test
    138     public void testInstallWithoutUpdate() throws Exception {
     137    void testInstallWithoutUpdate() throws Exception {
    139138        final PluginServer pluginServer = new PluginServer(
    140139            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
    141140            new PluginServer.RemotePlugin(this.referenceBazJarOld),
    public class PluginPreferenceHighLevelTest {  
    169168        Awaitility.await().atMost(2000, MILLISECONDS).until(() -> Config.getPref().getInt("pluginmanager.version", 999) != 999);
    170169
    171170        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    172         WireMock.resetAllRequests();
     171        this.pluginServerRule.resetRequests();
    173172
    174173        final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField(
    175174            tabbedPane.getPluginPreference(),
    public class PluginPreferenceHighLevelTest {  
    256255     * @throws Exception never
    257256     */
    258257    @Test
    259     public void testDisablePluginWithUpdatesAvailable() throws Exception {
     258    void testDisablePluginWithUpdatesAvailable() throws Exception {
    260259        final PluginServer pluginServer = new PluginServer(
    261260            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
    262261            new PluginServer.RemotePlugin(this.referenceBazJarNew),
    public class PluginPreferenceHighLevelTest {  
    289288        Awaitility.await().atMost(2000, MILLISECONDS).until(() -> Config.getPref().getInt("pluginmanager.version", 999) != 999);
    290289
    291290        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    292         WireMock.resetAllRequests();
     291        this.pluginServerRule.resetRequests();
    293292
    294293        final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField(
    295294            tabbedPane.getPluginPreference(),
    public class PluginPreferenceHighLevelTest {  
    378377     * @throws Exception never
    379378     */
    380379    @Test
    381     public void testUpdateOnlySelectedPlugin() throws Exception {
     380    void testUpdateOnlySelectedPlugin() throws Exception {
    382381        TestUtils.assumeWorkingJMockit();
    383382        final PluginServer pluginServer = new PluginServer(
    384383            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
    public class PluginPreferenceHighLevelTest {  
    406405        TestUtils.syncEDTAndWorkerThreads();
    407406
    408407        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    409         WireMock.resetAllRequests();
     408        this.pluginServerRule.resetRequests();
    410409
    411410        final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField(
    412411            tabbedPane.getPluginPreference(),
    public class PluginPreferenceHighLevelTest {  
    485484        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/dummy_plugin.v31772.jar")));
    486485        // baz_plugin has not
    487486        this.pluginServerRule.verify(0, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/baz_plugin.v7.jar")));
    488         WireMock.resetAllRequests();
     487        this.pluginServerRule.resetRequests();
    489488
    490489        // pluginmanager.version has been set to the current version
    491490        // questionably correct
    public class PluginPreferenceHighLevelTest {  
    566565     * @throws Exception never
    567566     */
    568567    @Test
    569     public void testUpdateWithNoAvailableUpdates() throws Exception {
     568    void testUpdateWithNoAvailableUpdates() throws Exception {
    570569        TestUtils.assumeWorkingJMockit();
    571570        final PluginServer pluginServer = new PluginServer(
    572571            new PluginServer.RemotePlugin(this.referenceDummyJarOld),
    public class PluginPreferenceHighLevelTest {  
    600599        TestUtils.syncEDTAndWorkerThreads();
    601600
    602601        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    603         WireMock.resetAllRequests();
     602        this.pluginServerRule.resetRequests();
    604603
    605604        final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField(
    606605            tabbedPane.getPluginPreference(),
    public class PluginPreferenceHighLevelTest {  
    656655        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    657656        // that should have been the only request to our PluginServer
    658657        assertEquals(1, this.pluginServerRule.getAllServeEvents().size());
    659         WireMock.resetAllRequests();
     658        this.pluginServerRule.resetRequests();
    660659
    661660        // pluginmanager.version has been set to the current version
    662661        assertEquals(10000, Config.getPref().getInt("pluginmanager.version", 111));
    public class PluginPreferenceHighLevelTest {  
    705704     * @throws Exception never
    706705     */
    707706    @Test
    708     public void testInstallWithoutRestartRequired() throws Exception {
     707    void testInstallWithoutRestartRequired() throws Exception {
    709708        TestUtils.assumeWorkingJMockit();
    710709        final boolean[] loadPluginsCalled = new boolean[] {false};
    711710        new MockUp<PluginHandler>() {
    public class PluginPreferenceHighLevelTest {  
    749748        TestUtils.syncEDTAndWorkerThreads();
    750749
    751750        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    752         WireMock.resetAllRequests();
     751        this.pluginServerRule.resetRequests();
    753752
    754753        final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField(
    755754            tabbedPane.getPluginPreference(),
    public class PluginPreferenceHighLevelTest {  
    825824     * preventing us from using the latest version
    826825     * @throws Exception on failure
    827826     */
    828     @JOSMTestRules.OverrideAssumeRevision("Revision: 7000\n")
     827    @AssumeRevision("Revision: 7000\n")
    829828    @Test
    830     public void testInstallMultiVersion() throws Exception {
     829    void testInstallMultiVersion() throws Exception {
    831830        TestUtils.assumeWorkingJMockit();
    832831
    833832        final String bazOldServePath = "/baz/old.jar";
    public class PluginPreferenceHighLevelTest {  
    870869        TestUtils.syncEDTAndWorkerThreads();
    871870
    872871        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    873         WireMock.resetAllRequests();
     872        this.pluginServerRule.resetRequests();
    874873
    875874        final PluginPreferencesModel model = (PluginPreferencesModel) TestUtils.getPrivateField(
    876875            tabbedPane.getPluginPreference(),
  • test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java
    index fc602eae74..d0d2e5a817 100644
    a b import org.openstreetmap.josm.plugins.PluginDownloadTask;  
    1818import org.openstreetmap.josm.plugins.PluginException;
    1919import org.openstreetmap.josm.plugins.PluginInformation;
    2020import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2122import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
    2223
    2324import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2526/**
    2627 * Unit tests of {@link PluginPreference} class.
    2728 */
     29@BasicPreferences
    2830public class PluginPreferenceTest {
    2931    /**
    3032     * Setup test.
    3133     */
    3234    @RegisterExtension
    3335    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().preferences().assertionsInEDT();
     36    public JOSMTestRules test = new JOSMTestRules().assertionsInEDT();
    3537
    3638    /**
    3739     * Unit test of {@link PluginPreference#PluginPreference}.
  • test/unit/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/projection/ProjectionPreferenceTest.java
    index 3ebd2f214a..c5762b1904 100644
    a b package org.openstreetmap.josm.gui.preferences.projection;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link ProjectionPreference} class.
    1312 */
     13@BasicPreferences
    1414class ProjectionPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link ProjectionPreference#ProjectionPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/remotecontrol/RemoteControlPreferenceTest.java
    index f884389305..206ff41cc3 100644
    a b package org.openstreetmap.josm.gui.preferences.remotecontrol;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link RemoteControlPreference} class.
    1312 */
     13@BasicPreferences
    1414class RemoteControlPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link RemoteControlPreference#RemoteControlPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorPreferenceTest.java
    index 735689b2a5..0206638a5c 100644
    a b package org.openstreetmap.josm.gui.preferences.validator;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link ValidatorPreference} class.
    1312 */
     13@BasicPreferences
    1414class ValidatorPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link ValidatorPreference#ValidatorPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java b/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java
    index 677cc11049..fcf25a975c 100644
    a b import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCas  
    2626import org.openstreetmap.josm.testutils.JOSMTestRules;
    2727
    2828import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     29import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2930
    3031/**
    3132 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
    3233 */
     34@IntegrationTest
    3335class ValidatorTagCheckerRulesPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    3436
    3537    /**
  • test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreferenceTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreferenceTest.java b/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTestsPreferenceTest.java
    index 3c03344059..4538f3c5ba 100644
    a b package org.openstreetmap.josm.gui.preferences.validator;  
    33
    44import static org.junit.jupiter.api.Assertions.assertNotNull;
    55
    6 import org.junit.jupiter.api.BeforeAll;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.JOSMFixture;
    97import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils;
     8import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    109
    1110/**
    1211 * Unit tests of {@link ValidatorTestsPreference} class.
    1312 */
     13@BasicPreferences
    1414class ValidatorTestsPreferenceTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @BeforeAll
    20     public static void setUpBeforeClass() {
    21         JOSMFixture.createUnitTestFixture().init();
    22     }
    23 
    2415    /**
    2516     * Unit test of {@link ValidatorTestsPreference#ValidatorTestsPreference}.
    2617     */
  • test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/PresetClassificationsTest.java
    index eba467c4f4..d912fd9ff2 100644
    a b import java.util.stream.Collectors;  
    1313
    1414import org.junit.jupiter.api.BeforeAll;
    1515import org.junit.jupiter.api.Test;
    16 import org.openstreetmap.josm.JOSMFixture;
    1716import org.openstreetmap.josm.data.osm.Node;
    1817import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1918import org.openstreetmap.josm.data.osm.OsmUtils;
    2019import org.openstreetmap.josm.data.osm.Way;
    2120import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassification;
    2221import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetSelector.PresetClassifications;
     22import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2323import org.xml.sax.SAXException;
    2424
    2525/**
    2626 * Unit tests of {@link PresetClassifications} class.
    2727 */
     28@BasicPreferences
    2829class PresetClassificationsTest {
    2930
    3031    static final PresetClassifications classifications = new PresetClassifications();
    class PresetClassificationsTest {  
    3637     */
    3738    @BeforeAll
    3839    public static void setUp() throws IOException, SAXException {
    39         JOSMFixture.createUnitTestFixture().init();
    4040        final Collection<TaggingPreset> presets = TaggingPresetReader.readAll("resource://data/defaultpresets.xml", true);
    4141        classifications.loadPresets(presets);
    4242    }
  • test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java
    index c4cf522762..8f42792ba1 100644
    a b import java.util.Collection;  
    1212import java.util.List;
    1313import java.util.stream.Collectors;
    1414
    15 import org.junit.Assert;
    1615import org.junit.jupiter.api.Test;
    17 import org.junit.jupiter.api.extension.RegisterExtension;
    1816import org.openstreetmap.josm.TestUtils;
    1917import org.openstreetmap.josm.gui.tagging.presets.items.Check;
    2018import org.openstreetmap.josm.gui.tagging.presets.items.Key;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2220import org.xml.sax.SAXException;
    2321
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    25 
    2622/**
    2723 * Unit tests of {@link TaggingPresetReader} class.
    2824 */
     25@BasicPreferences
    2926class TaggingPresetReaderTest {
    30 
    31     /**
    32      * Setup rule
    33      */
    34     @RegisterExtension
    35     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules();
    37 
    3827    /**
    3928     * #8954 - last checkbox in the preset is not added
    4029     * @throws SAXException if any XML error occurs
    class TaggingPresetReaderTest {  
    4433    void testTicket8954() throws SAXException, IOException {
    4534        String presetfile = TestUtils.getRegressionDataFile(8954, "preset.xml");
    4635        final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, false);
    47         Assert.assertEquals("Number of preset items", 1, presets.size());
     36        assertEquals(1, presets.size(), "Number of preset items");
    4837        final TaggingPreset preset = presets.iterator().next();
    49         Assert.assertEquals("Number of entries", 1, preset.data.size());
     38        assertEquals(1, preset.data.size(), "Number of entries");
    5039        final TaggingPresetItem item = preset.data.get(0);
    51         Assert.assertTrue("Entry is not checkbox", item instanceof Check);
     40        assertTrue(item instanceof Check, "Entry is not checkbox");
    5241    }
    5342
    5443    /**
    class TaggingPresetReaderTest {  
    9281    void testReadDefaulPresets() throws SAXException, IOException {
    9382        String presetfile = "resource://data/defaultpresets.xml";
    9483        final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(presetfile, true);
    95         Assert.assertTrue("Default presets are empty", presets.size() > 0);
     84        assertTrue(presets.size() > 0, "Default presets are empty");
    9685    }
    9786}
  • test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/CheckTest.java
    index 8fae5a60d0..5e6e30ed4b 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    1010import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport;
    1212import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1314
    1415import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1516
    1617/**
    1718 * Unit tests of {@link Check} class.
    1819 */
     20@BasicPreferences
    1921class CheckTest {
    2022
    2123    /**
  • test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/ComboTest.java
    index feabfa1bea..689503a9fa 100644
    a b import org.openstreetmap.josm.data.osm.OsmPrimitive;  
    1414import org.openstreetmap.josm.data.osm.OsmUtils;
    1515import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport;
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1718
    1819import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1920
    2021/**
    2122 * Unit tests of {@link Combo} class.
    2223 */
     24@BasicPreferences
    2325class ComboTest {
    2426
    2527    /**
  • test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetLinkTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetLinkTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/PresetLinkTest.java
    index 66c151189d..93afd59cf3 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    1111import org.junit.jupiter.api.Test;
    1212import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport;
    1313import org.openstreetmap.josm.testutils.JOSMTestRules;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1415
    1516import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1617
    1718/**
    1819 * Unit tests of {@link PresetLink} class.
    1920 */
     21@BasicPreferences
    2022class PresetLinkTest {
    2123
    2224    /**
  • test/unit/org/openstreetmap/josm/gui/tagging/presets/items/TextTest.java

    diff --git a/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/TextTest.java b/test/unit/org/openstreetmap/josm/gui/tagging/presets/items/TextTest.java
    index 6979cad768..64d201a277 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    1010import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetItemGuiSupport;
    1212import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1314
    1415import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1516
    1617/**
    1718 * Unit tests of {@link Text} class.
    1819 */
     20@BasicPreferences
    1921class TextTest {
    2022
    2123    /**
  • test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java b/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java
    index 90d640e298..16b4107e32 100644
    a b import org.openstreetmap.josm.TestUtils;  
    1919import org.openstreetmap.josm.testutils.JOSMTestRules;
    2020
    2121import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     22import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2223
    2324/**
    2425 * Integration tests of {@link CertificateAmendment} class.
    2526 */
     27@IntegrationTest
    2628class CertificateAmendmentTestIT {
    2729
    2830    /**
  • test/unit/org/openstreetmap/josm/io/NameFinderTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/NameFinderTest.java b/test/unit/org/openstreetmap/josm/io/NameFinderTest.java
    index 8a3f0569fa..dee6b497ca 100644
    a b import java.util.Arrays;  
    88import java.util.stream.Collectors;
    99
    1010import org.junit.jupiter.api.Test;
    11 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1211
    1312/**
    1413 * Unit tests of {@link NameFinder} class.
    1514 */
    16 @BasicPreferences
    1715class NameFinderTest {
    1816
    1917    // CHECKSTYLE.OFF: LineLength
  • test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java b/test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java
    index 22ddf1a670..dc722476f1 100644
    a b import java.util.Map;  
    1212import org.junit.jupiter.api.extension.RegisterExtension;
    1313import org.junit.jupiter.api.Test;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1516
    1617import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1718
    1819/**
    1920 * Unit tests of {@link NetworkManager} class.
    2021 */
     22@BasicPreferences
    2123class NetworkManagerTest {
    2224
    2325    /**
  • test/unit/org/openstreetmap/josm/io/ValidatorErrorWriterTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/ValidatorErrorWriterTest.java b/test/unit/org/openstreetmap/josm/io/ValidatorErrorWriterTest.java
    index 0385968622..c90799bd47 100644
    a b import java.util.Collections;  
    1212import java.util.Locale;
    1313
    1414import org.junit.jupiter.api.Test;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.openstreetmap.josm.data.coor.LatLon;
    1716import org.openstreetmap.josm.data.osm.Node;
    1817import org.openstreetmap.josm.data.validation.Severity;
    1918import org.openstreetmap.josm.data.validation.TestError;
    2019import org.openstreetmap.josm.data.validation.tests.RightAngleBuildingTest;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
    22 
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2421
    2522/**
    2623 * Unit tests of {@link ValidatorErrorWriter}
    2724 */
     25@BasicPreferences
    2826class ValidatorErrorWriterTest {
    29 
    30     /**
    31      * Setup rule
    32      */
    33     @RegisterExtension
    34     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().preferences();
    36 
    3727    @Test
    3828    void testEmpty() throws IOException {
    3929        doTest(Collections.emptyList(), "");
  • test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
    index 583ab5f393..c03f1311a7 100644
    a b import org.junit.jupiter.api.Test;  
    1616import org.junit.jupiter.api.extension.RegisterExtension;
    1717import org.openstreetmap.josm.spi.preferences.Config;
    1818import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1920import org.openstreetmap.josm.tools.Utils;
    2021
    2122import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2324/**
    2425 * Unit tests for Remote Control
    2526 */
     27@BasicPreferences
    2628class RemoteControlTest {
    2729
    2830    private String httpBase;
    class RemoteControlTest {  
    3234     */
    3335    @RegisterExtension
    3436    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().preferences().https().assertionsInEDT();
     37    public JOSMTestRules test = new JOSMTestRules().https().assertionsInEDT();
    3638
    3739    /**
    3840     * Starts Remote control before testing requests.
  • test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java
    index 976134f011..9e09ba66f4 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    1212import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1313import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1516
    1617import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1718
    1819/**
    1920 * Unit tests of {@link AddNodeHandler} class.
    2021 */
     22@BasicPreferences
    2123class AddNodeHandlerTest {
    2224    /**
    2325     * Setup test.
  • test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java b/test/unit/org/openstreetmap/josm/io/remotecontrol/handler/ImportHandlerTest.java
    index 625759f3f6..f81e8c7409 100644
    a b import org.openstreetmap.josm.gui.MainApplication;  
    1414import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1515import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
    1616import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1718import org.openstreetmap.josm.tools.Utils;
    1819
    1920import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2122/**
    2223 * Unit tests of {@link ImportHandler} class.
    2324 */
     25@BasicPreferences
    2426class ImportHandlerTest {
    2527    /**
    2628     * Setup test.
  • test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java b/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java
    index acf5f77170..69158c461a 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    2727import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    2828import org.openstreetmap.josm.io.IllegalDataException;
    2929import org.openstreetmap.josm.testutils.JOSMTestRules;
     30import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3031
    3132import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3233
    3334/**
    3435 * Unit tests for Session reading.
    3536 */
     37@BasicPreferences
    3638class SessionReaderTest {
    3739
    3840    /**
  • test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java

    diff --git a/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java b/test/unit/org/openstreetmap/josm/io/session/SessionWriterTest.java
    index 0cce3b77de..3a41c0b374 100644
    a b import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    3737import org.openstreetmap.josm.gui.layer.TMSLayer;
    3838import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    3939import org.openstreetmap.josm.testutils.JOSMTestRules;
     40import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    4041import org.openstreetmap.josm.tools.MultiMap;
    4142import org.openstreetmap.josm.tools.Utils;
    4243
    import static org.junit.jupiter.api.Assertions.assertEquals;  
    4748/**
    4849 * Unit tests for Session writing.
    4950 */
     51@BasicPreferences
    5052class SessionWriterTest {
    5153
    5254    protected static final class OsmHeadlessJosExporter extends OsmDataSessionExporter {
  • test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java

    diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerJOSMTooOldTest.java
    index 5dffde15f8..210261104f 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins;
    33
    4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertNotEquals;
     4
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertNotEquals;
    88
    99import java.io.File;
    1010import java.io.IOException;
    import java.util.Comparator;  
    1717import java.util.List;
    1818import java.util.stream.Collectors;
    1919
    20 import org.junit.Before;
    21 import org.junit.Rule;
    22 import org.junit.Test;
     20import com.github.tomakehurst.wiremock.WireMockServer;
     21import com.github.tomakehurst.wiremock.client.WireMock;
     22import org.junit.jupiter.api.BeforeEach;
     23import org.junit.jupiter.api.Test;
     24import org.junit.jupiter.api.extension.RegisterExtension;
    2325import org.openstreetmap.josm.TestUtils;
    2426import org.openstreetmap.josm.data.Preferences;
    2527import org.openstreetmap.josm.gui.MainApplication;
    2628import org.openstreetmap.josm.spi.preferences.Config;
    2729import org.openstreetmap.josm.testutils.JOSMTestRules;
    2830import org.openstreetmap.josm.testutils.PluginServer;
     31import org.openstreetmap.josm.testutils.annotations.AssumeRevision;
     32import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     33import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
    2934import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    3035import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
    3136
    32 import com.github.tomakehurst.wiremock.client.WireMock;
    33 import com.github.tomakehurst.wiremock.junit.WireMockRule;
    34 
    35 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    36 
    3737/**
    3838 * Test parts of {@link PluginHandler} class when the reported JOSM version is too old for the plugin.
    3939 */
    40 public class PluginHandlerJOSMTooOldTest {
    41     /**
    42      * Setup test.
    43      */
    44     @Rule
    45     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    46     public JOSMTestRules test = new JOSMTestRules().preferences().main().assumeRevision(
    47         "Revision: 6000\n"
    48     );
     40@BasicPreferences(true)
     41@BasicWiremock
     42@AssumeRevision("Revision: 6000\n")
     43class PluginHandlerJOSMTooOldTest {
     44    @RegisterExtension
     45    @SuppressWarnings("URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     46    JOSMTestRules josmTestRules = new JOSMTestRules().main();
    4947
    5048    /**
    5149     * Plugin server mock.
    5250     */
    53     @Rule
    54     public WireMockRule pluginServerRule = new WireMockRule(
    55         options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot())
    56     );
     51    @BasicWiremock
     52    public WireMockServer pluginServerRule;
    5753
    5854    /**
    5955     * Setup test.
    6056     */
    61     @Before
     57    @BeforeEach
    6258    public void setUp() {
    6359        Config.getPref().putInt("pluginmanager.version", 999);
    6460        Config.getPref().put("pluginmanager.lastupdate", "999");
    public class PluginHandlerJOSMTooOldTest {  
    114110     * @throws IOException never
    115111     */
    116112    @Test
    117     public void testUpdatePluginsDownloadBoth() throws IOException {
     113    void testUpdatePluginsDownloadBoth() throws IOException {
    118114        TestUtils.assumeWorkingJMockit();
    119115        final PluginServer pluginServer = new PluginServer(
    120116            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
    public class PluginHandlerJOSMTooOldTest {  
    176172     * @throws IOException never
    177173     */
    178174    @Test
    179     public void testUpdatePluginsSkipOne() throws IOException {
     175    void testUpdatePluginsSkipOne() throws IOException {
    180176        TestUtils.assumeWorkingJMockit();
    181177        final PluginServer pluginServer = new PluginServer(
    182178            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
    public class PluginHandlerJOSMTooOldTest {  
    248244     * @throws IOException never
    249245     */
    250246    @Test
    251     public void testUpdatePluginsUnexpectedlyJOSMTooOld() throws IOException {
     247    void testUpdatePluginsUnexpectedlyJOSMTooOld() throws IOException {
    252248        TestUtils.assumeWorkingJMockit();
    253249        final PluginServer pluginServer = new PluginServer(
    254250            new PluginServer.RemotePlugin(this.referenceDummyJarNew),
    public class PluginHandlerJOSMTooOldTest {  
    302298     * @throws IOException never
    303299     */
    304300    @Test
    305     @JOSMTestRules.OverrideAssumeRevision("Revision: 7200\n")
    306     public void testUpdatePluginsMultiVersionInsufficient() throws IOException {
     301    @AssumeRevision("Revision: 7200\n")
     302    void testUpdatePluginsMultiVersionInsufficient() throws IOException {
    307303        TestUtils.assumeWorkingJMockit();
    308304
    309305        final PluginServer pluginServer = new PluginServer(
    public class PluginHandlerJOSMTooOldTest {  
    342338        // questionably correct
    343339        TestUtils.assertFileContentsEqual(this.referenceQuxJarNewer, this.targetQuxJar);
    344340
    345         assertEquals(2, WireMock.getAllServeEvents().size());
     341        assertEquals(2, this.pluginServerRule.getAllServeEvents().size(), "Requests: " + this.pluginServerRule.getAllServeEvents().stream()
     342                .map(serveEvent -> serveEvent.getRequest().getUrl()).collect(Collectors.joining(", ")));
    346343        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    347344        // questionably correct
    348345        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugin/qux_plugin.v432.jar")));
  • test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java

    diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerMultiVersionTest.java
    index 16d93c571e..0b09ac155e 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins;
    33
    4 import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options;
    5 import static org.junit.Assert.assertEquals;
    6 import static org.junit.Assert.assertFalse;
    7 import static org.junit.Assert.assertNotEquals;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertNotEquals;
    87
    98import java.io.File;
     9import java.io.IOException;
    1010import java.nio.file.Files;
    1111import java.util.Arrays;
    1212import java.util.Collections;
    import java.util.List;  
    1616import java.util.Map;
    1717import java.util.stream.Collectors;
    1818
    19 import org.junit.Before;
    20 import org.junit.Rule;
    21 import org.junit.Test;
     19import com.github.tomakehurst.wiremock.WireMockServer;
     20import com.github.tomakehurst.wiremock.client.WireMock;
     21import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     22import org.apache.commons.io.FileUtils;
     23import org.junit.jupiter.api.AfterEach;
     24import org.junit.jupiter.api.BeforeEach;
     25import org.junit.jupiter.api.Test;
     26import org.junit.jupiter.api.extension.RegisterExtension;
    2227import org.openstreetmap.josm.TestUtils;
    2328import org.openstreetmap.josm.data.Preferences;
    2429import org.openstreetmap.josm.gui.MainApplication;
    2530import org.openstreetmap.josm.spi.preferences.Config;
    2631import org.openstreetmap.josm.testutils.JOSMTestRules;
    2732import org.openstreetmap.josm.testutils.PluginServer;
     33import org.openstreetmap.josm.testutils.annotations.AssumeRevision;
     34import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     35import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
    2836import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    2937
    30 import com.github.tomakehurst.wiremock.client.WireMock;
    31 import com.github.tomakehurst.wiremock.junit.WireMockRule;
    32 
    33 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    34 
    3538/**
    3639 * Test parts of {@link PluginHandler} class with plugins that advertise multiple versions for compatibility.
    3740 */
    38 public class PluginHandlerMultiVersionTest {
     41@BasicWiremock
     42@BasicPreferences
     43@AssumeRevision("7000")
     44class PluginHandlerMultiVersionTest {
    3945    /**
    4046     * Setup test.
    4147     */
    42     @Rule
     48    @RegisterExtension
    4349    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    44     public JOSMTestRules test = new JOSMTestRules().preferences().main();
     50    public JOSMTestRules test = new JOSMTestRules().main();
    4551
    4652    /**
    4753     * Plugin server mock.
    4854     */
    49     @Rule
    50     public WireMockRule pluginServerRule = new WireMockRule(
    51         options().dynamicPort().usingFilesUnderDirectory(TestUtils.getTestDataRoot())
    52     );
     55    @BasicWiremock
     56    WireMockServer pluginServerRule;
    5357
    5458    /**
    5559     * Setup test.
    5660     */
    57     @Before
    58     public void setUp() {
     61    @BeforeEach
     62    void setUp() throws IOException {
    5963        Config.getPref().putInt("pluginmanager.version", 999);
    6064        Config.getPref().put("pluginmanager.lastupdate", "999");
    6165        Config.getPref().putList("pluginmanager.sites",
    public class PluginHandlerMultiVersionTest {  
    7175        this.targetBazJarNew = new File(this.pluginDir, "baz_plugin.jar.new");
    7276        this.targetQuxJar = new File(this.pluginDir, "qux_plugin.jar");
    7377        this.targetQuxJarNew = new File(this.pluginDir, "qux_plugin.jar.new");
     78        // Clean up the plugin directory
     79        if (this.pluginDir.isDirectory()) {
     80            FileUtils.cleanDirectory(this.pluginDir);
     81        }
    7482        this.pluginDir.mkdirs();
    7583    }
    7684
     85    @AfterEach
     86    void afterEach() {
     87
     88    }
     89
    7790    private static final String referencePathQuxJarOld = "plugin/qux_plugin.v345.jar";
    7891    private static final String referencePathQuxJarNewer = "plugin/qux_plugin.v432.jar";
    7992    private static final String referencePathQuxJarNewest = "plugin/qux_plugin.v435.jar";
    public class PluginHandlerMultiVersionTest {  
    93106     * but an additional version is listed which *does* support our version
    94107     * @throws Exception on failure
    95108     */
    96     @JOSMTestRules.OverrideAssumeRevision("Revision: 7501\n")
     109    @AssumeRevision("Revision: 7501\n")
    97110    @Test
    98     public void testUpdatePluginsOneMultiVersion() throws Exception {
     111    void testUpdatePluginsOneMultiVersion() throws Exception {
    99112        TestUtils.assumeWorkingJMockit();
    100113
    101114        final String quxNewerServePath = "/qux/newer.jar";
    public class PluginHandlerMultiVersionTest {  
    146159        TestUtils.assertFileContentsEqual(this.referenceBazJarOld, this.targetBazJar);
    147160        TestUtils.assertFileContentsEqual(this.referenceQuxJarNewer, this.targetQuxJar);
    148161
    149         assertEquals(2, WireMock.getAllServeEvents().size());
     162        assertEquals(2, this.pluginServerRule.getAllServeEvents().size());
    150163        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    151164        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo(quxNewerServePath)));
    152165
    public class PluginHandlerMultiVersionTest {  
    160173     * we already have, which is still listed.
    161174     * @throws Exception on failure
    162175     */
    163     @JOSMTestRules.OverrideAssumeRevision("Revision: 7000\n")
     176    @AssumeRevision("Revision: 7000\n")
    164177    @Test
    165     public void testUpdatePluginsExistingVersionLatestPossible() throws Exception {
     178    void testUpdatePluginsExistingVersionLatestPossible() throws Exception {
    166179        TestUtils.assumeWorkingJMockit();
    167180
    168181        final Map<String, String> attrOverrides = new HashMap<String, String>() {{
    public class PluginHandlerMultiVersionTest {  
    206219        TestUtils.assertFileContentsEqual(this.referenceQuxJarOld, this.targetQuxJar);
    207220
    208221        // only the plugins list should have been downloaded
    209         assertEquals(1, WireMock.getAllServeEvents().size());
     222        assertEquals(1, this.pluginServerRule.getAllServeEvents().size());
    210223        this.pluginServerRule.verify(1, WireMock.getRequestedFor(WireMock.urlEqualTo("/plugins")));
    211224
    212225        assertEquals(7000, Config.getPref().getInt("pluginmanager.version", 111));
  • test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java

    diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java
    index aeefa91805..875cf24278 100644
    a b import org.openstreetmap.josm.gui.widgets.JosmTextArea;  
    2323import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin;
    2424import org.openstreetmap.josm.plugins.PluginHandler.PluginInformationAction;
    2525import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     26import org.openstreetmap.josm.testutils.annotations.I18n;
    2627import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
    2728import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2829
    import org.junit.jupiter.api.Test;  
    3334 * Unit tests of {@link PluginHandler} class.
    3435 */
    3536@BasicPreferences
     37@I18n
    3638class PluginHandlerTest {
    3739    /**
    3840     * Unit test of methods {@link DeprecatedPlugin#equals} and {@link DeprecatedPlugin#hashCode}.
  • test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java b/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
    index 6e70c9889b..51f80edee0 100644
    a b import java.util.HashMap;  
    1515import java.util.Iterator;
    1616import java.util.List;
    1717import java.util.Map;
    18 import java.util.Map.Entry;
    1918import java.util.Set;
     19import java.util.concurrent.TimeUnit;
    2020import java.util.function.Consumer;
    2121import java.util.stream.Collectors;
    2222
    2323import org.junit.jupiter.api.BeforeAll;
    2424import org.junit.jupiter.api.Test;
     25import org.junit.jupiter.api.Timeout;
    2526import org.junit.jupiter.api.extension.RegisterExtension;
    2627import org.openstreetmap.josm.TestUtils;
    2728import org.openstreetmap.josm.data.Preferences;
    import org.openstreetmap.josm.gui.layer.OsmDataLayer;  
    3435import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3536import org.openstreetmap.josm.spi.preferences.Config;
    3637import org.openstreetmap.josm.testutils.JOSMTestRules;
     38import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     39import org.openstreetmap.josm.testutils.annotations.Main;
     40import org.openstreetmap.josm.testutils.annotations.Projection;
     41import org.openstreetmap.josm.testutils.annotations.Territories;
    3742import org.openstreetmap.josm.tools.Destroyable;
    3843import org.openstreetmap.josm.tools.Logging;
    3944import org.openstreetmap.josm.tools.Utils;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    4348/**
    4449 * Integration tests of {@link PluginHandler} class.
    4550 */
     51@BasicPreferences
     52@Projection
     53@Main
     54@Territories
     55@Timeout(value = 10, unit = TimeUnit.MINUTES)
    4656public class PluginHandlerTestIT {
    4757
    4858    private static final List<String> errorsToIgnore = new ArrayList<>();
    public class PluginHandlerTestIT {  
    5161     */
    5262    @RegisterExtension
    5363    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public static JOSMTestRules test = new JOSMTestRules().main().projection().preferences().https()
    55             .territories().timeout(10 * 60 * 1000);
     64    public static JOSMTestRules test = new JOSMTestRules().https();
    5665
    5766    /**
    5867     * Setup test
    public class PluginHandlerTestIT {  
    7382
    7483        Map<String, Throwable> loadingExceptions = PluginHandler.pluginLoadingExceptions.entrySet().stream()
    7584                .filter(e -> !(Utils.getRootCause(e.getValue()) instanceof HeadlessException))
    76                 .collect(Collectors.toMap(e -> e.getKey(), e -> Utils.getRootCause(e.getValue())));
     85                .collect(Collectors.toMap(Map.Entry::getKey, e -> Utils.getRootCause(e.getValue())));
    7786
    7887        List<PluginInformation> loadedPlugins = PluginHandler.getPlugins();
    7988        Map<String, List<String>> invalidManifestEntries = loadedPlugins.stream().filter(pi -> !pi.invalidManifestEntries.isEmpty())
    public class PluginHandlerTestIT {  
    147156    private static <T> Map<String, T> filterKnownErrors(Map<String, T> errorMap) {
    148157        return errorMap.entrySet().parallelStream()
    149158                .filter(entry -> !errorsToIgnore.contains(convertEntryToString(entry)))
    150                 .collect(Collectors.toMap(Entry::getKey, Entry::getValue));
     159                .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
    151160    }
    152161
    153162    private static void debugPrint(Map<String, ?> invalidManifestEntries) {
    154163        System.out.println(invalidManifestEntries.entrySet()
    155164                .stream()
    156                 .map(e -> convertEntryToString(e))
     165                .map(PluginHandlerTestIT::convertEntryToString)
    157166                .collect(Collectors.joining(", ")));
    158167    }
    159168
    160     private static String convertEntryToString(Entry<String, ?> entry) {
     169    private static String convertEntryToString(Map.Entry<String, ?> entry) {
    161170        return entry.getKey() + "=\"" + entry.getValue() + "\"";
    162171    }
    163172
  • test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java

    diff --git a/test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java b/test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java
    index 9c4fd03875..483ddf1fba 100644
    a b import static org.junit.jupiter.api.Assertions.assertTrue;  
    77import org.junit.jupiter.api.extension.RegisterExtension;
    88import org.junit.jupiter.api.Test;
    99import org.openstreetmap.josm.testutils.JOSMTestRules;
     10import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1011
    1112import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1213
    1314/**
    1415 * Unit tests of {@link Lifecycle} class.
    1516 */
     17@BasicPreferences
    1618class LifecycleTest {
    1719
    1820    /**
  • test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java b/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
    index b68e571827..27f7959116 100644
    a b import java.awt.GraphicsEnvironment;  
    66import java.awt.Toolkit;
    77import java.awt.Window;
    88import java.awt.event.WindowEvent;
    9 import java.io.ByteArrayInputStream;
    109import java.io.File;
    1110import java.io.IOException;
    1211import java.io.PrintWriter;
    import java.lang.annotation.Retention;  
    1716import java.lang.annotation.RetentionPolicy;
    1817import java.lang.annotation.Target;
    1918import java.lang.reflect.Method;
    20 import java.nio.charset.StandardCharsets;
    2119import java.security.GeneralSecurityException;
    2220import java.text.MessageFormat;
    2321import java.util.Arrays;
    import java.util.TimeZone;  
    2624import java.util.logging.Handler;
    2725import java.util.logging.Level;
    2826
     27import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2928import org.awaitility.Awaitility;
    3029import org.junit.jupiter.api.extension.AfterAllCallback;
    3130import org.junit.jupiter.api.extension.AfterEachCallback;
    import org.openstreetmap.josm.io.OsmConnection;  
    6463import org.openstreetmap.josm.io.OsmTransferCanceledException;
    6564import org.openstreetmap.josm.spi.preferences.Config;
    6665import org.openstreetmap.josm.spi.preferences.Setting;
     66import org.openstreetmap.josm.testutils.annotations.MockVersion;
     67import org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource;
    6768import org.openstreetmap.josm.testutils.mockers.EDTAssertionMocker;
    6869import org.openstreetmap.josm.testutils.mockers.WindowlessMapViewStateMocker;
    6970import org.openstreetmap.josm.testutils.mockers.WindowlessNavigatableComponentMocker;
    import org.openstreetmap.josm.tools.Utils;  
    7980import org.openstreetmap.josm.tools.bugreport.ReportedException;
    8081import org.openstreetmap.josm.tools.date.DateUtils;
    8182
    82 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    83 
    8483/**
    8584 * This class runs a test in an environment that resembles the one used by the JOSM main application.
    8685 * <p>
    public class JOSMTestRules implements TestRule, AfterEachCallback, BeforeEachCal  
    332331                true,
    333332                true,
    334333                true,
    335                 new TileSourceRule.ColorSource(Color.WHITE, "White Tiles", 256),
    336                 new TileSourceRule.ColorSource(Color.BLACK, "Black Tiles", 256),
    337                 new TileSourceRule.ColorSource(Color.MAGENTA, "Magenta Tiles", 256),
    338                 new TileSourceRule.ColorSource(Color.GREEN, "Green Tiles", 256)
     334                new ColorSource(Color.WHITE, "White Tiles", 256),
     335                new ColorSource(Color.BLACK, "Black Tiles", 256),
     336                new ColorSource(Color.MAGENTA, "Magenta Tiles", 256),
     337                new ColorSource(Color.GREEN, "Green Tiles", 256)
    339338            )
    340339        );
    341340    }
    public class JOSMTestRules implements TestRule, AfterEachCallback, BeforeEachCal  
    403402        return this;
    404403    }
    405404
    406     private static class MockVersion extends Version {
    407         MockVersion(final String propertiesString) {
    408             super.initFromRevisionInfo(
    409                 new ByteArrayInputStream(propertiesString.getBytes(StandardCharsets.UTF_8))
    410             );
    411         }
    412     }
    413 
    414405    @Override
    415406    public Statement apply(Statement base, Description description) {
    416407        // First process any Override* annotations for per-test overrides.
  • test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java b/test/unit/org/openstreetmap/josm/testutils/TileSourceRule.java
    index 9156cbd539..b7fc44b687 100644
    a b import static com.github.tomakehurst.wiremock.core.WireMockConfiguration.options  
    55import static org.openstreetmap.josm.TestUtils.getPrivateStaticField;
    66
    77import java.awt.Color;
    8 import java.awt.Graphics2D;
    9 import java.awt.image.BufferedImage;
    10 import java.io.ByteArrayOutputStream;
    118import java.io.IOException;
    129import java.util.Arrays;
    1310import java.util.Collections;
    1411import java.util.HashMap;
    1512import java.util.List;
    16 import java.util.Objects;
    17 
    18 import javax.imageio.ImageIO;
    1913
    2014import org.junit.runner.Description;
    2115import org.junit.runners.model.Statement;
    public class TileSourceRule extends WireMockRule {  
    5044
    5145    /**
    5246     * Class defining a tile source for TileSourceRule to mock. Due to the way WireMock is designed, it is far more
    53      * straightforward to serve a single image in all tile positions
     47     * straightforward to serve a single image in all tile positions.
     48     *
     49     * @deprecated Please extend {@link org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource} instead.
     50     * When JUnit 4 support is removed from JOSM, this class will disappear. Until then,
     51     * {@link org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource} will extend {@link ConstSource}.
    5452     */
     53    @Deprecated
    5554    public abstract static class ConstSource {
    5655        /**
    5756         * method for actually generating the payload body bytes, uncached
    public class TileSourceRule extends WireMockRule {  
    101100
    102101    /**
    103102     * A plain color tile source
     103     * @deprecated Use {@link org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource} instead
    104104     */
    105     public static class ColorSource extends ConstSource {
    106         protected final Color color;
    107         protected final String label;
    108         protected final int tileSize;
    109 
     105    @Deprecated
     106    public static class ColorSource extends org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource {
    110107        /**
    111108         * @param color Color for these tiles
    112109         * @param label text label/name for this source if displayed in JOSM menus
    113110         * @param tileSize Pixel dimension of tiles (usually 256)
    114111         */
    115112        public ColorSource(Color color, String label, int tileSize) {
    116             this.color = color;
    117             this.label = label;
    118             this.tileSize = tileSize;
    119         }
    120 
    121         @Override
    122         public int hashCode() {
    123             return Objects.hash(this.color, this.label, this.tileSize, this.getClass());
    124         }
    125 
    126         @Override
    127         public byte[] generatePayloadBytes() {
    128             BufferedImage image = new BufferedImage(this.tileSize, this.tileSize, BufferedImage.TYPE_INT_RGB);
    129             Graphics2D g = image.createGraphics();
    130             g.setBackground(this.color);
    131             g.clearRect(0, 0, image.getWidth(), image.getHeight());
    132 
    133             ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    134             try {
    135                 ImageIO.write(image, "png", outputStream);
    136             } catch (IOException e) {
    137                 Logging.trace(e);
    138             }
    139             return outputStream.toByteArray();
    140         }
    141 
    142         @Override
    143         public MappingBuilder getMappingBuilder() {
    144             return WireMock.get(WireMock.urlMatching(String.format("/%h/(\\d+)/(\\d+)/(\\d+)\\.png", this.hashCode())));
    145         }
    146 
    147         @Override
    148         public ImageryInfo getImageryInfo(int port) {
    149             return new ImageryInfo(
    150                 this.label,
    151                 String.format("tms[20]:http://localhost:%d/%h/{z}/{x}/{y}.png", port, this.hashCode()),
    152                 "tms",
    153                 (String) null,
    154                 (String) null
    155             );
    156         }
    157 
    158         @Override
    159         public String getLabel() {
    160             return this.label;
     113            super(color, label, tileSize);
    161114        }
    162115    }
    163116
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/AssumeRevision.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/AssumeRevision.java b/test/unit/org/openstreetmap/josm/testutils/annotations/AssumeRevision.java
    new file mode 100644
    index 0000000000..849f06cf13
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import java.lang.annotation.Documented;
     5import java.lang.annotation.ElementType;
     6import java.lang.annotation.Retention;
     7import java.lang.annotation.RetentionPolicy;
     8import java.lang.annotation.Target;
     9import java.util.Optional;
     10
     11import org.junit.jupiter.api.extension.AfterEachCallback;
     12import org.junit.jupiter.api.extension.BeforeEachCallback;
     13import org.junit.jupiter.api.extension.ExtendWith;
     14import org.junit.jupiter.api.extension.ExtensionContext;
     15import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
     16import org.junit.jupiter.api.extension.ExtensionContext.Store;
     17import org.openstreetmap.josm.TestUtils;
     18import org.openstreetmap.josm.data.Version;
     19import org.openstreetmap.josm.testutils.JOSMTestRules;
     20
     21
     22/**
     23 * Override this test's assumed JOSM version (as reported by {@link Version}).
     24 * @author Taylor Smock
     25 * @see JOSMTestRules#assumeRevision(String)
     26 * @since xxx
     27 */
     28@Documented
     29@Retention(RetentionPolicy.RUNTIME)
     30@Target({ElementType.METHOD, ElementType.TYPE})
     31@ExtendWith(AssumeRevision.AssumeRevisionExtension.class)
     32public @interface AssumeRevision {
     33    /**
     34     * Returns overridden assumed JOSM version.
     35     * @return overridden assumed JOSM version
     36     */
     37    String value();
     38
     39    /**
     40     * Override the JOSM revision information. Use {@link AssumeRevision} instead of directly using this extension.
     41     * @author Taylor Smock
     42     * @since xxx
     43     */
     44    class AssumeRevisionExtension implements BeforeEachCallback, AfterEachCallback {
     45
     46        @Override
     47        public void afterEach(ExtensionContext context) throws Exception {
     48            Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class));
     49            Version originalVersion = store.getOrDefault(Version.class, Version.class, null);
     50            if (originalVersion != null) {
     51                TestUtils.setPrivateStaticField(Version.class, "instance", originalVersion);
     52            }
     53        }
     54
     55        @Override
     56        public void beforeEach(ExtensionContext context) throws Exception {
     57            Optional<AssumeRevision> annotation = AnnotationUtils.findFirstParentAnnotation(context, AssumeRevision.class);
     58            if (annotation.isPresent()) {
     59                Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class));
     60                if (store.get(Version.class, Version.class) == null) {
     61                    store.put(Version.class, Version.getInstance());
     62                }
     63                final Version replacementVersion = new MockVersion(annotation.get().value());
     64                TestUtils.setPrivateStaticField(Version.class, "instance", replacementVersion);
     65            }
     66        }
     67    }
     68
     69}
  • test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java b/test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java
    index 1ee93ed28b..ee81391c02 100644
    a b package org.openstreetmap.josm.testutils.annotations;  
    33
    44import java.lang.annotation.Documented;
    55import java.lang.annotation.ElementType;
     6import java.lang.annotation.Inherited;
    67import java.lang.annotation.Retention;
    78import java.lang.annotation.RetentionPolicy;
    89import java.lang.annotation.Target;
     10import java.lang.reflect.Field;
     11import java.nio.file.Path;
    912
    1013import org.junit.jupiter.api.extension.AfterAllCallback;
    1114import org.junit.jupiter.api.extension.AfterEachCallback;
    import org.junit.jupiter.api.extension.BeforeEachCallback;  
    1417import org.junit.jupiter.api.extension.ExtendWith;
    1518import org.junit.jupiter.api.extension.ExtensionContext;
    1619import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
     20import org.junit.platform.commons.util.ClassFilter;
     21import org.junit.platform.commons.util.ReflectionUtils;
    1722import org.openstreetmap.josm.data.Preferences;
     23import org.openstreetmap.josm.data.preferences.AbstractProperty;
    1824import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
    1925import org.openstreetmap.josm.data.preferences.JosmUrls;
    2026import org.openstreetmap.josm.spi.preferences.Config;
    2127import org.openstreetmap.josm.testutils.JOSMTestRules;
     28import org.openstreetmap.josm.tools.Logging;
    2229
    2330/**
    2431 * Allow tests to use JOSM preferences (see {@link JOSMTestRules#preferences()}).
    import org.openstreetmap.josm.testutils.JOSMTestRules;  
    3138@Documented
    3239@Retention(RetentionPolicy.RUNTIME)
    3340@Target({ElementType.TYPE, ElementType.METHOD})
     41@Inherited
     42// Force use of a new JOSM home every run (this helps avoid resetting the user's JOSM preferences, when run from an IDE)
     43@JosmHome
    3444@ExtendWith(BasicPreferences.BasicPreferencesExtension.class)
    3545public @interface BasicPreferences {
    3646
     47    /** {@code true} to clear preferences between tests. Alternatively, re-annotate specific tests with this annotation. */
     48    boolean value() default false;
     49
    3750    /**
    3851     * Initialize basic preferences. This is often more than enough for basic tests.
    3952     * @author Taylor Smock
    public @interface BasicPreferences {  
    4255        @Override
    4356        public void afterAll(ExtensionContext context) throws Exception {
    4457            AnnotationUtils.resetStaticClass(Config.class);
     58
     59            // Ensure that config tests are consistent
     60            resetConfigVariables(null);
    4561        }
    4662
    4763        @Override
    4864        public void afterEach(ExtensionContext context) throws Exception {
    49             if (context.getElement().isPresent() && context.getElement().get().isAnnotationPresent(BasicPreferences.class)) {
     65            if (context.getElement().isPresent() && context.getElement().get().isAnnotationPresent(BasicPreferences.class)
     66            || AnnotationUtils.findFirstParentAnnotation(context, BasicPreferences.class).map(BasicPreferences::value).orElse(false)) {
    5067                this.afterAll(context);
    5168            }
    5269        }
    public @interface BasicPreferences {  
    6481
    6582            // Store the pref for other extensions
    6683            context.getStore(Namespace.create(BasicPreferencesExtension.class)).put("preferences", pref);
     84
     85            resetConfigVariables(pref);
    6786        }
    6887
    6988        @Override
    7089        public void beforeEach(ExtensionContext context) throws Exception {
    71             if (AnnotationUtils.elementIsAnnotated(context.getElement(), BasicPreferences.class) || Config.getPref() == null) {
     90            if (AnnotationUtils.elementIsAnnotated(context.getElement(), BasicPreferences.class) || Config.getPref() == null
     91                || AnnotationUtils.findFirstParentAnnotation(context, BasicPreferences.class).map(BasicPreferences::value).orElse(false)) {
    7292                this.beforeAll(context);
    7393            }
    7494        }
     95
     96        /**
     97         * Reset all {@link AbstractProperty} preferences to the new preference
     98         * @param pref The preference to use
     99         * @throws ReflectiveOperationException if reflection fails
     100         */
     101        private void resetConfigVariables(Preferences pref) throws ReflectiveOperationException {
     102            final Field configField = AbstractProperty.class.getDeclaredField("preferences");
     103            configField.setAccessible(true);
     104            for (Path classPath : ReflectionUtils.getAllClasspathRootDirectories()) {
     105                for (Class<?> clazz : ReflectionUtils.findAllClassesInClasspathRoot(classPath.toUri(), ClassFilter.of(tClazz -> true))) {
     106                    try {
     107                        for (Field field : clazz.getDeclaredFields()) {
     108                            if (ReflectionUtils.isStatic(field) && AbstractProperty.class.isAssignableFrom(field.getType())) {
     109                                field.setAccessible(true);
     110                                configField.set(field.get(null), pref);
     111                            }
     112                        }
     113                    } catch (NoClassDefFoundError noClassDefFoundError) {
     114                        Logging.warn("{0}: No class definition found", clazz.getName());
     115                    }
     116                }
     117            }
     118
     119            // Ensure that the directories get reset as well. This is stored in the main preferences holder (Preferences.main())
     120            JosmBaseDirectories.getInstance().clearMemos();
     121        }
    75122    }
    76123}
     124
  • test/unit/org/openstreetmap/josm/testutils/annotations/BasicWiremock.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/BasicWiremock.java b/test/unit/org/openstreetmap/josm/testutils/annotations/BasicWiremock.java
    index 2abe8efff9..cf15c5a700 100644
    a b import static org.junit.jupiter.api.Assertions.fail;  
    77
    88import java.lang.annotation.Documented;
    99import java.lang.annotation.ElementType;
     10import java.lang.annotation.Inherited;
    1011import java.lang.annotation.Retention;
    1112import java.lang.annotation.RetentionPolicy;
    1213import java.lang.annotation.Target;
    import org.junit.jupiter.api.extension.ParameterContext;  
    2930import org.junit.jupiter.api.extension.ParameterResolutionException;
    3031import org.junit.jupiter.api.extension.ParameterResolver;
    3132import org.junit.platform.commons.support.AnnotationSupport;
     33import org.junit.platform.commons.util.ReflectionUtils;
    3234import org.openstreetmap.josm.TestUtils;
    3335import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3436import org.openstreetmap.josm.gui.util.GuiHelper;
    import com.github.tomakehurst.wiremock.verification.LoggedRequest;  
    5456@Retention(RetentionPolicy.RUNTIME)
    5557@Target({ ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
    5658@ExtendWith(BasicWiremock.WireMockExtension.class)
     59@ExtendWith(BasicWiremock.WireMockParameterResolver.class)
     60@Inherited
    5761public @interface BasicWiremock {
    5862    /**
    5963     * Set the path for the data. Default is {@link TestUtils#getTestDataRoot()}.
    public @interface BasicWiremock {  
    7882     *
    7983     */
    8084    class WireMockExtension
    81             implements AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback, ParameterResolver {
     85            implements AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback {
    8286        /**
    8387         * Get the default wiremock server
    8488         * @param context The context to search
    public @interface BasicWiremock {  
    9296                final List<ResponseTransformer> transformers = new ArrayList<>(annotation.responseTransformers().length);
    9397                for (Class<? extends ResponseTransformer> responseTransformer : annotation.responseTransformers()) {
    9498                    for (Pair<Class<?>[], Object[]> parameterMapping : Arrays.asList(
    95                             new Pair<>(new Class<?>[] {ExtensionContext.class }, new Object[] {context }),
     99                            new Pair<>(new Class<?>[] {ExtensionContext.class}, new Object[] {context}),
    96100                            new Pair<>(new Class<?>[0], new Object[0]))) {
    97101                        try {
    98                             Constructor<? extends ResponseTransformer> constructor = responseTransformer
    99                                     .getConstructor(parameterMapping.a);
     102                            Constructor<? extends ResponseTransformer> constructor = responseTransformer.getConstructor(
     103                                    parameterMapping.a);
    100104                            transformers.add(constructor.newInstance(parameterMapping.b));
    101105                            break;
    102106                        } catch (ReflectiveOperationException e) {
    public @interface BasicWiremock {  
    104108                        }
    105109                    }
    106110                }
    107                 return new WireMockServer(
    108                     options().usingFilesUnderDirectory(Utils.isStripEmpty(annotation.value()) ? TestUtils.getTestDataRoot() :
    109                             annotation.value()).extensions(transformers.toArray(new ResponseTransformer[0])).dynamicPort());
     111                return new WireMockServer(options().usingFilesUnderDirectory(
     112                        Utils.isStripEmpty(annotation.value()) ? TestUtils.getTestDataRoot() :
     113                                annotation.value()).extensions(transformers.toArray(new ResponseTransformer[0])).dynamicPort());
    110114            }, WireMockServer.class);
    111115        }
    112116
    public @interface BasicWiremock {  
    138142            List<LoggedRequest> missed = getWiremock(context).findUnmatchedRequests().getRequests();
    139143            missed.forEach(r -> Logging.error(r.getAbsoluteUrl()));
    140144            try {
    141                 assertTrue(missed.isEmpty(), missed.stream().map(LoggedRequest::getUrl).collect(Collectors.joining("\n\n")));
     145                assertTrue(missed.isEmpty(),
     146                        missed.stream().map(LoggedRequest::getUrl).collect(Collectors.joining("\n\n")));
    142147            } finally {
    143148                getWiremock(context).resetRequests();
    144149                getWiremock(context).resetToDefaultMappings();
    public @interface BasicWiremock {  
    153158        @Override
    154159        public void beforeAll(ExtensionContext context) throws Exception {
    155160            getWiremock(context).start();
     161            setWireMocks(context);
    156162        }
    157163
    158164        @Override
    public @interface BasicWiremock {  
    160166            if (AnnotationUtils.elementIsAnnotated(context.getElement(), BasicWiremock.class) || getWiremock(context) == null) {
    161167                this.beforeAll(context);
    162168            }
     169            setWireMocks(context);
     170        }
     171
     172        /**
     173         * Set wiremock fields
     174         * @param context The context to use
     175         * @throws IllegalAccessException If the object cannot be accessed
     176         */
     177        private static void setWireMocks(ExtensionContext context) throws IllegalAccessException {
    163178            if (context.getTestClass().isPresent()) {
    164                 List<Field> wireMockFields = AnnotationSupport.findAnnotatedFields(context.getRequiredTestClass(), BasicWiremock.class);
     179                List<Field> wireMockFields = AnnotationSupport.findAnnotatedFields(context.getRequiredTestClass(),
     180                        BasicWiremock.class);
    165181                for (Field field : wireMockFields) {
    166                     if (WireMockServer.class.isAssignableFrom(field.getType())) {
     182                    if (field.getType().isAssignableFrom(WireMockServer.class)) {
    167183                        final boolean isAccessible = field.isAccessible();
    168184                        field.setAccessible(true);
    169185                        try {
    170                             field.set(context.getTestInstance().orElse(null), getWiremock(context));
     186                            if (ReflectionUtils.isStatic(field) && context.getRequiredTestClass().equals(context.getElement().orElse(null))) {
     187                                field.set(null, getWiremock(context));
     188                            } else if (context.getTestInstance().isPresent()) {
     189                                field.set(context.getTestInstance().get(), getWiremock(context));
     190                            }
    171191                        } finally {
    172192                            field.setAccessible(isAccessible);
    173193                        }
    public @interface BasicWiremock {  
    176196                    }
    177197                }
    178198            }
     199
    179200        }
     201    }
    180202
     203    /**
     204     * A specific resolver for WireMock parameters
     205     */
     206    class WireMockParameterResolver implements ParameterResolver {
    181207        @Override
    182208        public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
    183209                throws ParameterResolutionException {
    184210            return parameterContext.getParameter().getAnnotation(BasicWiremock.class) != null
    185                     && parameterContext.getParameter().getType() == WireMockServer.class;
     211                    && parameterContext.getParameter().getType().isAssignableFrom(WireMockServer.class);
    186212        }
    187213
    188214        @Override
    189215        public Object resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
    190216                throws ParameterResolutionException {
    191             return getWiremock(extensionContext);
     217            return WireMockExtension.getWiremock(extensionContext);
    192218        }
    193219    }
    194220
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/FakeImagery.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/FakeImagery.java b/test/unit/org/openstreetmap/josm/testutils/annotations/FakeImagery.java
    new file mode 100644
    index 0000000000..db54a5af8f
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static org.junit.jupiter.api.Assertions.fail;
     5import static org.openstreetmap.josm.TestUtils.getPrivateStaticField;
     6
     7import java.awt.Color;
     8import java.io.IOException;
     9import java.lang.annotation.Documented;
     10import java.lang.annotation.ElementType;
     11import java.lang.annotation.Retention;
     12import java.lang.annotation.RetentionPolicy;
     13import java.lang.annotation.Target;
     14import java.lang.reflect.Method;
     15import java.lang.reflect.Type;
     16import java.util.ArrayList;
     17import java.util.Arrays;
     18import java.util.EnumSet;
     19import java.util.List;
     20import java.util.Optional;
     21import java.util.Set;
     22import java.util.function.Supplier;
     23
     24import org.junit.jupiter.api.extension.ExtendWith;
     25import org.junit.jupiter.api.extension.ExtensionContext;
     26import org.junit.jupiter.api.extension.ParameterContext;
     27import org.junit.jupiter.api.extension.ParameterResolutionException;
     28import org.junit.jupiter.api.extension.ParameterResolver;
     29import org.junit.platform.commons.support.AnnotationSupport;
     30import org.junit.platform.commons.util.ReflectionUtils;
     31import org.openstreetmap.josm.data.imagery.ImageryInfo;
     32import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
     33import org.openstreetmap.josm.gui.bbox.SlippyMapBBoxChooser;
     34import org.openstreetmap.josm.testutils.annotations.fake_imagery.ColorSource;
     35import org.openstreetmap.josm.testutils.annotations.fake_imagery.ConstSource;
     36import org.openstreetmap.josm.tools.Logging;
     37import org.opentest4j.AssertionFailedError;
     38
     39import com.github.tomakehurst.wiremock.WireMockServer;
     40import com.github.tomakehurst.wiremock.client.WireMock;
     41
     42/**
     43 * An annotation for fake imagery
     44 * Please note that this currently only supports single-color tile sources.
     45 * @author Taylor Smock
     46 * @since xxx
     47 */
     48@Documented
     49@Retention(RetentionPolicy.RUNTIME)
     50@Target({ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER})
     51@BasicWiremock
     52@ExtendWith(FakeImagery.FakeImageryExtension.class)
     53@ExtendWith(FakeImagery.FakeImageryParameterResolver.class)
     54public @interface FakeImagery {
     55    /**
     56     * The options to use for FakeImagery
     57     * @return The options
     58     */
     59    Options[] options() default {Options.CLEAR_LAYER_LIST, Options.CLEAR_SLIPPY_MAP_SOURCES, Options.REGISTER_IN_LAYER_LIST};
     60
     61    /**
     62     * The color tile sources to use for FakeImagery
     63     * @return The simple color tile sources
     64     */
     65    ColorTileSource[] colorTileSources() default {@ColorTileSource(colors = Colors.WHITE, name = "White Tiles"),
     66        @ColorTileSource(colors = Colors.BLACK, name = "Black Tiles"),
     67        @ColorTileSource(colors = Colors.MAGENTA, name = "Magenta Tiles"), @ColorTileSource(colors = Colors.GREEN, name = "Green Tiles")};
     68
     69    /**
     70     * The more complex tilesources to use. The classes <i>must</i> have a constructor with no arguments
     71     * @return The tile sources to instantiate
     72     */
     73    Class<? extends ConstSource>[] tileSources() default {};
     74
     75    /**
     76     * Define a simple tile source (only single color supported at this time)
     77     * @author Taylor Smock
     78     */
     79    @Retention(RetentionPolicy.RUNTIME)
     80    @Target(ElementType.LOCAL_VARIABLE)
     81    @interface ColorTileSource {
     82        /**
     83         * Pixel dimension of tiles (usually 256)
     84         * @return The expected size for the tiles
     85         */
     86        int size() default 256;
     87
     88        /**
     89         * Color for these tiles
     90         * @return The Color enum (sorry, you can't make your own arbitrary colors)
     91         */
     92        Colors colors() default Colors.BLACK;
     93
     94        /**
     95         * text label/name for this source if displayed in JOSM menus
     96         * @return The name for the layer/menu entry
     97         */
     98        String name();
     99    }
     100
     101    /**
     102     * The options that can be used for FakeImagery
     103     * @author Taylor Smock
     104     *
     105     */
     106    enum Options {
     107        /**
     108         * whether to clear ImageryLayerInfo's layer list of any pre-existing entries
     109         */
     110        CLEAR_LAYER_LIST,
     111        /**
     112         * whether to clear SlippyMapBBoxChooser's stubborn fallback Mapnik ColorTileSource
     113         */
     114        CLEAR_SLIPPY_MAP_SOURCES,
     115        /**
     116         * whether to add sources to ImageryLayerInfo's layer list
     117         */
     118        REGISTER_IN_LAYER_LIST
     119    }
     120
     121    /**
     122     * An enum for colors (currently only uses static colors from {@link Color})
     123     */
     124    enum Colors {
     125        BLACK(Color.BLACK),
     126        BLUE(Color.BLUE),
     127        CYAN(Color.CYAN),
     128        DARK_GRAY(Color.DARK_GRAY),
     129        GRAY(Color.GRAY),
     130        GREEN(Color.GREEN),
     131        LIGHT_GRAY(Color.LIGHT_GRAY),
     132        MAGENTA(Color.MAGENTA),
     133        ORANGE(Color.ORANGE),
     134        PINK(Color.PINK),
     135        RED(Color.RED),
     136        WHITE(Color.WHITE),
     137        YELLOW(Color.YELLOW);
     138
     139        private final Color color;
     140        Colors(Color color) {
     141            this.color = color;
     142        }
     143
     144        public Color getColor() {
     145            return this.color;
     146        }
     147    }
     148
     149    /**
     150     * A class to specifically mock Imagery calls
     151     */
     152    class FakeImageryExtension extends BasicWiremock.WireMockExtension {
     153        static final String SLIPPY_MAP_PROVIDERS = "slippyMapProviders";
     154        static final String SLIPPY_MAP_DEFAULT_PROVIDER = "slippyMapDefaultProvider";
     155        static final String ORIGINAL_IMAGERY_INFO_LIST = "originalImageryInfoList";
     156
     157        @Override
     158        public void afterEach(ExtensionContext context) throws Exception {
     159            try {
     160                super.afterEach(context);
     161            } finally {
     162                cleanup(context);
     163            }
     164        }
     165
     166        @Override
     167        public void beforeAll(ExtensionContext context) throws Exception {
     168            if (context.getStore(ExtensionContext.Namespace.create(BasicPreferences.BasicPreferencesExtension.class))
     169                    .get("preferences") == null) {
     170                fail("FakeImageryExtension requires preferences (try @BasicPreferences)");
     171            }
     172            super.beforeAll(context);
     173
     174            // Get the wiremock server
     175            final WireMockServer wireMockServer = getWiremock(context);
     176
     177            // set up a stub target for the early request hack
     178            wireMockServer.stubFor(WireMock.get(
     179                    WireMock.urlMatching("/_poke")
     180            ).willReturn(WireMock.aResponse().withStatus(200).withBody("ow.")));
     181            runServer(wireMockServer);
     182        }
     183
     184        @Override
     185        public void beforeEach(final ExtensionContext context) throws Exception {
     186            super.beforeEach(context);
     187            final FakeImagery fakeImagery = AnnotationSupport.findAnnotation(context.getElement(), FakeImagery.class)
     188                    .orElseGet(() -> AnnotationSupport.findAnnotation(context.getRequiredTestClass(), FakeImagery.class)
     189                    .orElseThrow((Supplier<AssertionFailedError>) () -> fail(context.getDisplayName() + " missing @FakeImagery annotation")));
     190            final Set<Options> options = EnumSet.copyOf(Arrays.asList(fakeImagery.options()));
     191            final ColorTileSource[] colorTileSources = fakeImagery.colorTileSources();
     192            final Class<? extends ConstSource>[] additionalTileSources = fakeImagery.tileSources();
     193
     194            // Get the wiremock server
     195            final WireMockServer wireMockServer = getWiremock(context);
     196
     197            final List<ConstSource> constSourceList = new ArrayList<>(colorTileSources.length + additionalTileSources.length);
     198            for (ColorTileSource source : colorTileSources) {
     199                final ColorSource colorSource = new ColorSource(source);
     200                constSourceList.add(colorSource);
     201                wireMockServer.stubFor(colorSource.getMappingBuilder().willReturn(colorSource.getResponseDefinitionBuilder()));
     202            }
     203
     204            for (Class<? extends ConstSource> constSourceClazz : additionalTileSources) {
     205                final ConstSource constSource = ReflectionUtils.newInstance(constSourceClazz);
     206                constSourceList.add(constSource);
     207                wireMockServer.stubFor(constSource.getMappingBuilder().willReturn(constSource.getResponseDefinitionBuilder()));
     208            }
     209
     210            registerLayers(context, options, constSourceList, wireMockServer);
     211        }
     212
     213        /**
     214         * A hack to circumvent a WireMock bug concerning delayed server startup. sending an early request
     215         * to the mock server seems to prompt it to start earlier (though this request itself is not
     216         * expected to succeed). See <a href="https://github.com/tomakehurst/wiremock/issues/97">WireMock Issue #97</a>
     217         */
     218        private static void runServer(WireMockServer wireMockServer) {
     219            try {
     220                new java.net.URL(wireMockServer.url("/_poke")).getContent();
     221            } catch (IOException e) {
     222                Logging.trace(e);
     223            }
     224        }
     225
     226        private static void registerLayers(final ExtensionContext context, final Set<Options> options, final List<ConstSource> sourcesList,
     227                final WireMockServer wireMockServer) {
     228            if (options.contains(Options.REGISTER_IN_LAYER_LIST) || options.contains(Options.CLEAR_LAYER_LIST)) {
     229                ExtensionContext.Store store = context.getStore(
     230                        ExtensionContext.Namespace.create(FakeImageryExtension.class));
     231                if (options.contains(Options.CLEAR_SLIPPY_MAP_SOURCES)) {
     232                    try {
     233                        final List<SlippyMapBBoxChooser.TileSourceProvider> slippyMapProviders =
     234                                (List<SlippyMapBBoxChooser.TileSourceProvider>)
     235                                        getPrivateStaticField(SlippyMapBBoxChooser.class, "providers");
     236                        // pop this off the beginning of the list, keep for later
     237                        final SlippyMapBBoxChooser.TileSourceProvider slippyMapDefaultProvider = slippyMapProviders.remove(0);
     238                        store.put(SLIPPY_MAP_PROVIDERS, slippyMapProviders);
     239                        store.put(SLIPPY_MAP_DEFAULT_PROVIDER, slippyMapDefaultProvider);
     240                    } catch (ReflectiveOperationException e) {
     241                        Logging.warn("Failed to remove default SlippyMapBBoxChooser TileSourceProvider");
     242                    }
     243                }
     244
     245                if (options.contains(Options.CLEAR_LAYER_LIST)) {
     246                    final List<ImageryInfo> originalImageryInfoList = ImageryLayerInfo.instance.getLayers();
     247                    store.put(ORIGINAL_IMAGERY_INFO_LIST, originalImageryInfoList);
     248                    ImageryLayerInfo.instance.clear();
     249                }
     250                if (options.contains(Options.REGISTER_IN_LAYER_LIST)) {
     251                    for (ConstSource source : sourcesList) {
     252                        ImageryLayerInfo.addLayer(source.getImageryInfo(wireMockServer));
     253                    }
     254                }
     255                store.put(ConstSource.class, sourcesList);
     256            }
     257        }
     258
     259        /**
     260         * Cleanup the environment
     261         * @param context The context with the original values
     262         */
     263        private static void cleanup(final ExtensionContext context) {
     264            final ExtensionContext.Store store = context.getStore(
     265                    ExtensionContext.Namespace.create(FakeImageryExtension.class));
     266            final List<SlippyMapBBoxChooser.TileSourceProvider> slippyMapProviders = (List<SlippyMapBBoxChooser.TileSourceProvider>)
     267                    store.remove(SLIPPY_MAP_PROVIDERS, List.class);
     268            final SlippyMapBBoxChooser.TileSourceProvider slippyMapDefaultProvider = store.remove(SLIPPY_MAP_DEFAULT_PROVIDER,
     269                    SlippyMapBBoxChooser.TileSourceProvider.class);
     270            final List<ImageryInfo> originalImageryInfoList = (List<ImageryInfo>) store.remove(ORIGINAL_IMAGERY_INFO_LIST, List.class);
     271            // clean up to original state
     272            if (slippyMapDefaultProvider != null && slippyMapProviders != null) {
     273                slippyMapProviders.add(0, slippyMapDefaultProvider);
     274            }
     275            if (originalImageryInfoList != null) {
     276                ImageryLayerInfo.instance.clear();
     277                ImageryLayerInfo.addLayers(originalImageryInfoList);
     278            }
     279        }
     280    }
     281
     282    /**
     283     * A parameter resolver for FakeImagery
     284     */
     285    class FakeImageryParameterResolver implements ParameterResolver {
     286        @Override
     287        public boolean supportsParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
     288                throws ParameterResolutionException {
     289            ExtensionContext.Store store = extensionContext.getStore(
     290                    ExtensionContext.Namespace.create(FakeImageryExtension.class));
     291            if (store.get(ConstSource.class) != null && parameterContext.isAnnotated(FakeImagery.class)
     292                    && List.class.isAssignableFrom(parameterContext.getParameter().getType())) {
     293                 Optional<Method> optionalMethod = ReflectionUtils.findMethod(parameterContext.getParameter().getParameterizedType().getClass(),
     294                         "getActualTypeArguments");
     295                 if (!optionalMethod.isPresent() || !optionalMethod.get().getReturnType().isAssignableFrom(Type[].class)) {
     296                     // We can't check the type. Therefore, we must hope that everything goes well.
     297                     return true;
     298                 }
     299                 Type[] types = (Type[]) ReflectionUtils.invokeMethod(optionalMethod.get(),
     300                         parameterContext.getParameter().getParameterizedType());
     301                 return types.length == 1 && ConstSource.class.isAssignableFrom((Class<?>) types[0]);
     302            }
     303            return false;
     304        }
     305
     306        @Override
     307        public List<ConstSource> resolveParameter(ParameterContext parameterContext, ExtensionContext extensionContext)
     308                throws ParameterResolutionException {
     309            ExtensionContext.Store store = extensionContext.getStore(
     310                    ExtensionContext.Namespace.create(FakeImageryExtension.class));
     311            return (List<ConstSource>) store.get(ConstSource.class, List.class);
     312        }
     313    }
     314}
  • test/unit/org/openstreetmap/josm/testutils/annotations/FullPreferences.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/FullPreferences.java b/test/unit/org/openstreetmap/josm/testutils/annotations/FullPreferences.java
    index 92fa0844e5..42d07918df 100644
    a b import org.openstreetmap.josm.testutils.annotations.BasicPreferences.BasicPrefer  
    2929@Documented
    3030@Retention(RetentionPolicy.RUNTIME)
    3131@Target({ElementType.TYPE, ElementType.METHOD})
    32 @JosmHome
    3332@BasicPreferences
    3433@ExtendWith(FullPreferences.UsePreferencesExtension.class)
    3534public @interface FullPreferences {
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/IntegrationTest.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/IntegrationTest.java b/test/unit/org/openstreetmap/josm/testutils/annotations/IntegrationTest.java
    new file mode 100644
    index 0000000000..e1698055b6
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.RetentionPolicy.RUNTIME;
     5
     6import java.lang.annotation.Documented;
     7import java.lang.annotation.ElementType;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     10
     11import org.junit.jupiter.api.Tag;
     12
     13/**
     14 * Integration Tests annotation (JUnit5 can filter tests with/without this annotation)
     15 * @author Taylor Smock
     16 * @since xxx
     17 */
     18@Documented
     19@Retention(RUNTIME)
     20@Target({ElementType.METHOD, ElementType.TYPE})
     21@Tag("integrationTest")
     22public @interface IntegrationTest {
     23
     24}
  • test/unit/org/openstreetmap/josm/testutils/annotations/JosmHome.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/JosmHome.java b/test/unit/org/openstreetmap/josm/testutils/annotations/JosmHome.java
    index c51d0e00f4..61075fbe2f 100644
    a b import java.nio.file.attribute.BasicFileAttributes;  
    1616import java.util.UUID;
    1717
    1818import org.junit.jupiter.api.extension.AfterAllCallback;
     19import org.junit.jupiter.api.extension.AfterEachCallback;
    1920import org.junit.jupiter.api.extension.BeforeAllCallback;
     21import org.junit.jupiter.api.extension.BeforeEachCallback;
    2022import org.junit.jupiter.api.extension.ExtendWith;
    2123import org.junit.jupiter.api.extension.ExtensionContext;
    2224import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
    import org.openstreetmap.josm.testutils.JOSMTestRules;  
    2527
    2628/**
    2729 * Use the JOSM home directory. See {@link JOSMTestRules}.
    28  * Typically only used by {@link FullPreferences}.
     30 * Called by {@link BasicPreferences}.
    2931 *
    3032 * @author Taylor Smock
    3133 * @since 18037
    public @interface JosmHome {  
    3941     * Create a JOSM home directory. Prefer using {@link JosmHome}.
    4042     * @author Taylor Smock
    4143     */
    42     class JosmHomeExtension implements BeforeAllCallback, AfterAllCallback {
     44    class JosmHomeExtension implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
    4345        @Override
    4446        public void afterAll(ExtensionContext context) throws Exception {
    4547            Path tempDir = context.getStore(Namespace.create(JosmHome.class)).get("home", Path.class);
    public @interface JosmHome {  
    6668            System.setProperty("josm.home", home.getAbsolutePath());
    6769            JosmBaseDirectories.getInstance().clearMemos();
    6870        }
     71
     72        @Override
     73        public void afterEach(ExtensionContext context) throws Exception {
     74            if (shouldRun(context)) {
     75                this.afterAll(context);
     76                // Restore the "original" home
     77                ExtensionContext.Store store = context.getStore(Namespace.create(JosmHome.class));
     78                Path oldHome = store.get("old_home", Path.class);
     79                System.setProperty("josm.home", oldHome.toFile().getAbsolutePath());
     80                JosmBaseDirectories.getInstance().clearMemos();
     81            }
     82        }
     83
     84        @Override
     85        public void beforeEach(ExtensionContext context) throws Exception {
     86            if (shouldRun(context)) {
     87                // Store the "original" home
     88                ExtensionContext.Store store = context.getStore(Namespace.create(JosmHome.class));
     89                store.put("old_home", store.get("home", Path.class));
     90                this.beforeAll(context);
     91            }
     92        }
     93
     94        /**
     95         * Check if this should run before/after each test
     96         * @param context The context to use
     97         * @return {@code true} if we should change home directories before/after each test
     98         */
     99        private boolean shouldRun(ExtensionContext context) {
     100            return AnnotationUtils.findFirstParentAnnotation(context, BasicPreferences.class).map(BasicPreferences::value).orElse(false);
     101        }
    69102    }
    70103}
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/Main.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/Main.java b/test/unit/org/openstreetmap/josm/testutils/annotations/Main.java
    new file mode 100644
    index 0000000000..1d430563b0
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.RetentionPolicy.RUNTIME;
     5
     6import java.lang.annotation.Documented;
     7import java.lang.annotation.ElementType;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     10import java.util.Optional;
     11
     12import org.junit.jupiter.api.extension.AfterEachCallback;
     13import org.junit.jupiter.api.extension.BeforeEachCallback;
     14import org.junit.jupiter.api.extension.ExtendWith;
     15import org.junit.jupiter.api.extension.ExtensionContext;
     16import org.junit.platform.commons.support.AnnotationSupport;
     17import org.openstreetmap.josm.JOSMFixture;
     18import org.openstreetmap.josm.gui.MainApplication;
     19import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.mockers.WindowlessMapViewStateMocker;
     21import org.openstreetmap.josm.testutils.mockers.WindowlessNavigatableComponentMocker;
     22
     23/**
     24 * Use the {@link MainApplication#main}, {@code Main.contentPanePrivate}, {@code Main.mainPanel}, global variables in this test.
     25 * @author Taylor Smock
     26 * @see JOSMTestRules#main()
     27 * @since xxx
     28 */
     29@Documented
     30@Retention(RUNTIME)
     31@Target({ ElementType.TYPE, ElementType.METHOD })
     32@BasicPreferences
     33@HTTP // Prevent MOTD from throwing
     34@ExtendWith(Main.MainExtension.class)
     35public @interface Main {
     36    /**
     37     * Get the class to use as the mocker for the map view
     38     * @return The mocker class for the map view
     39     */
     40    Class<?> mapViewStateMocker() default WindowlessMapViewStateMocker.class;
     41
     42    /**
     43     * Get the class to use for the navigable component
     44     * @return The class to use for the navigable component.
     45     */
     46    Class<?> navigableComponentMocker() default WindowlessNavigatableComponentMocker.class;
     47
     48    /**
     49     * Initialize the MainApplication
     50     * @author Taylor Smock
     51     */
     52    class MainExtension implements BeforeEachCallback, AfterEachCallback {
     53        @Override
     54        public void afterEach(ExtensionContext context) throws Exception {
     55            synchronized (MainExtension.class) {
     56                MainApplication.getLayerManager().resetState();
     57                AnnotationUtils.resetStaticClass(MainApplication.class);
     58            }
     59        }
     60
     61        @Override
     62        public void beforeEach(ExtensionContext context) throws Exception {
     63            Optional<Main> annotation = AnnotationSupport.findAnnotation(context.getElement(), Main.class);
     64            Class<?> mapViewStateMocker = null;
     65            Class<?> navigableComponentMocker = null;
     66            if (annotation.isPresent()) {
     67                mapViewStateMocker = annotation.get().mapViewStateMocker();
     68                navigableComponentMocker = annotation.get().navigableComponentMocker();
     69            }
     70
     71            // apply mockers to MapViewState and NavigableComponent whether we're headless or not
     72            // as we generally don't create the josm main window even in non-headless mode.
     73            if (mapViewStateMocker != null) {
     74                mapViewStateMocker.getConstructor().newInstance();
     75            }
     76            if (navigableComponentMocker != null) {
     77                navigableComponentMocker.getConstructor().newInstance();
     78            }
     79
     80            synchronized (MainExtension.class) {
     81                new MainApplication();
     82                JOSMFixture.initContentPane();
     83                JOSMFixture.initMainPanel(true);
     84                JOSMFixture.initToolbar();
     85                JOSMFixture.initMainMenu();
     86            }
     87        }
     88    }
     89}
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/MockVersion.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/MockVersion.java b/test/unit/org/openstreetmap/josm/testutils/annotations/MockVersion.java
    new file mode 100644
    index 0000000000..12ee7530c8
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import java.io.ByteArrayInputStream;
     5import java.nio.charset.StandardCharsets;
     6
     7import org.openstreetmap.josm.data.Version;
     8import org.openstreetmap.josm.testutils.JOSMTestRules;
     9
     10/**
     11 * This is only publicly available for {@link JOSMTestRules#assumeRevision(String)}.
     12 * This may (and probably will) become a private class in the future.
     13 */
     14public class MockVersion extends Version {
     15    public MockVersion(final String propertiesString) {
     16        super.initFromRevisionInfo(new ByteArrayInputStream(propertiesString.getBytes(StandardCharsets.UTF_8)));
     17    }
     18}
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/OsmApiType.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/OsmApiType.java b/test/unit/org/openstreetmap/josm/testutils/annotations/OsmApiType.java
    new file mode 100644
    index 0000000000..11a5bd8b23
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.ElementType.METHOD;
     5import static java.lang.annotation.ElementType.TYPE;
     6import static java.lang.annotation.RetentionPolicy.RUNTIME;
     7
     8import java.lang.annotation.Documented;
     9import java.lang.annotation.Retention;
     10import java.lang.annotation.Target;
     11import java.util.Optional;
     12
     13import org.junit.jupiter.api.extension.AfterAllCallback;
     14import org.junit.jupiter.api.extension.AfterEachCallback;
     15import org.junit.jupiter.api.extension.BeforeAllCallback;
     16import org.junit.jupiter.api.extension.BeforeEachCallback;
     17import org.junit.jupiter.api.extension.ExtendWith;
     18import org.junit.jupiter.api.extension.ExtensionContext;
     19import org.openstreetmap.josm.io.OsmApi;
     20import org.openstreetmap.josm.spi.preferences.Config;
     21import org.openstreetmap.josm.testutils.FakeOsmApi;
     22import org.openstreetmap.josm.testutils.JOSMTestRules;
     23
     24/**
     25 * Specify the OSM API to use for the test. {@link APIType#NONE} has no effect.
     26 *
     27 * @author Taylor Smock
     28 * @see JOSMTestRules#devAPI()
     29 * @see JOSMTestRules#fakeAPI()
     30 * @since xxx
     31 */
     32@Documented
     33@Retention(RUNTIME)
     34@Target({ TYPE, METHOD })
     35@FullPreferences
     36@HTTP
     37@ExtendWith(OsmApiType.OsmApiTypeExtension.class)
     38public @interface OsmApiType {
     39    /**
     40     * The API type to use
     41     * @return The API type to use (default NONE)
     42     */
     43    APIType value() default APIType.NONE;
     44
     45    /**
     46     * API types to initialize
     47     * @author Taylor Smock
     48     *
     49     */
     50    enum APIType {
     51        NONE, FAKE, DEV
     52    }
     53
     54    /**
     55     * Initialize the OSM api
     56     * @author Taylor Smock
     57     *
     58     */
     59    class OsmApiTypeExtension implements AfterAllCallback, AfterEachCallback, BeforeAllCallback, BeforeEachCallback {
     60        @Override
     61        public void afterAll(ExtensionContext context) throws Exception {
     62            afterEach(context);
     63        }
     64
     65        @Override
     66        public void afterEach(ExtensionContext context) throws Exception {
     67            // Reset to none
     68            Config.getPref().put("osm-server.url", null);
     69            AnnotationUtils.resetStaticClass(OsmApi.class);
     70        }
     71
     72        @Override
     73        public void beforeAll(ExtensionContext context) throws Exception {
     74            beforeEach(context);
     75        }
     76
     77        @Override
     78        public void beforeEach(ExtensionContext context) throws Exception {
     79            Optional<OsmApiType> annotation = AnnotationUtils.findFirstParentAnnotation(context, OsmApiType.class);
     80            APIType useAPI = APIType.NONE;
     81            if (annotation.isPresent()) {
     82                useAPI = annotation.get().value();
     83            }
     84            // Set API
     85            if (useAPI == APIType.DEV) {
     86                Config.getPref().put("osm-server.url", "https://api06.dev.openstreetmap.org/api");
     87            } else if (useAPI == APIType.FAKE) {
     88                FakeOsmApi api = FakeOsmApi.getInstance();
     89                Config.getPref().put("osm-server.url", api.getServerUrl());
     90            }
     91
     92            // Initialize API
     93            if (useAPI != APIType.NONE) {
     94                OsmApi.getOsmApi().initialize(null);
     95            }
     96        }
     97    }
     98}
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/Projection.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/Projection.java b/test/unit/org/openstreetmap/josm/testutils/annotations/Projection.java
    new file mode 100644
    index 0000000000..0d0ce136ae
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import java.lang.annotation.Documented;
     5import java.lang.annotation.ElementType;
     6import java.lang.annotation.Retention;
     7import java.lang.annotation.RetentionPolicy;
     8import java.lang.annotation.Target;
     9import java.util.Optional;
     10
     11import org.junit.jupiter.api.extension.AfterAllCallback;
     12import org.junit.jupiter.api.extension.BeforeAllCallback;
     13import org.junit.jupiter.api.extension.BeforeEachCallback;
     14import org.junit.jupiter.api.extension.ExtendWith;
     15import org.junit.jupiter.api.extension.ExtensionContext;
     16import org.junit.platform.commons.support.AnnotationSupport;
     17import org.openstreetmap.josm.data.projection.ProjectionRegistry;
     18import org.openstreetmap.josm.data.projection.Projections;
     19import org.openstreetmap.josm.testutils.JOSMTestRules;
     20
     21/**
     22 * Use projections in tests (Mercator).
     23 * @author Taylor Smock
     24 * @see JOSMTestRules#projection()
     25 *
     26 */
     27@Documented
     28@Retention(RetentionPolicy.RUNTIME)
     29@Target({ElementType.METHOD, ElementType.TYPE})
     30@ExtendWith(Projection.ProjectionExtension.class)
     31public @interface Projection {
     32    /**
     33     * The value to use for the projection. Defaults to EPSG:3857 (Mercator).
     34     * @return The value to use to get the projection from {@link Projections#getProjectionByCode}.
     35     */
     36    String projectionCode() default "EPSG:3857";
     37
     38    /**
     39     * Use projections in tests. Use {@link Projection} preferentially.
     40     * @author Taylor Smock
     41     *
     42     */
     43    class ProjectionExtension implements BeforeEachCallback, BeforeAllCallback, AfterAllCallback {
     44        @Override
     45        public void afterAll(ExtensionContext context) throws Exception {
     46            ProjectionRegistry.clearProjectionChangeListeners();
     47            AnnotationUtils.resetStaticClass(ProjectionRegistry.class);
     48        }
     49
     50        @Override
     51        public void beforeAll(ExtensionContext context) throws Exception {
     52            // Needed in order to run prior to Territories
     53            beforeEach(context);
     54        }
     55
     56        @Override
     57        public void beforeEach(ExtensionContext context) throws Exception {
     58            Optional<Projection> annotation = AnnotationSupport.findAnnotation(context.getElement(), Projection.class);
     59            if (annotation.isPresent()) {
     60                ProjectionRegistry.setProjection(Projections.getProjectionByCode(annotation.get().projectionCode()));
     61            } else {
     62                ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
     63            }
     64        }
     65
     66    }
     67}
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/Territories.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/Territories.java b/test/unit/org/openstreetmap/josm/testutils/annotations/Territories.java
    new file mode 100644
    index 0000000000..5a552bfa04
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import java.lang.annotation.Documented;
     5import java.lang.annotation.ElementType;
     6import java.lang.annotation.Retention;
     7import java.lang.annotation.RetentionPolicy;
     8import java.lang.annotation.Target;
     9import java.util.Optional;
     10
     11import org.junit.jupiter.api.extension.AfterAllCallback;
     12import org.junit.jupiter.api.extension.BeforeAllCallback;
     13import org.junit.jupiter.api.extension.ExtendWith;
     14import org.junit.jupiter.api.extension.ExtensionContext;
     15import org.junit.platform.commons.support.AnnotationSupport;
     16import org.openstreetmap.josm.testutils.JOSMTestRules;
     17
     18/**
     19 * Use boundaries dataset in this test.
     20 * @see JOSMTestRules#territories()
     21 * @author Taylor Smock
     22 * @since xxx
     23 */
     24@Documented
     25@Retention(RetentionPolicy.RUNTIME)
     26@Target(ElementType.TYPE)
     27@BasicPreferences // Needed for nodes
     28@Projection // Needed for getEastNorth
     29@ExtendWith(Territories.TerritoriesExtension.class)
     30public @interface Territories {
     31    /**
     32     * Initialization states. Please note that the highest initialization state holds.
     33     * @author Taylor Smock
     34     */
     35    enum Initialize {
     36        /** Don't initialize */
     37        NONE,
     38        /** Initialize only internal data */
     39        INTERNAL,
     40        /** Initialize internal and external data. Requires {@link HTTP}. */
     41        ALL
     42    }
     43
     44    /**
     45     * The way to initialize Territories
     46     * @return The value to use
     47     */
     48    Initialize value() default Initialize.INTERNAL;
     49
     50    /**
     51     * Initialize boundaries prior to use
     52     * @author Taylor Smock
     53     *
     54     */
     55    class TerritoriesExtension implements BeforeAllCallback, AfterAllCallback {
     56        /** This state is only used to avoid re-initializing the Territories class */
     57        private static Initialize state = Initialize.NONE;
     58        @Override
     59        public void afterAll(ExtensionContext context) throws Exception {
     60            synchronized (TerritoriesExtension.class) {
     61                // TODO org.openstreetmap.josm.tools.Territories.uninitialize();
     62            }
     63        }
     64
     65        @Override
     66        public void beforeAll(ExtensionContext context) throws Exception {
     67            Optional<Territories> annotation = AnnotationSupport.findAnnotation(context.getElement(), Territories.class);
     68            if (annotation.isPresent()) {
     69                Initialize current = annotation.get().value();
     70                // Avoid potential race conditions if tests are parallelized
     71                synchronized (TerritoriesExtension.class) {
     72                    if (current == Initialize.INTERNAL && state != Initialize.ALL && state != Initialize.INTERNAL) {
     73                        org.openstreetmap.josm.tools.Territories.initializeInternalData();
     74                        state = Initialize.INTERNAL;
     75                    } else if (current == Initialize.ALL && state != Initialize.ALL) {
     76                        org.openstreetmap.josm.tools.Territories.initialize();
     77                        state = Initialize.ALL;
     78                    }
     79                }
     80            }
     81        }
     82    }
     83}
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ColorSource.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ColorSource.java b/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ColorSource.java
    new file mode 100644
    index 0000000000..b06d502f4d
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations.fake_imagery;
     3
     4import javax.imageio.ImageIO;
     5import java.awt.Color;
     6import java.awt.Graphics2D;
     7import java.awt.image.BufferedImage;
     8import java.io.ByteArrayOutputStream;
     9import java.io.IOException;
     10import java.util.Objects;
     11
     12import org.openstreetmap.josm.data.imagery.ImageryInfo;
     13import org.openstreetmap.josm.testutils.annotations.FakeImagery;
     14import org.openstreetmap.josm.tools.Logging;
     15
     16import com.github.tomakehurst.wiremock.client.MappingBuilder;
     17import com.github.tomakehurst.wiremock.client.WireMock;
     18
     19/**
     20 * A plain color tile source
     21 * @since xxx
     22 */
     23public class ColorSource extends ConstSource {
     24    protected final Color color;
     25    protected final String label;
     26    protected final int tileSize;
     27
     28    /**
     29     * Create a new ColorSource
     30     * @param colorTileSource The tile source to use
     31     */
     32    public ColorSource(final FakeImagery.ColorTileSource colorTileSource) {
     33        this(colorTileSource.colors().getColor(), colorTileSource.name(), colorTileSource.size());
     34    }
     35
     36    /**
     37     * @param color Color for these tiles
     38     * @param label text label/name for this source if displayed in JOSM menus
     39     * @param tileSize Pixel dimension of tiles (usually 256)
     40     */
     41    public ColorSource(Color color, String label, int tileSize) {
     42        this.color = color;
     43        this.label = label;
     44        this.tileSize = tileSize;
     45    }
     46
     47    @Override
     48    public int hashCode() {
     49        return Objects.hash(this.color, this.label, this.tileSize, this.getClass());
     50    }
     51
     52    @Override
     53    public byte[] generatePayloadBytes() {
     54        BufferedImage image = new BufferedImage(this.tileSize, this.tileSize, BufferedImage.TYPE_INT_RGB);
     55        Graphics2D g = image.createGraphics();
     56        g.setBackground(this.color);
     57        g.clearRect(0, 0, image.getWidth(), image.getHeight());
     58
     59        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
     60        try {
     61            ImageIO.write(image, "png", outputStream);
     62        } catch (IOException e) {
     63            Logging.trace(e);
     64        }
     65        return outputStream.toByteArray();
     66    }
     67
     68    @Override
     69    public MappingBuilder getMappingBuilder() {
     70        return WireMock.get(WireMock.urlMatching(String.format("/%h/(\\d+)/(\\d+)/(\\d+)\\.png", this.hashCode())));
     71    }
     72
     73    @Override
     74    public ImageryInfo getImageryInfo(int port) {
     75        return new ImageryInfo(this.label,
     76                String.format("tms[20]:http://localhost:%d/%h/{z}/{x}/{y}.png", port, this.hashCode()), "tms",
     77                (String) null, (String) null);
     78    }
     79
     80    @Override
     81    public String getLabel() {
     82        return this.label;
     83    }
     84}
  • new file test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ConstSource.java

    diff --git a/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ConstSource.java b/test/unit/org/openstreetmap/josm/testutils/annotations/fake_imagery/ConstSource.java
    new file mode 100644
    index 0000000000..cd3fa37e0c
    - +  
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations.fake_imagery;
     3
     4import org.openstreetmap.josm.data.imagery.ImageryInfo;
     5import org.openstreetmap.josm.testutils.TileSourceRule;
     6
     7import com.github.tomakehurst.wiremock.WireMockServer;
     8
     9/**
     10 * Class defining a tile source for TileSourceRule to mock. Due to the way WireMock is designed, it is far more
     11 * straightforward to serve a single image in all tile positions
     12 *
     13 * Please note that this extends {@link TileSourceRule.ConstSource} for compatibility reasons.
     14 * {@link TileSourceRule} may be removed in the future.
     15 * @since xxx
     16 */
     17public abstract class ConstSource extends TileSourceRule.ConstSource {
     18    // This class should have the same body as {@link TileSourceRule.ConstSource}
     19    // For now, this class solely exists for transitioning off of JUnit 4 (the assumption is that JOSM will
     20    // eventually remove all JUnit 4 dependent classes, at which point the parent class will be deleted, and its
     21    // body moved here).
     22
     23    /**
     24     * Get the imagery info object for the specified wiremock server (use this instead of the port-based method)
     25     * @param wireMockServer The wiremock server to use
     26     * @return The URL for the object
     27     */
     28    public ImageryInfo getImageryInfo(final WireMockServer wireMockServer) {
     29        // When main body is moved here, mark getImageryInfo(int port) as deprecated
     30        return this.getImageryInfo(wireMockServer.port());
     31    }
     32}
  • test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java b/test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java
    index 77bef7ea66..a7d9c5e351 100644
    a b import org.openstreetmap.josm.io.OsmApiException;  
    2222import org.openstreetmap.josm.io.OsmApiInitializationException;
    2323import org.openstreetmap.josm.io.auth.CredentialsManager;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2526import org.openstreetmap.josm.tools.date.DateUtils;
    2627import org.openstreetmap.josm.tools.date.DateUtilsTest;
    2728
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    3031/**
    3132 * Unit tests of {@link ExceptionUtil} class.
    3233 */
     34@BasicPreferences
    3335class ExceptionUtilTest {
    3436
    3537    /**
    class ExceptionUtilTest {  
    3739     */
    3840    @RegisterExtension
    3941    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI();
     42    public JOSMTestRules test = new JOSMTestRules().fakeAPI();
    4143
    4244    private static String baseUrl;
    4345    private static String serverUrl;
  • test/unit/org/openstreetmap/josm/tools/GeometryTest.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/GeometryTest.java b/test/unit/org/openstreetmap/josm/tools/GeometryTest.java
    index b58c6d24e2..67ef2a94cb 100644
    a b import org.openstreetmap.josm.data.projection.ProjectionRegistry;  
    3636import org.openstreetmap.josm.data.projection.Projections;
    3737import org.openstreetmap.josm.io.OsmReader;
    3838import org.openstreetmap.josm.testutils.JOSMTestRules;
     39import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3940
    4041import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    4142
    4243/**
    4344 * Unit tests of {@link Geometry} class.
    4445 */
     46@BasicPreferences
    4547class GeometryTest {
    4648    /**
    4749     * Primitives need preferences and projection.
    4850     */
    4951    @RegisterExtension
    5052    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    51     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
     53    public JOSMTestRules test = new JOSMTestRules().projection();
    5254
    5355    /**
    5456     * Test of {@link Geometry#getLineLineIntersection} method.
  • test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java b/test/unit/org/openstreetmap/josm/tools/OsmPrimitiveImageProviderTest.java
    index 87830b2d75..eaaae8f40f 100644
    a b import org.openstreetmap.josm.data.osm.OsmUtils;  
    1919import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    2020import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetsTest;
    2121import org.openstreetmap.josm.testutils.JOSMTestRules;
     22import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2223import org.openstreetmap.josm.tools.OsmPrimitiveImageProvider.Options;
    2324
    2425import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;  
    2627/**
    2728 * Unit tests of {@link OsmPrimitiveImageProvider}
    2829 */
     30@BasicPreferences
    2931class OsmPrimitiveImageProviderTest {
    3032
    3133    /**
  • test/unit/org/openstreetmap/josm/tools/PlatformHookTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/PlatformHookTestIT.java b/test/unit/org/openstreetmap/josm/tools/PlatformHookTestIT.java
    index 7e4b5169de..8181596e02 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    1414import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515
    1616import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     17import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    1718
    1819/**
    1920 * Integration tests of {@link PlatformHook} class.
    2021 */
     22@IntegrationTest
    2123class PlatformHookTestIT {
    2224
    2325    /**
  • test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java b/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java
    index a77f57e97d..361f5e7e23 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    2020import org.openstreetmap.josm.TestUtils;
    2121import org.openstreetmap.josm.spi.preferences.Config;
    2222import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2324
    2425import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2526import mockit.Expectations;
    import mockit.Mocked;  
    2829/**
    2930 * Unit tests of {@link PlatformHookWindows} class.
    3031 */
     32@BasicPreferences
    3133class PlatformHookWindowsTest {
    3234
    3335    /**
    class PlatformHookWindowsTest {  
    3537     */
    3638    @RegisterExtension
    3739    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().preferences().https();
     40    public JOSMTestRules test = new JOSMTestRules().https();
    3941
    4042    static PlatformHookWindows hook;
    4143
  • test/unit/org/openstreetmap/josm/tools/TerritoriesTestIT.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/TerritoriesTestIT.java b/test/unit/org/openstreetmap/josm/tools/TerritoriesTestIT.java
    index f0c25d8c7f..b88d82569a 100644
    a b import org.junit.jupiter.api.extension.RegisterExtension;  
    1111import org.openstreetmap.josm.testutils.JOSMTestRules;
    1212
    1313import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     14import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    1415
    1516/**
    1617 * Integration tests of {@link Territories} class.
    1718 */
     19@IntegrationTest
    1820class TerritoriesTestIT {
    1921
    2022    /**
  • test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java b/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java
    index bc3d94c3d8..c2a5ade9fb 100644
    a b import org.junit.jupiter.api.Disabled;  
    2020import org.junit.jupiter.api.Test;
    2121import org.junit.jupiter.api.extension.RegisterExtension;
    2222import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     24import org.openstreetmap.josm.testutils.annotations.I18n;
    2325import org.openstreetmap.josm.tools.UncheckedParseException;
    2426
    25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2627import net.trajano.commons.testing.UtilityClassTestUtil;
    2728
    2829/**
    2930 * Unit tests of {@link DateUtils} class.
    3031 */
     32@I18n
     33@BasicPreferences
    3134public class DateUtilsTest {
    32 
    33     /**
    34      * Set the timezone and timeout.
    35      * <p>
    36      * Timeouts need to be disabled because we change the time zone.
    37      */
     35    // Solely needed for setting clock to UTC. To be replaced with @TimeZoneAnnotation
    3836    @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().i18n().preferences();
    41 
     37    JOSMTestRules josmTestRules = new JOSMTestRules();
    4238    /**
    4339     * Tests that {@code DateUtils} satisfies utility class criteria.
    4440     * @throws ReflectiveOperationException if an error occurs
  • test/unit/org/openstreetmap/josm/tools/date/IntervalTest.java

    diff --git a/test/unit/org/openstreetmap/josm/tools/date/IntervalTest.java b/test/unit/org/openstreetmap/josm/tools/date/IntervalTest.java
    index fe59d460cf..4b8bbe18f1 100644
    a b  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.tools.date;
    33
    4 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    5 import org.junit.jupiter.api.BeforeEach;
    6 import org.junit.jupiter.api.Test;
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    8 import org.openstreetmap.josm.testutils.JOSMTestRules;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
    95
    106import java.time.Instant;
    117import java.util.Locale;
    128
    13 import static org.junit.jupiter.api.Assertions.assertEquals;
     9import org.junit.jupiter.api.BeforeEach;
     10import org.junit.jupiter.api.Test;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1412
     13@BasicPreferences
    1514class IntervalTest {
    16 
    17     /**
    18      * Setup test.
    19      */
    20     @RegisterExtension
    21     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    22     public JOSMTestRules test = new JOSMTestRules().preferences();
    23 
    2415    /**
    2516     * Setup test.
    2617     */