Ticket #16567: 16567.initial_extensions.3.patch

File 16567.initial_extensions.3.patch, 189.1 KB (added by taylor.smock, 5 years ago)

Modify Territories to have an uninitialize function (java-docs indicate that calling it outside of a test environment is a very bad idea (tm)), modify several tests to use the extensions (largely focused on longer tests, most taking >10s on my machine), add a utils class to find appropriate annotations and reset static classes, add replacements for assertionsInEDT, http, https, a new specific annotation for DeleteCommandCallback, setting up and cleaning up the layer environment, timezone usage, annotations for integration and slow tests

  • src/org/openstreetmap/josm/tools/RightAndLefthandTraffic.java

     
    4747        rlCache = new GeoPropertyIndex<>(geoProperty, 24);
    4848    }
    4949
     50    /**
     51     * Uninitialize RightAndLefthandTraffic. This should <i>only</i> be used in tests,
     52     * and only by the Territories extension. Calling this in production code
     53     * <i>is an error</i> and will break stuff.
     54     */
     55    static void uninitialize() {
     56        rlCache = null;
     57    }
     58
    5059    static void appendLeftDrivingBoundaries(OsmPrimitive osm, Collection<Way> ways) {
    5160        // Find all outer ways of left-driving countries. Many of them are adjacent (African and Asian states)
    5261        if (LEFT.equals(osm.get(DRIVING_SIDE))) {
  • src/org/openstreetmap/josm/tools/Territories.java

     
    125125    }
    126126
    127127    /**
     128     * Uninitialize territories. This should <i>only</i> be used in tests,
     129     * and only by the Territories extension. Calling this in production code
     130     * <i>is an error</i> and will break stuff.
     131     */
     132    public static synchronized void uninitialize() {
     133        iso3166Cache = null;
     134        taginfoCache = null;
     135        customTagsCache = null;
     136        dataSet = null;
     137        taginfoGeofabrikCache = null;
     138        customTagsCache = null;
     139        RightAndLefthandTraffic.uninitialize();
     140    }
     141
     142    /**
    128143     * Initializes territories using the internal data only.
    129144     */
    130145    public static synchronized void initializeInternalData() {
  • test/functional/org/openstreetmap/josm/data/BoundariesTestIT.java

     
    1111import java.util.stream.Collectors;
    1212
    1313import org.junit.jupiter.api.Test;
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    1514import org.openstreetmap.josm.data.osm.DataSet;
    1615import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1716import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    1817import org.openstreetmap.josm.io.OsmReader;
    19 import org.openstreetmap.josm.testutils.JOSMTestRules;
     18import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     19import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2020
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    22 
    2321/**
    2422 * Test of boundaries OSM file.
    2523 */
     24@BasicPreferences
     25@IntegrationTest
    2626class BoundariesTestIT {
    2727
    2828    private static final List<String> RETIRED_ISO3166_1_CODES = Arrays.asList(
     
    4747            "US-WY");
    4848
    4949    /**
    50      * Setup test.
    51      */
    52     @RegisterExtension
    53     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public JOSMTestRules test = new JOSMTestRules().preferences();
    55 
    56     /**
    5750     * Test of boundaries OSM file.
    5851     * @throws Exception if an error occurs
    5952     */
  • test/functional/org/openstreetmap/josm/data/osm/TaginfoTestIT.java

     
    2222import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    2323import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    2424import org.openstreetmap.josm.testutils.JOSMTestRules;
     25import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2526import org.openstreetmap.josm.tools.HttpClient;
    2627import org.xml.sax.SAXException;
    2728
     
    3031/**
    3132 * Various integration tests with Taginfo.
    3233 */
     34@IntegrationTest
    3335class TaginfoTestIT {
    3436
    3537    /**
  • test/functional/org/openstreetmap/josm/tools/ImageProviderTest.java

     
    2424
    2525import javax.swing.ImageIcon;
    2626
    27 import org.junit.jupiter.api.BeforeAll;
    2827import org.junit.jupiter.api.BeforeEach;
    2928import org.junit.jupiter.api.Test;
    30 import org.junit.jupiter.api.extension.RegisterExtension;
    3129import org.junit.jupiter.params.ParameterizedTest;
    3230import org.junit.jupiter.params.provider.ValueSource;
    33 import org.openstreetmap.josm.JOSMFixture;
    3431import org.openstreetmap.josm.TestUtils;
    3532import org.openstreetmap.josm.data.coor.LatLon;
    3633import org.openstreetmap.josm.data.osm.Node;
     
    3734import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset;
    3835import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    3936import org.openstreetmap.josm.gui.tagging.presets.items.Key;
    40 import org.openstreetmap.josm.testutils.JOSMTestRules;
     37import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    4138import org.xml.sax.SAXException;
    4239
    4340import com.kitfox.svg.SVGConst;
     
    4744/**
    4845 * Unit tests of {@link ImageProvider} class.
    4946 */
     47@BasicPreferences
    5048class ImageProviderTest {
    51 
    52     /**
    53      * Setup test.
    54      */
    55     @RegisterExtension
    56     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    57     public JOSMTestRules test = new JOSMTestRules();
    58 
    5949    private static final class LogHandler14319 extends Handler {
    6050        boolean failed;
    6151
     
    7565        }
    7666    }
    7767
    78     /**
    79      * Setup test.
    80      */
    81     @BeforeAll
    82     public static void setUp() {
    83         JOSMFixture.createUnitTestFixture().init();
    84     }
    85 
    8668    @BeforeEach
    8769    public void resetPixelDensity() {
    8870        GuiSizesHelper.setPixelDensity(1.0f);
  • test/performance/org/openstreetmap/josm/data/osm/KeyValuePerformanceTest.java

     
    1616import org.junit.Before;
    1717import org.junit.jupiter.api.Test;
    1818import org.junit.jupiter.api.Timeout;
    19 import org.junit.jupiter.api.extension.RegisterExtension;
    2019import org.openstreetmap.josm.PerformanceTestUtils;
    2120import org.openstreetmap.josm.PerformanceTestUtils.PerformanceTestTimer;
    2221import org.openstreetmap.josm.data.osm.OsmDataGenerator.KeyValueDataGenerator;
    23 import org.openstreetmap.josm.testutils.JOSMTestRules;
     22import org.openstreetmap.josm.testutils.annotations.Projection;
    2423
    2524import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2625
     
    2827 * This test measures the performance of {@link OsmPrimitive#get(String)} and related.
    2928 * @author Michael Zangl
    3029 */
     30@Projection
    3131@Timeout(value = 15*60, unit = TimeUnit.SECONDS)
    3232class KeyValuePerformanceTest {
    3333    private static final int PUT_RUNS = 10000;
     
    3939    private Random random;
    4040
    4141    /**
    42      * Prepare the test.
    43      */
    44     @RegisterExtension
    45     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    46     public JOSMTestRules test = new JOSMTestRules().projection();
    47 
    48     /**
    4942     * See if there is a big difference between Strings that are interned and those that are not.
    5043     */
    5144    @Test
  • test/performance/org/openstreetmap/josm/data/osm/visitor/paint/StyledMapRendererPerformanceTest.java

     
    99import org.junit.jupiter.api.AfterAll;
    1010import org.junit.jupiter.api.BeforeAll;
    1111import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     12import org.openstreetmap.josm.testutils.annotations.SlowTest;
    1213
    1314import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1415
     
    1516/**
    1617 * Performance test of {@code StyledMapRenderer}.
    1718 */
     19@SlowTest
    1820class StyledMapRendererPerformanceTest extends AbstractMapRendererPerformanceTestParent {
    1921
    2022    @BeforeAll
  • test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterTest.java

     
    1717 * Tests how fast {@link MapCSSStyleSource} finds the right style candidates for one object.
    1818 * @author Michael Zangl
    1919 */
    20 @Timeout(value = 15*60, unit = TimeUnit.SECONDS)
     20@Timeout(value = 15, unit = TimeUnit.MINUTES)
    2121class MapCSSStyleSourceFilterTest {
    2222
    2323    private static final int TEST_RULE_COUNT = 10000;
  • test/unit/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTaskTestParent.java

     
    88
    99import org.junit.Rule;
    1010import org.openstreetmap.josm.TestUtils;
    11 import org.openstreetmap.josm.testutils.JOSMTestRules;
     11import org.openstreetmap.josm.testutils.annotations.HTTPS;
    1212
    1313import com.github.tomakehurst.wiremock.junit.WireMockRule;
    1414
    15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    16 
    1715/**
    1816 * Superclass of {@link DownloadGpsTaskTest}, {@link DownloadOsmTaskTest} and {@link DownloadNotesTaskTest}.
    1917 */
     18@HTTPS
    2019public abstract class AbstractDownloadTaskTestParent {
    21 
    2220    /**
    23      * Setup test.
    24      */
    25     @Rule
    26     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    27     public JOSMTestRules test = new JOSMTestRules().https();
    28 
    29     /**
    3021     * HTTP mock.
    3122     */
    3223    @Rule
  • test/unit/org/openstreetmap/josm/actions/downloadtasks/PluginDownloadTaskTest.java

     
    1111import java.nio.charset.StandardCharsets;
    1212import java.util.Collections;
    1313
    14 import org.junit.Rule;
    1514import org.junit.Test;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.data.Preferences;
     
    1817import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1918import org.openstreetmap.josm.plugins.PluginDownloadTask;
    2019import org.openstreetmap.josm.plugins.PluginInformation;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.AssumeRevision;
     21import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     22import org.openstreetmap.josm.testutils.annotations.HTTPS;
    2223import org.openstreetmap.josm.tools.Utils;
    2324
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    25 
    2625/**
    2726 * Unit tests for class {@link PluginDownloadTask}.
    2827 */
     28@HTTPS
     29@AssumeRevision("Revision: 8000\n")
     30@FullPreferences
    2931public class PluginDownloadTaskTest extends AbstractDownloadTaskTestParent {
    3032    protected String pluginPath;
    3133
    32     /**
    33      * Setup test.
    34      */
    35     @Rule
    36     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    37     public JOSMTestRules testRule = new JOSMTestRules().https().assumeRevision(
    38         "Revision: 8000\n"
    39     ).preferences();
    40 
    4134    @Override
    4235    protected String getRemoteContentType() {
    4336        return "application/java-archive";
  • test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java

     
    1010import java.util.Collection;
    1111
    1212import org.junit.jupiter.api.Test;
    13 import org.junit.jupiter.api.extension.RegisterExtension;
    1413import org.openstreetmap.josm.command.PseudoCommand;
    1514import org.openstreetmap.josm.command.SequenceCommand;
    1615import org.openstreetmap.josm.data.APIDataSet;
     
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2019import org.openstreetmap.josm.data.osm.Relation;
    2120import org.openstreetmap.josm.data.osm.Way;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2322
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    25 
    2623/**
    2724 * Unit tests for class {@link FixDataHook}.
    2825 */
     26@BasicPreferences
    2927class FixDataHookTest {
    30 
    3128    /**
    32      * Setup test.
    33      */
    34     @RegisterExtension
    35     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules().main();
    37 
    38     /**
    3929     * Test of {@link FixDataHook#checkUpload} method.
    4030     */
    4131    @Test
  • test/unit/org/openstreetmap/josm/actions/upload/ValidateUploadHookTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertTrue;
    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.APIDataSet;
    9 import org.openstreetmap.josm.testutils.JOSMTestRules;
     9import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    1010
    11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    12 
    1311/**
    1412 * Unit tests for class {@link ValidateUploadHook}.
    1513 */
     14@Timeout(30)
     15@OsmApiType(apiType = OsmApiType.APIType.FAKE)
    1616class ValidateUploadHookTest {
    17 
    1817    /**
    19      * Setup test.
    20      */
    21     @RegisterExtension
    22     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    23     public JOSMTestRules test = new JOSMTestRules().fakeAPI().timeout(30000);
    24 
    25     /**
    2618     * Test of {@link ValidateUploadHook#checkUpload} method.
    2719     */
    2820    @Test
  • test/unit/org/openstreetmap/josm/command/AddPrimitivesCommandTest.java

     
    1212import java.util.List;
    1313
    1414import org.junit.jupiter.api.Test;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.data.coor.LatLon;
    1817import org.openstreetmap.josm.data.osm.DataSet;
     
    2423import org.openstreetmap.josm.data.osm.Way;
    2524import org.openstreetmap.josm.data.osm.WayData;
    2625import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    27 import org.openstreetmap.josm.testutils.JOSMTestRules;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2827
    29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3028import nl.jqno.equalsverifier.EqualsVerifier;
    3129import nl.jqno.equalsverifier.Warning;
    3230
     
    3331/**
    3432 * Unit tests of {@link AddPrimitivesCommand} class.
    3533 */
     34@BasicPreferences // for Nodes
    3635class AddPrimitivesCommandTest {
    37 
    3836    /**
    39      * We need prefs for nodes.
    40      */
    41     @RegisterExtension
    42     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    43     public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
    44 
    45     /**
    4637     * Test if the add command is executed correctly and does not set the modified flag.
    4738     */
    4839    @Test
  • test/unit/org/openstreetmap/josm/command/ChangeCommandTest.java

     
    44import static org.junit.jupiter.api.Assertions.assertArrayEquals;
    55import static org.junit.jupiter.api.Assertions.assertEquals;
    66import static org.junit.jupiter.api.Assertions.assertNull;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
    8 import static org.junit.jupiter.api.Assertions.assertThrows;
    99
    1010import java.util.ArrayList;
    1111import java.util.Collections;
     
    1313
    1414import org.junit.jupiter.api.BeforeEach;
    1515import org.junit.jupiter.api.Test;
    16 import org.junit.jupiter.api.extension.RegisterExtension;
    1716import org.openstreetmap.josm.TestUtils;
    1817import org.openstreetmap.josm.command.CommandTest.CommandTestData;
    1918import org.openstreetmap.josm.data.coor.LatLon;
     
    2524import org.openstreetmap.josm.data.osm.User;
    2625import org.openstreetmap.josm.data.osm.Way;
    2726import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    28 import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     28import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
    2929
    30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3130import nl.jqno.equalsverifier.EqualsVerifier;
    3231import nl.jqno.equalsverifier.Warning;
    3332
     
    3433/**
    3534 * Unit tests of {@link ChangeCommand} class.
    3635 */
     36@LayerEnvironment
     37@BasicPreferences // Preferences are needed for Nodes
    3738class ChangeCommandTest {
    38 
    39     /**
    40      * We need prefs for nodes.
    41      */
    42     @RegisterExtension
    43     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    44     public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
    4539    private CommandTestData testData;
    4640
    4741    /**
  • test/unit/org/openstreetmap/josm/command/ChangeMembersCommandTest.java

     
    99
    1010import org.junit.jupiter.api.BeforeEach;
    1111import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    1312import org.openstreetmap.josm.TestUtils;
    1413import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    1514import org.openstreetmap.josm.data.osm.DataSet;
     
    1817import org.openstreetmap.josm.data.osm.RelationMember;
    1918import org.openstreetmap.josm.data.osm.User;
    2019import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     21import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
    2222
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2423import nl.jqno.equalsverifier.EqualsVerifier;
    2524import nl.jqno.equalsverifier.Warning;
    2625
     
    2726/**
    2827 * Unit tests of {@link ChangeMembersCommand} class.
    2928 */
     29@LayerEnvironment
     30@BasicPreferences // For nodes
    3031class ChangeMembersCommandTest {
    31 
    32     /**
    33      * We need prefs for nodes.
    34      */
    35     @RegisterExtension
    36     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    37     public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
    3832    private CommandTestDataWithRelation testData;
    3933
    4034    /**
  • test/unit/org/openstreetmap/josm/command/ChangePropertyCommandTest.java

     
    1515
    1616import org.junit.jupiter.api.BeforeEach;
    1717import org.junit.jupiter.api.Test;
    18 import org.junit.jupiter.api.extension.RegisterExtension;
    1918import org.openstreetmap.josm.TestUtils;
    2019import org.openstreetmap.josm.command.CommandTest.CommandTestData;
    2120import org.openstreetmap.josm.data.osm.DataSet;
     
    2625import org.openstreetmap.josm.data.osm.User;
    2726import org.openstreetmap.josm.data.osm.Way;
    2827import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    29 import org.openstreetmap.josm.testutils.JOSMTestRules;
     28import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     29import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
    3030
    31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3231import nl.jqno.equalsverifier.EqualsVerifier;
    3332import nl.jqno.equalsverifier.Warning;
    3433
     
    3534/**
    3635 * Unit tests of {@link ChangePropertyCommand} class.
    3736 */
     37@BasicPreferences
     38@LayerEnvironment
    3839class ChangePropertyCommandTest {
    3940
    40     /**
    41      * We need prefs for nodes.
    42      */
    43     @RegisterExtension
    44     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    45     public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
    4641    private CommandTestData testData;
    4742
    4843    /**
  • test/unit/org/openstreetmap/josm/command/ChangeRelationMemberRoleCommandTest.java

     
    1111
    1212import org.junit.jupiter.api.BeforeEach;
    1313import org.junit.jupiter.api.Test;
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    1514import org.openstreetmap.josm.TestUtils;
    1615import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    1716import org.openstreetmap.josm.data.osm.DataSet;
     
    1918import org.openstreetmap.josm.data.osm.Relation;
    2019import org.openstreetmap.josm.data.osm.User;
    2120import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     22import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
    2323
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2524import nl.jqno.equalsverifier.EqualsVerifier;
    2625import nl.jqno.equalsverifier.Warning;
    2726
     
    2827/**
    2928 * Unit tests of {@link ChangeRelationMemberRoleCommand} class.
    3029 */
     30@LayerEnvironment
     31@BasicPreferences // For nodes
    3132class ChangeRelationMemberRoleCommandTest {
    32 
    33     /**
    34      * We need prefs for nodes.
    35      */
    36     @RegisterExtension
    37     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
    3933    private CommandTestDataWithRelation testData;
    4034
    4135    /**
  • test/unit/org/openstreetmap/josm/command/CommandTest.java

     
    44import java.util.Arrays;
    55
    66import org.junit.jupiter.api.Test;
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    87import org.openstreetmap.josm.TestUtils;
    98import org.openstreetmap.josm.data.coor.LatLon;
    109import org.openstreetmap.josm.data.osm.DataSet;
     
    1514import org.openstreetmap.josm.data.osm.Way;
    1615import org.openstreetmap.josm.gui.MainApplication;
    1716import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1918
    20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2119import nl.jqno.equalsverifier.EqualsVerifier;
    2220import nl.jqno.equalsverifier.Warning;
    2321
     
    2422/**
    2523 * Unit tests of {@link Command} class.
    2624 */
     25@BasicPreferences // Needed for nodes
    2726public class CommandTest {
    28 
    2927    /**
    30      * We need prefs for nodes / data sets.
    31      */
    32     @RegisterExtension
    33     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
    35 
    36     /**
    3728     * Unit test of methods {@link Command#equals} and {@link Command#hashCode}.
    3829     */
    3930    @Test
  • test/unit/org/openstreetmap/josm/command/DeleteCommandTest.java

     
    44import static org.junit.jupiter.api.Assertions.assertArrayEquals;
    55import static org.junit.jupiter.api.Assertions.assertEquals;
    66import static org.junit.jupiter.api.Assertions.assertFalse;
     7import static org.junit.jupiter.api.Assertions.assertThrows;
    78import static org.junit.jupiter.api.Assertions.assertTrue;
    8 import static org.junit.jupiter.api.Assertions.assertThrows;
    99
    1010import java.util.ArrayList;
    1111import java.util.Arrays;
     
    1515
    1616import org.junit.jupiter.api.BeforeEach;
    1717import org.junit.jupiter.api.Test;
    18 import org.junit.jupiter.api.extension.RegisterExtension;
    1918import org.openstreetmap.josm.TestUtils;
    2019import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    2120import org.openstreetmap.josm.data.osm.DataSet;
     
    2625import org.openstreetmap.josm.data.osm.Way;
    2726import org.openstreetmap.josm.data.osm.WaySegment;
    2827import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    29 import org.openstreetmap.josm.testutils.JOSMTestRules;
     28import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     29import org.openstreetmap.josm.testutils.annotations.DeleteCommandCallback;
    3030
    31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3231import nl.jqno.equalsverifier.EqualsVerifier;
    3332import nl.jqno.equalsverifier.Warning;
    3433
     
    3534/**
    3635 * Unit tests of {@link DeleteCommand} class.
    3736 */
     37@BasicPreferences
     38@DeleteCommandCallback
    3839class DeleteCommandTest {
    39 
    40     /**
    41      * We need prefs for nodes.
    42      */
    43     @RegisterExtension
    44     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    45     public JOSMTestRules test = new JOSMTestRules().preferences().i18n();
    4640    private CommandTestDataWithRelation testData;
    4741
    4842    /**
  • test/unit/org/openstreetmap/josm/command/MoveCommandTest.java

     
    1313
    1414import org.junit.jupiter.api.BeforeEach;
    1515import org.junit.jupiter.api.Test;
    16 import org.junit.jupiter.api.extension.RegisterExtension;
    1716import org.openstreetmap.josm.TestUtils;
    1817import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    1918import org.openstreetmap.josm.data.coor.EastNorth;
     
    2423import org.openstreetmap.josm.data.osm.User;
    2524import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    2625import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    27 import org.openstreetmap.josm.testutils.JOSMTestRules;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     27import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
     28import org.openstreetmap.josm.testutils.annotations.Projection;
    2829
    29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3030import nl.jqno.equalsverifier.EqualsVerifier;
    3131import nl.jqno.equalsverifier.Warning;
    3232
     
    3333/**
    3434 * Unit tests of {@link MoveCommand} class.
    3535 */
     36@Projection
     37@BasicPreferences // Needed for nodes
     38@LayerEnvironment
    3639class MoveCommandTest {
    37     /**
    38      * We need prefs for nodes.
    39      */
    40     @RegisterExtension
    41     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    42     public JOSMTestRules test = new JOSMTestRules().preferences().i18n().projection();
    4340    private CommandTestDataWithRelation testData;
    4441
    4542    /**
  • test/unit/org/openstreetmap/josm/command/PurgeCommandTest.java

     
    1414
    1515import org.junit.jupiter.api.BeforeEach;
    1616import org.junit.jupiter.api.Test;
    17 import org.junit.jupiter.api.extension.RegisterExtension;
    1817import org.openstreetmap.josm.TestUtils;
    1918import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    2019import org.openstreetmap.josm.data.conflict.Conflict;
     
    2726import org.openstreetmap.josm.data.osm.Storage;
    2827import org.openstreetmap.josm.data.osm.User;
    2928import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    30 import org.openstreetmap.josm.testutils.JOSMTestRules;
     29import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     30import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
    3131
    32 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3332import nl.jqno.equalsverifier.EqualsVerifier;
    3433import nl.jqno.equalsverifier.Warning;
    3534
     
    3635/**
    3736 * Unit tests of {@link PurgeCommand} class.
    3837 */
     38@BasicPreferences // For nodes
     39@LayerEnvironment
    3940class PurgeCommandTest {
    40     /**
    41      * We need prefs for nodes.
    42      */
    43     @RegisterExtension
    44     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    45     public JOSMTestRules test = new JOSMTestRules().preferences();
    4641    private CommandTestDataWithRelation testData;
    4742
    4843    /**
  • test/unit/org/openstreetmap/josm/command/RotateCommandTest.java

     
    99
    1010import org.junit.jupiter.api.BeforeEach;
    1111import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    1312import org.openstreetmap.josm.TestUtils;
    1413import org.openstreetmap.josm.command.CommandTest.CommandTestData;
    1514import org.openstreetmap.josm.data.coor.EastNorth;
     
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2019import org.openstreetmap.josm.data.osm.User;
    2120import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     22import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
     23import org.openstreetmap.josm.testutils.annotations.Projection;
    2324
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2525import nl.jqno.equalsverifier.EqualsVerifier;
    2626import nl.jqno.equalsverifier.Warning;
    2727
     
    2828/**
    2929 * Unit tests of {@link RotateCommand} class.
    3030 */
     31@Projection
     32@BasicPreferences
     33@LayerEnvironment
    3134class RotateCommandTest {
    32 
    33     /**
    34      * We need prefs for nodes.
    35      */
    36     @RegisterExtension
    37     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
    3935    private CommandTestData testData;
    4036
    4137    /**
  • test/unit/org/openstreetmap/josm/command/SelectCommandTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertArrayEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    7 import static org.junit.jupiter.api.Assertions.assertThrows;
    88
    99import java.util.ArrayList;
    1010import java.util.Arrays;
     
    1212
    1313import org.junit.jupiter.api.BeforeEach;
    1414import org.junit.jupiter.api.Test;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    1817import org.openstreetmap.josm.data.osm.DataSet;
     
    1918import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2019import org.openstreetmap.josm.data.osm.User;
    2120import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     22import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
    2323
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2524import nl.jqno.equalsverifier.EqualsVerifier;
    2625import nl.jqno.equalsverifier.Warning;
    2726
     
    2827/**
    2928 * Unit tests of {@link SelectCommand} class.
    3029 */
     30@LayerEnvironment
     31@BasicPreferences // Needed for nodes
    3132class SelectCommandTest {
    32 
    33     /**
    34      * We need prefs for nodes.
    35      */
    36     @RegisterExtension
    37     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().preferences();
    3933    private CommandTestDataWithRelation testData;
    4034
    4135    /**
  • test/unit/org/openstreetmap/josm/command/SequenceCommandTest.java

     
    2020
    2121import org.junit.jupiter.api.BeforeEach;
    2222import org.junit.jupiter.api.Test;
    23 import org.junit.jupiter.api.extension.RegisterExtension;
    2423import org.openstreetmap.josm.TestUtils;
    2524import org.openstreetmap.josm.command.CommandTest.CommandTestDataWithRelation;
    2625import org.openstreetmap.josm.data.osm.DataSet;
     
    2827import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2928import org.openstreetmap.josm.data.osm.User;
    3029import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    31 import org.openstreetmap.josm.testutils.JOSMTestRules;
     30import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     31import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
    3232import org.openstreetmap.josm.tools.bugreport.ReportedException;
    3333
    34 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3534import nl.jqno.equalsverifier.EqualsVerifier;
    3635import nl.jqno.equalsverifier.Warning;
    3736
     
    3837/**
    3938 * Unit tests of {@link SequenceCommand} class.
    4039 */
     40@LayerEnvironment
     41@BasicPreferences // For nodes
    4142class SequenceCommandTest {
    42 
    43     /**
    44      * We need prefs for nodes.
    45      */
    46     @RegisterExtension
    47     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    48     public JOSMTestRules test = new JOSMTestRules().preferences();
    4943    private CommandTestDataWithRelation testData;
    5044
    5145    /**
  • test/unit/org/openstreetmap/josm/command/conflict/CoordinateConflictResolveCommandTest.java

     
    77
    88import org.junit.jupiter.api.BeforeEach;
    99import org.junit.jupiter.api.Test;
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.openstreetmap.josm.TestUtils;
    1211import org.openstreetmap.josm.command.CommandTest.CommandTestData;
    1312import org.openstreetmap.josm.data.conflict.Conflict;
     
    1817import org.openstreetmap.josm.data.osm.Way;
    1918import org.openstreetmap.josm.gui.conflict.pair.MergeDecisionType;
    2019import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2221
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2422import nl.jqno.equalsverifier.EqualsVerifier;
    2523import nl.jqno.equalsverifier.Warning;
    2624
     
    2725/**
    2826 * Unit tests of {@link CoordinateConflictResolveCommand} class.
    2927 */
     28@BasicPreferences
    3029class CoordinateConflictResolveCommandTest {
    3130
    3231    private CommandTestData testData;
    33 
    3432    /**
    3533     * Setup test.
    3634     */
    37     @RegisterExtension
    38     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    39     public JOSMTestRules test = new JOSMTestRules();
    40 
    41     /**
    42      * Setup test.
    43      */
    4435    @BeforeEach
    4536    public void setUp() {
    4637        testData = new CommandTestData();
  • test/unit/org/openstreetmap/josm/command/conflict/RelationMemberConflictResolverCommandTest.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.command.conflict;
    33
    4 import org.junit.jupiter.api.extension.RegisterExtension;
    54import org.junit.jupiter.api.Test;
    65import org.openstreetmap.josm.TestUtils;
    76import org.openstreetmap.josm.data.conflict.Conflict;
     
    109import org.openstreetmap.josm.data.osm.Relation;
    1110import org.openstreetmap.josm.data.osm.User;
    1211import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
     12import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1413
    15 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1614import nl.jqno.equalsverifier.EqualsVerifier;
    1715import nl.jqno.equalsverifier.Warning;
    1816
     
    1917/**
    2018 * Unit tests of {@link RelationMemberConflictResolverCommand} class.
    2119 */
     20@BasicPreferences // Needed for OsmPrimitive
    2221class RelationMemberConflictResolverCommandTest {
    23 
    2422    /**
    25      * Setup test.
    26      */
    27     @RegisterExtension
    28     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    29     public JOSMTestRules test = new JOSMTestRules();
    30 
    31     /**
    3223     * Unit test of methods {@link RelationMemberConflictResolverCommand#equals} and {@link RelationMemberConflictResolverCommand#hashCode}.
    3324     */
    3425    @Test
  • test/unit/org/openstreetmap/josm/command/conflict/VersionConflictResolveCommandTest.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.command.conflict;
    33
     4import org.junit.jupiter.api.Test;
    45import org.junit.jupiter.api.extension.RegisterExtension;
    5 import org.junit.jupiter.api.Test;
    66import org.openstreetmap.josm.TestUtils;
    77import org.openstreetmap.josm.data.conflict.Conflict;
    88import org.openstreetmap.josm.data.osm.DataSet;
  • test/unit/org/openstreetmap/josm/data/UserIdentityManagerTest.java

     
    66import static org.junit.jupiter.api.Assertions.assertNotNull;
    77import static org.junit.jupiter.api.Assertions.assertNull;
    88import static org.junit.jupiter.api.Assertions.assertSame;
     9import static org.junit.jupiter.api.Assertions.assertThrows;
    910import static org.junit.jupiter.api.Assertions.assertTrue;
    10 import static org.junit.jupiter.api.Assertions.assertThrows;
    1111
    1212import org.junit.jupiter.api.Test;
    1313import org.junit.jupiter.api.extension.RegisterExtension;
  • test/unit/org/openstreetmap/josm/data/cache/HostLimitQueueTest.java

     
    1212
    1313import org.apache.commons.jcs3.access.behavior.ICacheAccess;
    1414import org.junit.jupiter.api.Test;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
     15import org.junit.jupiter.api.Timeout;
    1616import org.openstreetmap.josm.data.imagery.TMSCachedTileLoader;
    1717import org.openstreetmap.josm.data.imagery.TileJobOptions;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     18import org.openstreetmap.josm.testutils.annotations.FullPreferences;
    1919import org.openstreetmap.josm.tools.Logging;
    2020
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    22 
    2321/**
    2422 * Simple tests for ThreadPoolExecutor / HostLimitQueue veryfing, that this pair works OK
    2523 * @author Wiktor Niesiobedzki
    2624 */
     25@FullPreferences
     26@Timeout(20)
    2727class HostLimitQueueTest {
    2828    /**
    29      * Setup test.
    30      */
    31     @RegisterExtension
    32     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    33     public JOSMTestRules test = new JOSMTestRules().preferences().timeout(20 * 1000);
    34 
    35     /**
    3629     * Mock class for tests
    3730     */
    3831    static class Task extends JCSCachedTileLoaderJob<String, CacheEntry> {
  • test/unit/org/openstreetmap/josm/data/coor/LatLonTest.java

     
    1010import java.util.List;
    1111
    1212import org.junit.jupiter.api.Test;
    13 import org.junit.jupiter.api.extension.RegisterExtension;
    1413import org.openstreetmap.josm.TestUtils;
    1514import org.openstreetmap.josm.data.Bounds;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.Projection;
    1716
    1817import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1918import nl.jqno.equalsverifier.EqualsVerifier;
     
    2120/**
    2221 * Unit tests for class {@link LatLon}.
    2322 */
     23@Projection
    2424public class LatLonTest {
    25 
    26     /**
    27      * Setup test.
    28      */
    29     @RegisterExtension
    30     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    31     public JOSMTestRules test = new JOSMTestRules().projection();
    32 
    3325    private static final double EPSILON = 1e-6;
    3426
    3527    /**
  • test/unit/org/openstreetmap/josm/data/coor/PolarCoorTest.java

     
    66
    77import java.text.DecimalFormat;
    88
    9 import org.junit.jupiter.api.extension.RegisterExtension;
    109import org.junit.jupiter.api.Test;
    1110import org.openstreetmap.josm.TestUtils;
    12 import org.openstreetmap.josm.testutils.JOSMTestRules;
     11import org.openstreetmap.josm.testutils.annotations.Projection;
    1312
    14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1513import nl.jqno.equalsverifier.EqualsVerifier;
    1614
    1715/**
    1816 * Test the {@link PolarCoor} class.
    1917 */
     18@Projection
    2019class PolarCoorTest {
    21 
    2220    /**
    23      * Setup test.
    24      */
    25     @RegisterExtension
    26     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    27     public JOSMTestRules test = new JOSMTestRules().projection();
    28 
    29     /**
    3021     * Test {@link PolarCoor#PolarCoor}
    3122     */
    3223    @Test
  • test/unit/org/openstreetmap/josm/data/gpx/GpxDataTest.java

     
    2020
    2121import org.junit.jupiter.api.BeforeEach;
    2222import org.junit.jupiter.api.Test;
    23 import org.junit.jupiter.api.extension.RegisterExtension;
    2423import org.openstreetmap.josm.TestUtils;
    2524import org.openstreetmap.josm.data.Bounds;
    2625import org.openstreetmap.josm.data.DataSource;
     
    3029import org.openstreetmap.josm.data.gpx.GpxData.GpxDataChangeListener;
    3130import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    3231import org.openstreetmap.josm.io.GpxReaderTest;
    33 import org.openstreetmap.josm.testutils.JOSMTestRules;
     32import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     33import org.openstreetmap.josm.testutils.annotations.Projection;
    3434import org.openstreetmap.josm.tools.ListenerList;
    3535import org.xml.sax.SAXException;
    3636
    37 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3837import nl.jqno.equalsverifier.EqualsVerifier;
    3938import nl.jqno.equalsverifier.Warning;
    4039
     
    4140/**
    4241 * Unit tests for class {@link GpxData}.
    4342 */
     43@BasicPreferences
     44@Projection
    4445class GpxDataTest {
    45 
    46     /**
    47      * Setup test.
    48      */
    49     @RegisterExtension
    50     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    51     public JOSMTestRules test = new JOSMTestRules().projection();
    52 
    5346    private GpxData data;
    5447
    5548    /**
  • test/unit/org/openstreetmap/josm/data/oauth/SignpostAdaptersTest.java

     
    1111import java.net.URL;
    1212
    1313import org.junit.jupiter.api.Test;
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    1514import org.openstreetmap.josm.data.oauth.SignpostAdapters.HttpRequest;
    1615import org.openstreetmap.josm.data.oauth.SignpostAdapters.HttpResponse;
    1716import org.openstreetmap.josm.data.oauth.SignpostAdapters.OAuthConsumer;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.HTTP;
     18import org.openstreetmap.josm.testutils.annotations.HTTPS;
    1919import org.openstreetmap.josm.tools.HttpClient;
    2020
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2221import net.trajano.commons.testing.UtilityClassTestUtil;
    2322
    2423/**
    2524 * Unit tests for class {@link SignpostAdapters}.
    2625 */
     26@HTTP
     27@HTTPS
    2728class SignpostAdaptersTest {
    28 
    29     /**
    30      * Setup test.
    31      */
    32     @RegisterExtension
    33     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().https();
    35 
    3629    private static HttpClient newClient() throws MalformedURLException {
    3730        return HttpClient.create(new URL("https://www.openstreetmap.org"));
    3831    }
  • test/unit/org/openstreetmap/josm/data/osm/DataSetMergerTest.java

     
    1818import org.junit.jupiter.api.AfterEach;
    1919import org.junit.jupiter.api.BeforeEach;
    2020import org.junit.jupiter.api.Test;
    21 import org.junit.jupiter.api.extension.RegisterExtension;
    2221import org.openstreetmap.josm.data.coor.LatLon;
    23 import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    24 import org.openstreetmap.josm.data.projection.Projections;
    2522import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    26 import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     24import org.openstreetmap.josm.testutils.annotations.Projection;
    2725import org.openstreetmap.josm.tools.date.DateUtils;
    2826
    29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    30 
    3127/**
    3228 * Unit tests for class {@link DataSetMerger}.
    3329 */
     30@BasicPreferences // Needed for OsmPrimitive
     31@Projection
    3432class DataSetMergerTest {
    3533
    36     /**
    37      * Setup test.
    38      */
    39     @RegisterExtension
    40     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    41     public JOSMTestRules test = new JOSMTestRules();
    42 
    4334    private DataSet my;
    4435    private DataSet their;
    4536
     
    5243        my.setVersion("0.6");
    5344        their = new DataSet();
    5445        their.setVersion("0.6");
    55         ProjectionRegistry.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator
    5646    }
    5747
    5848    private void runConsistencyTests(DataSet ds) {
  • test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java

     
    1212
    1313import org.junit.Assert;
    1414import org.junit.jupiter.api.Test;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.openstreetmap.josm.TestUtils;
    1716import org.openstreetmap.josm.data.Bounds;
    1817import org.openstreetmap.josm.data.DataSource;
     
    1918import org.openstreetmap.josm.data.coor.LatLon;
    2019import org.openstreetmap.josm.data.osm.event.DataSourceAddedEvent;
    2120import org.openstreetmap.josm.data.osm.event.DataSourceRemovedEvent;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2322
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    25 
    2623/**
    2724 * Unit tests for class {@link DataSet}.
    2825 */
     26@BasicPreferences // Needed for OsmPrimitive
    2927class DataSetTest {
    30 
    3128    /**
    32      * Setup test.
    33      */
    34     @RegisterExtension
    35     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules();
    37 
    38     /**
    3929     * Unit test of method {@link DataSet#searchRelations}.
    4030     */
    4131    @Test
  • test/unit/org/openstreetmap/josm/data/osm/OsmPrimitiveKeyHandlingTest.java

     
    55import static org.junit.jupiter.api.Assertions.assertFalse;
    66import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    8 import org.junit.jupiter.api.extension.RegisterExtension;
    98import org.junit.jupiter.api.Test;
    109import org.openstreetmap.josm.data.coor.LatLon;
    11 import org.openstreetmap.josm.testutils.JOSMTestRules;
     10import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1211
    1312import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1413
     
    1615 * Some unit test cases for basic tag management on {@link OsmPrimitive}. Uses
    1716 * {@link Node} for the tests, {@link OsmPrimitive} is abstract.
    1817 */
     18@BasicPreferences // Needed for OsmPrimitive
    1919class OsmPrimitiveKeyHandlingTest {
    20 
    2120    /**
    22      * Setup test.
    23      */
    24     @RegisterExtension
    25     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    26     public JOSMTestRules test = new JOSMTestRules();
    27 
    28     /**
    2921     * test query and get methods on a node withouth keys
    3022     */
    3123    @Test
  • test/unit/org/openstreetmap/josm/data/osm/TagCollectionTest.java

     
    1717import java.util.stream.Stream;
    1818
    1919import org.junit.jupiter.api.Test;
    20 import org.junit.jupiter.api.extension.RegisterExtension;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.FullPreferences;
    2221
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    24 
    2522/**
    2623 * Tests of {@link TagCollection}.
    2724 * @author Michael Zangl
    2825 */
     26@FullPreferences // primitives require prefs
    2927class TagCollectionTest {
    3028    private final Tag tagA = new Tag("k", "v");
    3129    private final Tag tagB = new Tag("k", "b");
     
    3533    private final Tag tagNullKey = new Tag(null, "b");
    3634    private final Tag tagNullValue = new Tag("k2", null);
    3735
    38     /**
    39      * We need prefs for using primitives
    40      */
    41     @RegisterExtension
    42     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    43     public JOSMTestRules test = new JOSMTestRules().preferences();
    44 
    4536    private void assertTagCounts(TagCollection collection, int a, int b, int c, int d) {
    4637        assertEquals(a, collection.getTagOccurrence(tagA));
    4738        assertEquals(b, collection.getTagOccurrence(tagB));
  • test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java

     
    1919
    2020import org.junit.Assert;
    2121import org.junit.jupiter.api.Test;
    22 import org.junit.jupiter.api.extension.RegisterExtension;
     22import org.junit.jupiter.api.Timeout;
    2323import org.openstreetmap.josm.TestUtils;
    2424import org.openstreetmap.josm.data.coor.LatLon;
    2525import org.openstreetmap.josm.data.osm.DataSet;
     
    4141import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetType;
    4242import org.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
    4343import org.openstreetmap.josm.gui.tagging.presets.items.Key;
    44 import org.openstreetmap.josm.testutils.JOSMTestRules;
     44import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    4545import org.openstreetmap.josm.tools.Logging;
    4646import org.openstreetmap.josm.tools.date.DateUtils;
    4747
    48 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    4948import nl.jqno.equalsverifier.EqualsVerifier;
    5049import nl.jqno.equalsverifier.Warning;
    5150
     
    5251/**
    5352 * Unit tests for class {@link SearchCompiler}.
    5453 */
     54@BasicPreferences // For OSM Primitives
     55@Timeout(30)
    5556class SearchCompilerTest {
    56 
    57     /**
    58      * We need prefs for this. We access preferences when creating OSM primitives.
    59      */
    60     @RegisterExtension
    61     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    62     public JOSMTestRules test = new JOSMTestRules().preferences().timeout(30000);
    63 
    6457    private static final class SearchContext {
    6558        final DataSet ds = new DataSet();
    6659        final Node n1 = new Node(LatLon.ZERO);
  • test/unit/org/openstreetmap/josm/data/osm/visitor/MergeSourceBuildingVisitorTest.java

     
    88
    99import java.util.Collection;
    1010
    11 import org.junit.jupiter.api.extension.RegisterExtension;
    1211import org.junit.jupiter.api.Test;
    1312import org.openstreetmap.josm.data.coor.LatLon;
    1413import org.openstreetmap.josm.data.osm.DataSet;
     
    1817import org.openstreetmap.josm.data.osm.Relation;
    1918import org.openstreetmap.josm.data.osm.RelationMember;
    2019import org.openstreetmap.josm.data.osm.Way;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2221
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    24 
    2522/**
    2623 * Unit tests for class {@link MergeSourceBuildingVisitor}.
    2724 */
     25@BasicPreferences // Due to OSM primitives
    2826class MergeSourceBuildingVisitorTest {
    2927
    3028    protected OsmPrimitive lookupByName(Collection<? extends OsmPrimitive> primitives, String name) {
     
    3533                .findFirst().orElse(null);
    3634    }
    3735
    38     /**
    39      * Setup test.
    40      */
    41     @RegisterExtension
    42     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    43     public JOSMTestRules test = new JOSMTestRules();
    44 
    4536    @Test
    4637    void testNodes() {
    4738        DataSet source = new DataSet();
  • test/unit/org/openstreetmap/josm/data/preferences/JosmUrlsTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.jupiter.api.extension.RegisterExtension;
    76import org.junit.jupiter.api.Test;
    87import org.openstreetmap.josm.spi.preferences.Config;
    9 import org.openstreetmap.josm.testutils.JOSMTestRules;
     8import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    109
    11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    12 
    1310/**
    1411 * Unit tests of {@link JosmUrls} class.
    1512 */
     13@OsmApiType(apiType = OsmApiType.APIType.DEV)
    1614class JosmUrlsTest {
    17 
    1815    /**
    19      * Setup test.
    20      */
    21     @RegisterExtension
    22     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    23     public JOSMTestRules test = new JOSMTestRules().devAPI();
    24 
    25     /**
    2616     * Unit test of {@link JosmUrls#getBaseUserUrl}.
    2717     */
    2818    @Test
  • test/unit/org/openstreetmap/josm/data/projection/ProjectionRefTest.java

     
    3131import java.util.regex.Matcher;
    3232import java.util.regex.Pattern;
    3333
    34 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3534import org.junit.Assert;
    36 import org.junit.jupiter.api.extension.RegisterExtension;
    3735import org.junit.jupiter.api.Test;
     36import org.junit.jupiter.api.Timeout;
    3837import org.openstreetmap.josm.data.Bounds;
    3938import org.openstreetmap.josm.data.coor.EastNorth;
    4039import org.openstreetmap.josm.data.coor.LatLon;
    4140import org.openstreetmap.josm.gui.preferences.projection.CodeProjectionChoice;
    42 import org.openstreetmap.josm.testutils.JOSMTestRules;
     41import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     42import org.openstreetmap.josm.testutils.annotations.HTTP;
     43import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids;
    4344import org.openstreetmap.josm.tools.Pair;
    4445import org.openstreetmap.josm.tools.PlatformManager;
    4546
     47import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     48
    4649/**
    4750 * Test projections using reference data from external program.
    4851 *
     
    5861 * This means the test does not verify our definitions, but the correctness
    5962 * of the algorithm, given a certain definition.
    6063 */
     64@Timeout(90)
     65@ProjectionNadGrids
     66@BasicPreferences
     67@HTTP
    6168class ProjectionRefTest {
    6269
    6370    private static final String CS2CS_EXE = "cs2cs";
     
    8390    static List<String> forcedCodes;
    8491
    8592    /**
    86      * Setup test.
    87      */
    88     @RegisterExtension
    89     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    90     public JOSMTestRules test = new JOSMTestRules().projectionNadGrids().timeout(90_000);
    91 
    92     /**
    9393     * Program entry point.
    9494     * @param args optional comma-separated list of projections to update. If set, only these projections will be updated
    9595     * @throws IOException in case of I/O error
  • test/unit/org/openstreetmap/josm/data/projection/proj/LonLatTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertFalse;
    55
    6 import org.junit.jupiter.api.extension.RegisterExtension;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.testutils.JOSMTestRules;
    97
    10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    11 
    128/**
    139 * Tests for {@link LonLat}.
    1410 */
    1511class LonLatTest {
    1612    /**
    17      * Setup rule.
    18      */
    19     @RegisterExtension
    20     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    21     public JOSMTestRules test = new JOSMTestRules();
    22 
    23     /**
    2413     * Test {@link LonLat#lonIsLinearToEast}
    2514     */
    2615    @Test
  • test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java

     
    4646import java.util.regex.Matcher;
    4747import java.util.regex.Pattern;
    4848
    49 import org.junit.jupiter.api.extension.RegisterExtension;
    5049import org.junit.jupiter.api.Test;
    51 import org.openstreetmap.josm.testutils.JOSMTestRules;
     50import org.openstreetmap.josm.testutils.annotations.HTTPS;
    5251import org.openstreetmap.josm.tools.Logging;
    5352
    5453import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     
    5857 *
    5958 * @version $Revision: 1723861 $
    6059 */
     60@HTTPS
    6161class DomainValidatorTestIT {
    62 
    6362    /**
    64      * Setup rule
    65      */
    66     @RegisterExtension
    67     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    68     public JOSMTestRules test = new JOSMTestRules().https();
    69 
    70     /**
    7163     * Download and process local copy of http://data.iana.org/TLD/tlds-alpha-by-domain.txt
    7264     * Check if the internal TLD table is up to date
    7365     * Check if the internal TLD tables have any spurious entries
  • test/unit/org/openstreetmap/josm/data/validation/tests/MapCSSTagCheckerTest.java

     
    1717
    1818import org.junit.jupiter.api.BeforeEach;
    1919import org.junit.jupiter.api.Test;
    20 import org.junit.jupiter.api.extension.RegisterExtension;
    2120import org.openstreetmap.josm.TestUtils;
    2221import org.openstreetmap.josm.command.ChangePropertyCommand;
    2322import org.openstreetmap.josm.command.ChangePropertyKeyCommand;
     
    4241import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    4342import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    4443import org.openstreetmap.josm.io.OsmReader;
    45 import org.openstreetmap.josm.testutils.JOSMTestRules;
     44import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     45import org.openstreetmap.josm.testutils.annotations.Territories;
    4646import org.openstreetmap.josm.tools.Logging;
    4747
    48 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    49 
    5048/**
    5149 * JUnit Test of {@link MapCSSTagChecker}.
    5250 */
     51@BasicPreferences
     52@Territories
    5353class MapCSSTagCheckerTest {
    54 
    5554    /**
    5655     * Setup test.
    5756     */
    58     @RegisterExtension
    59     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    60     public JOSMTestRules test = new JOSMTestRules().projection().territories().preferences();
    61 
    62     /**
    63      * Setup test.
    64      */
    6557    @BeforeEach
    6658    public void setUp() {
    6759        MapCSSTagCheckerAsserts.clear();
  • test/unit/org/openstreetmap/josm/data/validation/tests/TagCheckerTest.java

     
    1313import org.junit.Assert;
    1414import org.junit.jupiter.api.Disabled;
    1515import org.junit.jupiter.api.Test;
    16 import org.junit.jupiter.api.extension.RegisterExtension;
    1716import org.openstreetmap.josm.TestUtils;
    1817import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1918import org.openstreetmap.josm.data.osm.OsmUtils;
     
    2019import org.openstreetmap.josm.data.osm.Tag;
    2120import org.openstreetmap.josm.data.validation.Severity;
    2221import org.openstreetmap.josm.data.validation.TestError;
    23 import org.openstreetmap.josm.testutils.JOSMTestRules;
     22import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     23import org.openstreetmap.josm.testutils.annotations.Presets;
    2424
    25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    26 
    2725/**
    2826 * JUnit Test of {@link TagChecker}.
    2927 */
     28@BasicPreferences
     29@Presets
    3030class TagCheckerTest {
    31 
    32     /**
    33      * Setup test.
    34      */
    35     @RegisterExtension
    36     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    37     public JOSMTestRules rule = new JOSMTestRules().presets();
    38 
    3931    List<TestError> test(OsmPrimitive primitive) throws IOException {
    4032        final TagChecker checker = new TagChecker() {
    4133            @Override
  • test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui;
    33
     4import static org.junit.Assume.assumeFalse;
    45import static org.junit.jupiter.api.Assertions.assertEquals;
    56import static org.junit.jupiter.api.Assertions.assertFalse;
    67import static org.junit.jupiter.api.Assertions.assertNotNull;
    78import static org.junit.jupiter.api.Assertions.assertNull;
    89import static org.junit.jupiter.api.Assertions.assertTrue;
    9 import static org.junit.Assume.assumeFalse;
    1010
    1111import java.awt.BorderLayout;
    1212import java.awt.event.KeyEvent;
     
    2727import javax.swing.UIManager;
    2828
    2929import org.junit.jupiter.api.Test;
    30 import org.junit.jupiter.api.extension.RegisterExtension;
     30import org.junit.jupiter.api.Timeout;
    3131import org.openstreetmap.josm.TestUtils;
    3232import org.openstreetmap.josm.actions.JosmAction;
    3333import org.openstreetmap.josm.actions.OpenLocationAction;
     
    4242import org.openstreetmap.josm.plugins.PluginListParseException;
    4343import org.openstreetmap.josm.plugins.PluginListParser;
    4444import org.openstreetmap.josm.spi.preferences.Config;
    45 import org.openstreetmap.josm.testutils.JOSMTestRules;
     45import org.openstreetmap.josm.testutils.annotations.HTTPS;
     46import org.openstreetmap.josm.testutils.annotations.Main;
     47import org.openstreetmap.josm.testutils.annotations.OsmApiType;
     48import org.openstreetmap.josm.testutils.annotations.Projection;
    4649import org.openstreetmap.josm.tools.Logging;
    4750import org.openstreetmap.josm.tools.PlatformManager;
    4851import org.openstreetmap.josm.tools.Shortcut;
     
    5255/**
    5356 * Unit tests of {@link MainApplication} class.
    5457 */
     58@Main
     59@Projection
     60@HTTPS
     61@OsmApiType(apiType = OsmApiType.APIType.DEV)
     62@Timeout(20)
    5563public class MainApplicationTest {
    56 
    5764    /**
    58      * Setup test.
    59      */
    60     @RegisterExtension
    61     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    62     public JOSMTestRules test = new JOSMTestRules().main().projection().https().devAPI().timeout(20000);
    63 
    64     /**
    6565     * Make sure {@link MainApplication#contentPanePrivate} is initialized.
    6666     */
    6767    public static void initContentPane() {
  • test/unit/org/openstreetmap/josm/gui/bbox/SizeButtonTest.java

     
    55import static org.junit.jupiter.api.Assertions.assertFalse;
    66import static org.junit.jupiter.api.Assertions.assertTrue;
    77
    8 import org.junit.jupiter.api.extension.RegisterExtension;
    98import org.junit.jupiter.api.Test;
    109import org.openstreetmap.josm.TestUtils;
    1110import org.openstreetmap.josm.gui.bbox.SizeButton.AccessibleSizeButton;
    12 import org.openstreetmap.josm.testutils.JOSMTestRules;
     11import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1312
    14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    15 
    1613/**
    1714 * Unit tests of {@link SizeButton} class.
    1815 */
     16@BasicPreferences
    1917class SizeButtonTest {
    2018
    21     /**
    22      * Setup tests
    23      */
    24     @RegisterExtension
    25     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    26     public JOSMTestRules test = new JOSMTestRules().preferences();
    2719
    2820    /**
    2921     * Unit test of {@link SizeButton#SizeButton}.
  • test/unit/org/openstreetmap/josm/gui/conflict/pair/nodes/NodeListMergeModelTest.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.conflict.pair.nodes;
    33
    4 import static org.junit.jupiter.api.Assertions.fail;
    54import static org.junit.jupiter.api.Assertions.assertEquals;
    65import static org.junit.jupiter.api.Assertions.assertFalse;
    76import static org.junit.jupiter.api.Assertions.assertTrue;
     7import static org.junit.jupiter.api.Assertions.fail;
    88
    99import java.beans.PropertyChangeEvent;
    1010import java.beans.PropertyChangeListener;
     
    1919import javax.swing.DefaultListSelectionModel;
    2020
    2121import org.junit.jupiter.api.Test;
    22 import org.junit.jupiter.api.extension.RegisterExtension;
    2322import org.openstreetmap.josm.TestUtils;
    2423import org.openstreetmap.josm.data.osm.Node;
    2524import org.openstreetmap.josm.data.osm.Way;
    2625import org.openstreetmap.josm.gui.conflict.pair.AbstractListMergeModel;
    2726import org.openstreetmap.josm.testutils.DatasetFactory;
    28 import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2928import org.openstreetmap.josm.tools.Logging;
    3029
    31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    32 
    3330/**
    3431 * Unit tests of {@link NodeListMergeModel}.
    3532 */
     33@BasicPreferences
    3634class NodeListMergeModelTest {
    3735
    3836    private final DatasetFactory my = new DatasetFactory();
    3937    private final DatasetFactory their = new DatasetFactory();
    4038
    41     /**
    42      * Setup test.
    43      */
    44     @RegisterExtension
    45     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    46     public JOSMTestRules test = new JOSMTestRules();
    47 
    4839    @SuppressWarnings("unchecked")
    4940    protected List<Node> inspectNodeList(NodeListMergeModel model, String name) {
    5041        try {
  • test/unit/org/openstreetmap/josm/gui/datatransfer/ClipboardUtilsTest.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.datatransfer;
    33
     4import static org.junit.Assume.assumeTrue;
    45import static org.junit.jupiter.api.Assertions.assertEquals;
    56import static org.junit.jupiter.api.Assertions.assertNotNull;
    67import static org.junit.jupiter.api.Assertions.assertNull;
    78import static org.junit.jupiter.api.Assertions.assertSame;
    89import static org.junit.jupiter.api.Assertions.assertTrue;
    9 import static org.junit.Assume.assumeTrue;
    1010
    1111import java.awt.GraphicsEnvironment;
    1212import java.awt.datatransfer.Clipboard;
     
    1616import java.awt.datatransfer.UnsupportedFlavorException;
    1717import java.io.IOException;
    1818
    19 import org.junit.jupiter.api.extension.RegisterExtension;
    2019import org.junit.jupiter.api.Test;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
    2220
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2421import net.trajano.commons.testing.UtilityClassTestUtil;
    2522
    2623/**
     
    6764    }
    6865
    6966    /**
    70      * No dependencies
    71      */
    72     @RegisterExtension
    73     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    74     public JOSMTestRules test = new JOSMTestRules();
    75 
    76     /**
    7767     * Test {@link ClipboardUtils#getClipboard()}
    7868     */
    7969    @Test
  • test/unit/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandlerTest.java

     
    66
    77import java.util.Collections;
    88
    9 import org.junit.jupiter.api.extension.RegisterExtension;
    109import org.junit.jupiter.api.Test;
    1110import org.openstreetmap.josm.actions.CopyAction;
    1211import org.openstreetmap.josm.data.coor.LatLon;
     
    1514import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    1615import org.openstreetmap.josm.gui.MainApplication;
    1716import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     18import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
     19import org.openstreetmap.josm.testutils.annotations.Main;
     20import org.openstreetmap.josm.testutils.annotations.Projection;
    1921
    20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    21 
    2222/**
    2323 * Unit tests of {@link OsmTransferHandler} class.
    2424 */
     25@FullPreferences
     26@Projection
     27@Main
     28@LayerEnvironment
    2529class OsmTransferHandlerTest {
    26     /**
    27      * Prefs to use OSM primitives
    28      */
    29     @RegisterExtension
    30     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    31     public JOSMTestRules test = new JOSMTestRules().preferences().projection().main();
    32 
    3330    private final OsmTransferHandler transferHandler = new OsmTransferHandler();
    3431
    3532    /**
  • test/unit/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferableTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    7 import static org.junit.jupiter.api.Assertions.assertThrows;
    88
    99import java.awt.datatransfer.DataFlavor;
    1010import java.awt.datatransfer.UnsupportedFlavorException;
     
    1414import java.util.List;
    1515
    1616import org.junit.jupiter.api.Test;
    17 import org.junit.jupiter.api.extension.RegisterExtension;
    1817import org.openstreetmap.josm.data.osm.Node;
    1918import org.openstreetmap.josm.data.osm.NodeData;
    2019import org.openstreetmap.josm.data.osm.PrimitiveData;
    2120import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData;
    2221import org.openstreetmap.josm.gui.datatransfer.data.TagTransferData;
    23 import org.openstreetmap.josm.testutils.JOSMTestRules;
     22import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2423
    25 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    26 
    2724/**
    2825 * Unit tests of {@link PrimitiveTransferable} class.
    2926 */
     27@BasicPreferences
    3028class PrimitiveTransferableTest {
    3129    /**
    32      * Prefs to use OSM primitives
    33      */
    34     @RegisterExtension
    35     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules().preferences();
    37 
    38     /**
    3930     * Test of {@link PrimitiveTransferable#getTransferDataFlavors()} method response order
    4031     */
    4132    @Test
  • test/unit/org/openstreetmap/josm/gui/datatransfer/RelationMemberTransferableTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    7 import static org.junit.jupiter.api.Assertions.assertThrows;
    88import static org.openstreetmap.josm.gui.datatransfer.RelationMemberTransferable.RELATION_MEMBER_DATA;
    99
    1010import java.awt.datatransfer.DataFlavor;
     
    1313import java.util.Collections;
    1414
    1515import org.junit.jupiter.api.Test;
    16 import org.junit.jupiter.api.extension.RegisterExtension;
    1716import org.openstreetmap.josm.data.osm.Node;
    1817import org.openstreetmap.josm.data.osm.PrimitiveData;
    1918import org.openstreetmap.josm.data.osm.RelationMember;
    2019import org.openstreetmap.josm.data.osm.RelationMemberData;
    2120import org.openstreetmap.josm.gui.datatransfer.data.PrimitiveTransferData;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
     21import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2322
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    25 
    2623/**
    2724 * Unit tests of {@link RelationMemberTransferable} class.
    2825 */
     26@BasicPreferences
    2927class RelationMemberTransferableTest {
    30 
    3128    /**
    32      * Setup tests
    33      */
    34     @RegisterExtension
    35     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules();
    37 
    38     /**
    3929     * Test of {@link RelationMemberTransferable#getTransferDataFlavors()} method.
    4030     */
    4131    @Test
  • test/unit/org/openstreetmap/josm/gui/datatransfer/TagTransferableTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    7 import static org.junit.jupiter.api.Assertions.assertThrows;
    88
    99import java.awt.datatransfer.DataFlavor;
    1010import java.awt.datatransfer.UnsupportedFlavorException;
     
    1212import java.util.Map;
    1313
    1414import org.junit.jupiter.api.Test;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.openstreetmap.josm.gui.datatransfer.data.TagTransferData;
    17 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1816
    19 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    20 
    2117/**
    2218 * Unit tests of {@link TagTransferable} class.
    2319 */
    2420class TagTransferableTest {
    25 
    2621    /**
    27      * Setup tests
    28      */
    29     @RegisterExtension
    30     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    31     public JOSMTestRules test = new JOSMTestRules();
    32 
    33     /**
    3422     * Test of {@link TagTransferable#isDataFlavorSupported} method.
    3523     */
    3624    @Test
  • test/unit/org/openstreetmap/josm/gui/dialogs/CommandStackDialogTest.java

     
    44import static org.junit.jupiter.api.Assertions.assertFalse;
    55import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    87import org.junit.jupiter.api.Test;
    98import org.openstreetmap.josm.TestUtils;
    109import org.openstreetmap.josm.command.Command;
     
    1312import org.openstreetmap.josm.gui.MainApplication;
    1413import org.openstreetmap.josm.gui.MapFrame;
    1514import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     16import org.openstreetmap.josm.testutils.annotations.Main;
     17import org.openstreetmap.josm.testutils.annotations.Projection;
    1718
    18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    19 
    2019/**
    2120 * Unit tests of {@link CommandStackDialog} class.
    2221 */
     22@FullPreferences
     23@Projection
     24@Main
    2325class CommandStackDialogTest {
    24 
    2526    /**
    26      * Setup tests
    27      */
    28     @RegisterExtension
    29     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().main().projection().preferences();
    31 
    32     /**
    3327     * Unit test of {@link CommandStackDialog} class - empty case.
    3428     */
    3529    @Test
  • test/unit/org/openstreetmap/josm/gui/dialogs/ConflictDialogTest.java

     
    77import java.awt.Color;
    88import java.awt.image.BufferedImage;
    99
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.junit.jupiter.api.Test;
    1211import org.openstreetmap.josm.data.coor.LatLon;
    1312import org.openstreetmap.josm.data.osm.DataSet;
     
    1817import org.openstreetmap.josm.gui.MainApplication;
    1918import org.openstreetmap.josm.gui.dialogs.ConflictDialog.ConflictPainter;
    2019import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.Main;
     21import org.openstreetmap.josm.testutils.annotations.Projection;
    2222
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    24 
    2523/**
    2624 * Unit tests of {@link ConflictDialog} class.
    2725 */
     26@Main
     27@Projection
    2828class ConflictDialogTest {
    29 
    3029    /**
    31      * Setup tests
    32      */
    33     @RegisterExtension
    34     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().main().projection();
    36 
    37     /**
    3830     * Unit test of {@link ConflictDialog#ConflictDialog}.
    3931     */
    4032    @Test
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/actions/AbstractRelationEditorActionTest.java

     
    77
    88import org.junit.jupiter.api.BeforeEach;
    99import org.junit.jupiter.api.Disabled;
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.openstreetmap.josm.data.osm.DataSet;
    1211import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1312import org.openstreetmap.josm.data.osm.Relation;
     
    2221import org.openstreetmap.josm.gui.tagging.TagEditorModel;
    2322import org.openstreetmap.josm.gui.tagging.ac.AutoCompletingTextField;
    2423import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetHandler;
    25 import org.openstreetmap.josm.testutils.JOSMTestRules;
     24import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     25import org.openstreetmap.josm.testutils.annotations.Main;
    2626
    27 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    28 
    2927/**
    3028 * This class provides the basic test environment for relation editor actions.
    3129 * @author Michael Zangl
    3230 */
    3331@Disabled
     32@FullPreferences
     33@Main
    3434public abstract class AbstractRelationEditorActionTest {
    35     /**
    36      * Platform for tooltips.
    37      */
    38     @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().preferences().main();
    41 
    4235    protected OsmDataLayer layer;
    4336
    4437    private SelectionTableModel selectionTableModel;
  • test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java

     
    1010import org.junit.Assert;
    1111import org.junit.jupiter.api.BeforeEach;
    1212import org.junit.jupiter.api.Test;
    13 import org.junit.jupiter.api.extension.RegisterExtension;
    1413import org.openstreetmap.josm.data.osm.DataSet;
    1514import org.openstreetmap.josm.data.osm.Relation;
    1615import org.openstreetmap.josm.data.osm.RelationMember;
     
    1716import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1817import org.openstreetmap.josm.io.IllegalDataException;
    1918import org.openstreetmap.josm.io.OsmReader;
    20 import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     20import org.openstreetmap.josm.testutils.annotations.Projection;
    2121
    22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    23 
    2422/**
    2523 * Unit tests of {@link RelationSorter} class.
    2624 */
     25@FullPreferences
     26@Projection // defaults to Mercator projection
    2727class RelationSorterTest {
    2828
    2929    private final RelationSorter sorter = new RelationSorter();
     
    3030    private DataSet testDataset;
    3131
    3232    /**
    33      * Use Mercator projection
    34      */
    35     @RegisterExtension
    36     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    37     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
    38 
    39     /**
    4033     * Load the test data set
    4134     * @throws IllegalDataException if an error was found while parsing the data
    4235     * @throws IOException in case of I/O error
  • test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java

     
    99import javax.swing.JOptionPane;
    1010
    1111import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    1312import org.openstreetmap.josm.TestUtils;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     14import org.openstreetmap.josm.testutils.annotations.HTTPS;
    1515import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    1616import org.openstreetmap.josm.tools.LanguageInfo.LocaleType;
    1717import org.openstreetmap.josm.tools.PlatformHook;
    1818import org.openstreetmap.josm.tools.PlatformManager;
    1919
    20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2120import mockit.Expectations;
    2221import mockit.Injectable;
    2322import mockit.Mocked;
     
    2524/**
    2625 * Unit tests of {@link HelpBrowser} class.
    2726 */
     27@FullPreferences
     28@HTTPS
    2829class HelpBrowserTest {
    2930
    3031    static final String URL_1 = "https://josm.openstreetmap.de/wiki/Help";
     
    3132    static final String URL_2 = "https://josm.openstreetmap.de/wiki/Introduction";
    3233    static final String URL_3 = "https://josm.openstreetmap.de/javadoc";
    3334
    34     /**
    35      * Setup tests
    36      */
    37     @RegisterExtension
    38     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    39     static JOSMTestRules test = new JOSMTestRules().preferences().https();
    40 
    4135    static IHelpBrowser newHelpBrowser() {
    4236        return new IHelpBrowser() {
    4337
  • test/unit/org/openstreetmap/josm/gui/help/HyperlinkHandlerTest.java

     
    1010import javax.swing.text.html.HTMLDocument;
    1111import javax.swing.text.html.HTMLEditorKit;
    1212
    13 import org.junit.jupiter.api.extension.RegisterExtension;
    1413import org.junit.jupiter.api.Test;
    1514import org.openstreetmap.josm.gui.widgets.JosmEditorPane;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1716
    18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    19 
    2017/**
    2118 * Unit tests of {@link HyperlinkHandler} class.
    2219 */
     20@BasicPreferences // Needed for OsmPrimitive
    2321class HyperlinkHandlerTest {
    24 
    2522    /**
    26      * Setup tests
    27      */
    28     @RegisterExtension
    29     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().preferences();
    31 
    32     /**
    3323     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/17338">#17338</a>.
    3424     * @throws Exception if an error occurs
    3525     */
  • test/unit/org/openstreetmap/josm/gui/history/HistoryBrowserModelTest.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.history;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    45import static org.junit.jupiter.api.Assertions.assertEquals;
    56import static org.junit.jupiter.api.Assertions.assertNotEquals;
    67import static org.junit.jupiter.api.Assertions.assertNotNull;
     
    78import static org.junit.jupiter.api.Assertions.assertNull;
    89import static org.junit.jupiter.api.Assertions.assertTrue;
    910
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1111import org.junit.jupiter.api.Test;
     12import org.junit.jupiter.api.Timeout;
    1213import org.openstreetmap.josm.data.osm.Node;
    1314import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1415import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
     
    1617import org.openstreetmap.josm.data.osm.history.History;
    1718import org.openstreetmap.josm.data.osm.history.HistoryDataSet;
    1819import org.openstreetmap.josm.data.osm.history.HistoryNode;
    19 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     21import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    2022
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    22 
    2323/**
    2424 * Unit tests of {@link HistoryBrowserModel} class.
    2525 */
     26@FullPreferences
     27@OsmApiType(apiType = OsmApiType.APIType.DEV)
     28@Timeout(30)
    2629class HistoryBrowserModelTest {
    27 
    2830    /**
    29      * Setup test.
    30      */
    31     @RegisterExtension
    32     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    33     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(30000);
    34 
    35     /**
    3631     * Test for {@link HistoryBrowserModel#HistoryBrowserModel}.
    3732     */
    3833    @Test
     
    9893    void testSetPointsInTimeNullHistory() {
    9994        HistoryBrowserModel model = new HistoryBrowserModel();
    10095        VersionTableModel tableModel = model.getVersionTableModel();
    101         tableModel.setValueAt(false, 0, 0); // code coverage
    102         tableModel.setValueAt(true, 0, 1);  // reference point
    103         tableModel.setValueAt(true, 1, 2);  // current point
    104         tableModel.setValueAt(true, 3, 3);  // code coverage
     96        assertDoesNotThrow(() -> tableModel.setValueAt(false, 0, 0)); // code coverage
     97        assertDoesNotThrow(() -> tableModel.setValueAt(true, 0, 1));  // reference point
     98        assertDoesNotThrow(() -> tableModel.setValueAt(true, 1, 2));  // current point
     99        assertDoesNotThrow(() -> tableModel.setValueAt(true, 3, 3));  // code coverage
    105100    }
    106101
    107102    /**
  • test/unit/org/openstreetmap/josm/gui/history/HistoryLoadTaskTest.java

     
    66import java.io.IOException;
    77import java.io.InputStream;
    88
    9 import org.junit.jupiter.api.extension.RegisterExtension;
    109import org.junit.jupiter.api.Test;
     10import org.junit.jupiter.api.Timeout;
    1111import org.openstreetmap.josm.TestUtils;
    1212import org.openstreetmap.josm.data.osm.Node;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
     
    2121import org.openstreetmap.josm.io.OsmHistoryReader;
    2222import org.openstreetmap.josm.io.OsmServerHistoryReader;
    2323import org.openstreetmap.josm.io.OsmTransferException;
    24 import org.openstreetmap.josm.testutils.JOSMTestRules;
     24import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     25import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    2526import org.xml.sax.SAXException;
    2627
    27 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    28 
    2928/**
    3029 * Unit tests of {@link HistoryLoadTask} class.
    3130 */
     31@FullPreferences
     32@OsmApiType(apiType = OsmApiType.APIType.DEV)
     33@Timeout(20)
    3234class HistoryLoadTaskTest {
    33 
    3435    /**
    35      * Setup test.
    36      */
    37     @RegisterExtension
    38     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    39     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000);
    40 
    41     /**
    4236     * Unit test of {@link HistoryLoadTask#getLoadingMessage}
    4337     */
    4438    @Test
  • test/unit/org/openstreetmap/josm/gui/io/DownloadOpenChangesetsTaskTest.java

     
    1313import javax.swing.JOptionPane;
    1414import javax.swing.JPanel;
    1515
    16 import org.junit.jupiter.api.extension.RegisterExtension;
    1716import org.junit.jupiter.api.Test;
    1817import org.openstreetmap.josm.TestUtils;
    1918import org.openstreetmap.josm.data.UserIdentityManager;
    2019import org.openstreetmap.josm.gui.oauth.OAuthAuthorizationWizard;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     21import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    2222import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    2323import org.openstreetmap.josm.testutils.mockers.WindowMocker;
    2424import org.openstreetmap.josm.tools.UserCancelException;
    2525
    26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2726import mockit.Invocation;
    2827import mockit.Mock;
    2928import mockit.MockUp;
     
    3130/**
    3231 * Unit tests of {@link DownloadOpenChangesetsTask} class.
    3332 */
     33@FullPreferences
     34@OsmApiType(apiType = OsmApiType.APIType.DEV)
    3435class DownloadOpenChangesetsTaskTest {
    35 
    3636    /**
    37      * Setup tests
    38      */
    39     @RegisterExtension
    40     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    41     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI();
    42 
    43     /**
    4437     * OAuth wizard mocker.
    4538     */
    4639    public static class OAuthWizardMocker extends MockUp<OAuthAuthorizationWizard> {
  • test/unit/org/openstreetmap/josm/gui/io/DownloadPrimitivesTaskTest.java

     
    77
    88import java.util.Arrays;
    99
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.junit.jupiter.api.Test;
     11import org.junit.jupiter.api.Timeout;
    1212import org.openstreetmap.josm.data.osm.DataSet;
    1313import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    1414import org.openstreetmap.josm.data.osm.SimplePrimitiveId;
    1515import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     16import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     17import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    1718
    18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    19 
    2019/**
    2120 * Unit tests of {@link DownloadPrimitivesTask} class.
    2221 */
     22@FullPreferences
     23@OsmApiType(apiType = OsmApiType.APIType.DEV)
     24@Timeout(20)
    2325class DownloadPrimitivesTaskTest {
    24 
    2526    /**
    26      * Setup tests
    27      */
    28     @RegisterExtension
    29     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().preferences().devAPI().timeout(20000);
    31 
    32     /**
    3327     * Test of {@link DownloadPrimitivesTask} class.
    3428     */
    3529    @Test
  • test/unit/org/openstreetmap/josm/gui/layer/LayerTest.java

     
    1111
    1212import org.junit.jupiter.api.BeforeEach;
    1313import org.junit.jupiter.api.Test;
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    1514import org.openstreetmap.josm.data.projection.ProjectionRegistry;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     15import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     16import org.openstreetmap.josm.testutils.annotations.LayerEnvironment;
     17import org.openstreetmap.josm.testutils.annotations.Projection;
    1718
    18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    19 
    2019/**
    2120 * Test of the base {@link Layer} class
    2221 * @author Michael Zangl
    2322 */
     23@BasicPreferences
     24@Projection
     25@LayerEnvironment
    2426class LayerTest {
    25     /**
    26      * We need projection
    27      */
    28     @RegisterExtension
    29     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
    31 
    3227    private Layer testLayer;
    3328
    3429    /**
  • test/unit/org/openstreetmap/josm/gui/layer/OsmDataLayerTest.java

     
    1616
    1717import org.junit.jupiter.api.BeforeEach;
    1818import org.junit.jupiter.api.Test;
    19 import org.junit.jupiter.api.extension.RegisterExtension;
    2019import org.openstreetmap.josm.TestUtils;
    2120import org.openstreetmap.josm.actions.ExpertToggleAction;
    2221import org.openstreetmap.josm.data.Bounds;
     
    3534import org.openstreetmap.josm.gui.datatransfer.ClipboardUtils;
    3635import org.openstreetmap.josm.io.IllegalDataException;
    3736import org.openstreetmap.josm.io.OsmReader;
    38 import org.openstreetmap.josm.testutils.JOSMTestRules;
     37import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     38import org.openstreetmap.josm.testutils.annotations.Main;
     39import org.openstreetmap.josm.testutils.annotations.Projection;
    3940import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker;
    4041import org.openstreetmap.josm.tools.Logging;
    4142import org.openstreetmap.josm.tools.date.DateUtils;
    4243
    43 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    44 
    4544/**
    4645 * Unit tests of {@link OsmDataLayer} class.
    4746 */
     47@Projection
     48@Main
     49@BasicPreferences // for primitives
    4850class OsmDataLayerTest {
    49 
    50     /**
    51      * Setup tests
    52      */
    53     @RegisterExtension
    54     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    55     public JOSMTestRules test = new JOSMTestRules().projection().main();
    56 
    5751    private DataSet ds;
    5852    private OsmDataLayer layer;
    5953
  • test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ChildOrParentSelectorTest.java

     
    1212import org.junit.jupiter.api.BeforeEach;
    1313import org.junit.jupiter.api.Disabled;
    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.DataSet;
    1817import org.openstreetmap.josm.data.osm.Node;
     
    2423import org.openstreetmap.josm.gui.mappaint.MultiCascade;
    2524import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector;
    2625import org.openstreetmap.josm.io.OsmReader;
    27 import org.openstreetmap.josm.testutils.JOSMTestRules;
     26import org.openstreetmap.josm.testutils.annotations.Projection;
    2827
    29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    30 
    3128/**
    3229 * Unit tests of {@link ChildOrParentSelector}.
    3330 */
     31@Projection
    3432class ChildOrParentSelectorTest {
    3533
    3634    private DataSet ds;
    3735
    3836    /**
    39      * Setup rule
    40      */
    41     @RegisterExtension
    42     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    43     public JOSMTestRules test = new JOSMTestRules().projection();
    44 
    45     /**
    4637     * Setup test
    4738     */
    4839    @BeforeEach
  • test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionTest.java

     
    77
    88import org.junit.jupiter.api.BeforeEach;
    99import org.junit.jupiter.api.Test;
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1211import org.openstreetmap.josm.data.osm.OsmUtils;
    1312import org.openstreetmap.josm.gui.mappaint.Environment;
     
    1514import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.ToTagConvertable;
    1615import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op;
    1716import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.SimpleKeyValueCondition;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.FullPreferences;
    1918
    20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    21 
    2219/**
    2320 * This test universally tests all {@link Condition}s.
    2421 * @author Michael Zangl
    2522 */
     23@FullPreferences // Nodes require preferences
    2624class ConditionTest {
    27     /**
    28      * We need prefs for nodes.
    29      */
    30     @RegisterExtension
    31     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    32     public JOSMTestRules test = new JOSMTestRules().preferences();
    3325    private OsmPrimitive node0;
    3426    private OsmPrimitive node1;
    3527    private OsmPrimitive node2;
  • test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTest.java

     
    1616
    1717import org.junit.Assert;
    1818import org.junit.jupiter.api.Test;
    19 import org.junit.jupiter.api.extension.RegisterExtension;
    2019import org.openstreetmap.josm.TestUtils;
    2120import org.openstreetmap.josm.data.coor.LatLon;
    2221import org.openstreetmap.josm.data.osm.DataSet;
     
    3837import org.openstreetmap.josm.gui.mappaint.mapcss.Selector.ChildOrParentSelector;
    3938import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser;
    4039import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    41 import org.openstreetmap.josm.testutils.JOSMTestRules;
     40import org.openstreetmap.josm.testutils.annotations.Projection;
    4241import org.openstreetmap.josm.tools.ColorHelper;
    4342
    44 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    45 
    4643/**
    4744 * Unit tests of {@link MapCSSParser}.
    4845 */
     46@Projection
    4947class MapCSSParserTest {
    5048
    5149    protected static Environment getEnvironment(String key, String value) {
     
    5654        return new MapCSSParser(new StringReader(stringToParse));
    5755    }
    5856
    59     /**
    60      * Setup rule
    61      */
    62     @RegisterExtension
    63     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    64     public JOSMTestRules test = new JOSMTestRules().projection();
    65 
    6657    @Test
    6758    void testDeclarations() throws Exception {
    6859        getParser("{ opacity: 0.5; color: rgb(1.0, 0.0, 0.0); }").declaration();
  • test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

     
    2525import org.apache.commons.jcs3.access.CacheAccess;
    2626import org.junit.jupiter.api.AfterAll;
    2727import org.junit.jupiter.api.BeforeAll;
    28 import org.junit.jupiter.api.extension.RegisterExtension;
     28import org.junit.jupiter.api.Timeout;
    2929import org.junit.jupiter.params.ParameterizedTest;
    3030import org.junit.jupiter.params.provider.Arguments;
    3131import org.junit.jupiter.params.provider.MethodSource;
     
    5959import org.openstreetmap.josm.data.projection.Projections;
    6060import org.openstreetmap.josm.io.imagery.ApiKeyProvider;
    6161import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException;
    62 import org.openstreetmap.josm.testutils.JOSMTestRules;
     62import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     63import org.openstreetmap.josm.testutils.annotations.HTTP;
     64import org.openstreetmap.josm.testutils.annotations.HTTPS;
     65import org.openstreetmap.josm.testutils.annotations.I18n;
     66import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
     67import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids;
     68import org.openstreetmap.josm.testutils.annotations.SlowTest;
    6369import org.openstreetmap.josm.tools.HttpClient;
    6470import org.openstreetmap.josm.tools.HttpClient.Response;
    6571import org.openstreetmap.josm.tools.Logging;
    6672import org.openstreetmap.josm.tools.Utils;
    6773
    68 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    69 
    7074/**
    7175 * Integration tests of {@link ImageryPreference} class.
    7276 */
     77@HTTP
     78@HTTPS
     79@I18n
     80@FullPreferences
     81@org.openstreetmap.josm.testutils.annotations.Projection
     82@ProjectionNadGrids
     83@Timeout(value = 40, unit = TimeUnit.MINUTES)
     84@IntegrationTest
     85@SlowTest
    7386public class ImageryPreferenceTestIT {
    7487
    7588    private static final String ERROR_SEP = " -> ";
     
    7689    private static final LatLon GREENWICH = new LatLon(51.47810, -0.00170);
    7790    private static final int DEFAULT_ZOOM = 12;
    7891
    79     /**
    80      * Setup rule
    81      */
    82     @RegisterExtension
    83     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    84     static JOSMTestRules test = new JOSMTestRules().https().i18n().preferences().projection().projectionNadGrids()
    85                                                    .timeout((int) TimeUnit.MINUTES.toMillis(40));
    86 
    8792    /** Entry to test */
    8893    private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>());
    8994    private final Map<String, Map<ImageryInfo, List<String>>> ignoredErrors = Collections.synchronizedMap(new TreeMap<>());
  • test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java

     
    88import java.io.IOException;
    99import java.util.ArrayList;
    1010import java.util.List;
     11import java.util.concurrent.TimeUnit;
    1112
    1213import org.junit.jupiter.api.BeforeAll;
    13 import org.junit.jupiter.api.extension.RegisterExtension;
     14import org.junit.jupiter.api.Timeout;
    1415import org.junit.jupiter.params.ParameterizedTest;
    1516import org.junit.jupiter.params.provider.MethodSource;
    1617import org.openstreetmap.josm.TestUtils;
     
    2324import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.AssignmentInstruction;
    2425import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule;
    2526import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    26 import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.testutils.annotations.HTTPS;
     28import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
     29import org.openstreetmap.josm.testutils.annotations.SlowTest;
    2730import org.openstreetmap.josm.tools.ImageProvider;
    2831
    29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    30 
    3132/**
    3233 * Integration tests of {@link MapPaintPreference} class.
    3334 */
     35@HTTPS
     36@Timeout(value = 15, unit = TimeUnit.MINUTES)
     37@IntegrationTest
     38@SlowTest
    3439class MapPaintPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    35 
    3640    /**
    37      * Setup rule
    38      */
    39     @RegisterExtension
    40     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    41     public static JOSMTestRules test = new JOSMTestRules().https().timeout(15000*60).parameters();
    42 
    43     /**
    4441     * Setup test
    4542     * @throws IOException in case of I/O error
    4643     */
  • test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java

     
    1414import java.util.List;
    1515import java.util.Locale;
    1616import java.util.Set;
     17import java.util.concurrent.TimeUnit;
    1718
    1819import org.junit.jupiter.api.BeforeAll;
    19 import org.junit.jupiter.api.extension.RegisterExtension;
     20import org.junit.jupiter.api.Timeout;
    2021import org.junit.jupiter.params.ParameterizedTest;
    2122import org.junit.jupiter.params.provider.MethodSource;
    2223import org.openstreetmap.josm.TestUtils;
     
    2627import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetsTest;
    2728import org.openstreetmap.josm.gui.tagging.presets.items.Link;
    2829import org.openstreetmap.josm.spi.preferences.Config;
    29 import org.openstreetmap.josm.testutils.JOSMTestRules;
     30import org.openstreetmap.josm.testutils.annotations.HTTP;
     31import org.openstreetmap.josm.testutils.annotations.HTTPS;
     32import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
     33import org.openstreetmap.josm.testutils.annotations.SlowTest;
    3034import org.openstreetmap.josm.tools.HttpClient;
    3135import org.openstreetmap.josm.tools.HttpClient.Response;
    3236import org.openstreetmap.josm.tools.ImageProvider;
     
    3337import org.openstreetmap.josm.tools.Logging;
    3438import org.xml.sax.SAXException;
    3539
    36 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    37 
    3840/**
    3941 * Integration tests of {@link TaggingPresetPreference} class.
    4042 */
     43@HTTP
     44@HTTPS
     45@Timeout(value = 20, unit = TimeUnit.MINUTES)
     46@IntegrationTest
     47@SlowTest
    4148class TaggingPresetPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    42 
    4349    /**
    44      * Setup rule
    45      */
    46     @RegisterExtension
    47     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    48     public static JOSMTestRules test = new JOSMTestRules().https().timeout(10000*120).parameters();
    49 
    50     /**
    5150     * Setup test
    5251     * @throws IOException in case of I/O error
    5352     */
  • test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java

     
    99import java.util.Collection;
    1010
    1111import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
     12import org.junit.jupiter.api.Timeout;
    1313import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
    1414import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
    1515import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     16import org.openstreetmap.josm.testutils.annotations.HTTP;
     17import org.openstreetmap.josm.testutils.annotations.HTTPS;
     18import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    1719
    18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    19 
    2020/**
    2121 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
    2222 */
     23@HTTP
     24@HTTPS
     25@Timeout(20)
     26@IntegrationTest
    2327class ValidatorTagCheckerRulesPreferenceTestIT {
    24 
    2528    /**
    26      * Setup rule
    27      */
    28     @RegisterExtension
    29     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);
    31 
    32     /**
    3329     * Test that available tag checker rules are valid.
    3430     * @throws Exception in case of error
    3531     */
  • test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java

     
    1414
    1515import org.junit.Assert;
    1616import org.junit.jupiter.api.Test;
    17 import org.junit.jupiter.api.extension.RegisterExtension;
    1817import org.openstreetmap.josm.TestUtils;
    1918import org.openstreetmap.josm.gui.tagging.presets.items.Check;
    2019import org.openstreetmap.josm.gui.tagging.presets.items.Key;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2221import org.xml.sax.SAXException;
    2322
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    25 
    2623/**
    2724 * Unit tests of {@link TaggingPresetReader} class.
    2825 */
     26@BasicPreferences
    2927class TaggingPresetReaderTest {
    30 
    3128    /**
    32      * Setup rule
    33      */
    34     @RegisterExtension
    35     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules();
    37 
    38     /**
    3929     * #8954 - last checkbox in the preset is not added
    4030     * @throws SAXException if any XML error occurs
    4131     * @throws IOException if any I/O error occurs
  • test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java

     
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.io;
    33
    4 import static org.junit.Assume.assumeFalse;
    54
     5import static org.junit.jupiter.api.Assumptions.assumeFalse;
     6
    67import java.io.IOException;
    78import java.net.URL;
    89import java.net.URLConnection;
     
    1112
    1213import javax.net.ssl.SSLHandshakeException;
    1314
    14 import org.junit.Assert;
    15 import org.junit.ClassRule;
     15import org.junit.jupiter.api.Assertions;
    1616import org.junit.jupiter.api.BeforeAll;
    1717import org.junit.jupiter.api.Test;
     18import org.junit.jupiter.api.Timeout;
    1819import org.openstreetmap.josm.TestUtils;
    19 import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     21import org.openstreetmap.josm.testutils.annotations.HTTP;
     22import org.openstreetmap.josm.testutils.annotations.HTTPS;
     23import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
    2024
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    22 
    2325/**
    2426 * Integration tests of {@link CertificateAmendment} class.
    2527 */
     28@IntegrationTest
     29@Timeout(20)
     30@HTTP
     31@HTTPS
     32@BasicPreferences
    2633class CertificateAmendmentTestIT {
    27 
    28     /**
    29      * Setup rule
    30      */
    31     @ClassRule
    32     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    33     public static JOSMTestRules test = new JOSMTestRules().https().preferences().timeout(20000);
    34 
    3534    private static final List<String> errorsToIgnore = new ArrayList<>();
    3635
    3736    /**
     
    110109        String error = "Expected error: " + url;
    111110        assumeFalse(errorsToIgnore.contains(error));
    112111        if (!shouldWork) {
    113             Assert.fail(error);
     112            Assertions.fail(error);
    114113        }
    115114    }
    116115}
  • test/unit/org/openstreetmap/josm/io/DiffResultProcessorTest.java

     
    99import java.util.Collections;
    1010import java.util.Set;
    1111
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    1312import org.junit.jupiter.api.Test;
    1413import org.openstreetmap.josm.data.coor.LatLon;
    1514import org.openstreetmap.josm.data.osm.Changeset;
     
    2120import org.openstreetmap.josm.data.osm.Way;
    2221import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2322import org.openstreetmap.josm.io.DiffResultProcessor.DiffResultEntry;
    24 import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2524import org.openstreetmap.josm.tools.Logging;
    2625import org.openstreetmap.josm.tools.XmlParsingException;
    2726
    28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    29 
    3027/**
    3128 * Unit tests of {@link DiffResultProcessor}
    3229 */
     30@BasicPreferences
    3331class DiffResultProcessorTest {
    34 
    35     /**
    36      * Setup rule
    37      */
    38     @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules();
    41 
    4232    private static void shouldFail(String s) {
    4333        try {
    4434            new DiffResultProcessor(null).parse(s, NullProgressMonitor.INSTANCE);
  • test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java

     
    99import java.net.URL;
    1010import java.util.Map;
    1111
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    1312import org.junit.jupiter.api.Test;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.HTTPS;
     14import org.openstreetmap.josm.testutils.annotations.Main;
     15import org.openstreetmap.josm.testutils.annotations.OsmApiType;
     16import org.openstreetmap.josm.testutils.annotations.Projection;
    1517
    16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    17 
    1818/**
    1919 * Unit tests of {@link NetworkManager} class.
    2020 */
     21@HTTPS
     22@Main
     23@Projection
     24@OsmApiType(apiType = OsmApiType.APIType.DEV)
    2125class NetworkManagerTest {
    22 
    2326    /**
    24      * Setup test.
    25      */
    26     @RegisterExtension
    27     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    28     public JOSMTestRules test = new JOSMTestRules().https().devAPI().main().projection();
    29 
    30     /**
    3127     * Unit test of {@link NetworkManager#addNetworkError},
    3228     *              {@link NetworkManager#getNetworkErrors} and
    3329     *              {@link NetworkManager#clearNetworkErrors}.
  • test/unit/org/openstreetmap/josm/io/OsmReaderTest.java

     
    1717import java.nio.file.Paths;
    1818import java.util.Arrays;
    1919
    20 import org.junit.jupiter.api.extension.RegisterExtension;
    2120import org.junit.jupiter.api.Test;
    2221import org.openstreetmap.josm.TestUtils;
    2322import org.openstreetmap.josm.data.osm.DataSet;
     
    2625import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    2726import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    2827import org.openstreetmap.josm.io.OsmReader.Options;
    29 import org.openstreetmap.josm.testutils.JOSMTestRules;
     28import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    3029
    31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    32 
    3330/**
    3431 * Unit tests of {@link OsmReader} class.
    3532 */
     33@BasicPreferences // For primitives
    3634class OsmReaderTest {
    37 
    38     /**
    39      * Setup rule
    40      */
    41     @RegisterExtension
    42     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    43     public JOSMTestRules test = new JOSMTestRules();
    44 
    4535    private static Options[][] options() {
    4636        return new Options[][]{
    4737                new Options[]{},
  • test/unit/org/openstreetmap/josm/io/auth/CredentialsAgentExceptionTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.jupiter.api.extension.RegisterExtension;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.testutils.JOSMTestRules;
    97
    10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    11 
    128/**
    139 * Unit tests of {@link CredentialsAgentException} class.
    1410 */
    1511class CredentialsAgentExceptionTest {
    16 
    1712    /**
    18      * Setup test
    19      */
    20     @RegisterExtension
    21     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    22     public JOSMTestRules test = new JOSMTestRules();
    23 
    24     /**
    2513     * Unit test of {@code CredentialsAgentException#CredentialsAgentException}
    2614     */
    2715    @Test
  • test/unit/org/openstreetmap/josm/io/remotecontrol/handler/AddNodeHandlerTest.java

     
    55import static org.junit.jupiter.api.Assertions.assertEquals;
    66import static org.junit.jupiter.api.Assertions.assertThrows;
    77
    8 import org.junit.jupiter.api.extension.RegisterExtension;
    98import org.junit.jupiter.api.Test;
    109import org.openstreetmap.josm.data.osm.DataSet;
    1110import org.openstreetmap.josm.gui.MainApplication;
    1211import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    1312import org.openstreetmap.josm.io.remotecontrol.handler.RequestHandler.RequestHandlerBadRequestException;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT;
     14import org.openstreetmap.josm.testutils.annotations.Main;
     15import org.openstreetmap.josm.testutils.annotations.Projection;
    1516
    16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    17 
    1817/**
    1918 * Unit tests of {@link AddNodeHandler} class.
    2019 */
     20@Main
     21@Projection
     22@AssertionsInEDT
    2123class AddNodeHandlerTest {
    22     /**
    23      * Setup test.
    24      */
    25     @RegisterExtension
    26     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    27     public JOSMTestRules test = new JOSMTestRules().main().assertionsInEDT().projection();
    28 
    2924    private static AddNodeHandler newHandler(String url) throws RequestHandlerBadRequestException {
    3025        AddNodeHandler req = new AddNodeHandler();
    3126        if (url != null)
  • test/unit/org/openstreetmap/josm/plugins/PluginExceptionTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55
    6 import org.junit.jupiter.api.extension.RegisterExtension;
    76import org.junit.jupiter.api.Test;
    8 import org.openstreetmap.josm.testutils.JOSMTestRules;
    97
    10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    11 
    128/**
    139 * Unit tests of {@link PluginException} class.
    1410 */
    1511class PluginExceptionTest {
    16 
    1712    /**
    18      * Setup test.
    19      */
    20     @RegisterExtension
    21     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    22     public JOSMTestRules test = new JOSMTestRules();
    23 
    24     /**
    2513     * Unit test of {@link PluginException#PluginException}.
    2614     */
    2715    @Test
  • test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java

     
    1616import javax.swing.JOptionPane;
    1717import javax.swing.JScrollPane;
    1818
    19 import org.junit.jupiter.api.extension.RegisterExtension;
    2019import org.junit.jupiter.api.Test;
    2120import org.openstreetmap.josm.TestUtils;
    2221import org.openstreetmap.josm.gui.MainApplication;
     
    2423import org.openstreetmap.josm.gui.widgets.JosmTextArea;
    2524import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin;
    2625import org.openstreetmap.josm.plugins.PluginHandler.PluginInformationAction;
    27 import org.openstreetmap.josm.testutils.JOSMTestRules;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    2827import org.openstreetmap.josm.testutils.mockers.HelpAwareOptionPaneMocker;
    2928import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    3029
    31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3230import nl.jqno.equalsverifier.EqualsVerifier;
    3331
    3432/**
    3533 * Unit tests of {@link PluginHandler} class.
    3634 */
     35@BasicPreferences
    3736class PluginHandlerTest {
    38 
    3937    /**
    40      * Setup test.
    41      */
    42     @RegisterExtension
    43     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    44     public JOSMTestRules test = new JOSMTestRules();
    45 
    46     /**
    4738     * Unit test of methods {@link DeprecatedPlugin#equals} and {@link DeprecatedPlugin#hashCode}.
    4839     */
    4940    @Test
  • test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

     
    1717import java.util.Map;
    1818import java.util.Map.Entry;
    1919import java.util.Set;
     20import java.util.concurrent.TimeUnit;
    2021import java.util.function.Consumer;
    2122import java.util.stream.Collectors;
    2223
    2324import org.junit.jupiter.api.BeforeAll;
    2425import org.junit.jupiter.api.Test;
    25 import org.junit.jupiter.api.extension.RegisterExtension;
     26import org.junit.jupiter.api.Timeout;
    2627import org.openstreetmap.josm.TestUtils;
    2728import org.openstreetmap.josm.data.Preferences;
    2829import org.openstreetmap.josm.data.gpx.GpxData;
     
    3334import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    3435import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    3536import org.openstreetmap.josm.spi.preferences.Config;
    36 import org.openstreetmap.josm.testutils.JOSMTestRules;
     37import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     38import org.openstreetmap.josm.testutils.annotations.HTTP;
     39import org.openstreetmap.josm.testutils.annotations.HTTPS;
     40import org.openstreetmap.josm.testutils.annotations.IntegrationTest;
     41import org.openstreetmap.josm.testutils.annotations.Main;
     42import org.openstreetmap.josm.testutils.annotations.Projection;
    3743import org.openstreetmap.josm.tools.Destroyable;
    3844import org.openstreetmap.josm.tools.Logging;
    3945import org.openstreetmap.josm.tools.Utils;
    4046
    41 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    42 
    4347/**
    4448 * Integration tests of {@link PluginHandler} class.
    4549 */
     50@FullPreferences
     51@Projection
     52@HTTP
     53@HTTPS
     54@Main
     55@Timeout(value = 10, unit = TimeUnit.MINUTES)
     56@IntegrationTest
    4657public class PluginHandlerTestIT {
    47 
    4858    private static final List<String> errorsToIgnore = new ArrayList<>();
    49     /**
    50      * Setup test.
    51      */
    52     @RegisterExtension
    53     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public static JOSMTestRules test = new JOSMTestRules().main().projection().preferences().https()
    55             .timeout(10 * 60 * 1000);
    5659
    5760    /**
    5861     * Setup test
  • test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java

     
    44import static org.junit.jupiter.api.Assertions.assertFalse;
    55import static org.junit.jupiter.api.Assertions.assertTrue;
    66
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    87import org.junit.jupiter.api.Test;
    9 import org.openstreetmap.josm.testutils.JOSMTestRules;
     8import org.openstreetmap.josm.testutils.annotations.HTTPS;
     9import org.openstreetmap.josm.testutils.annotations.Main;
     10import org.openstreetmap.josm.testutils.annotations.OsmApiType;
     11import org.openstreetmap.josm.testutils.annotations.Projection;
    1012
    11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    12 
    1313/**
    1414 * Unit tests of {@link Lifecycle} class.
    1515 */
     16@HTTPS
     17@Main
     18@Projection
     19@OsmApiType(apiType = OsmApiType.APIType.DEV)
    1620class LifecycleTest {
    17 
    18     /**
    19      * Setup test.
    20      */
    21     @RegisterExtension
    22     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    23     public JOSMTestRules test = new JOSMTestRules().https().devAPI().main().projection();
    24 
    2521    private static class InitStatusListenerStub implements InitStatusListener {
    2622
    2723        boolean updated;
  • test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

     
    6060import org.openstreetmap.josm.io.OsmTransferCanceledException;
    6161import org.openstreetmap.josm.spi.preferences.Config;
    6262import org.openstreetmap.josm.spi.preferences.Setting;
     63import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT;
     64import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     65import org.openstreetmap.josm.testutils.annotations.HTTPS;
     66import org.openstreetmap.josm.testutils.annotations.JosmHome;
     67import org.openstreetmap.josm.testutils.annotations.Main;
     68import org.openstreetmap.josm.testutils.annotations.OsmApiType;
     69import org.openstreetmap.josm.testutils.annotations.Presets;
     70import org.openstreetmap.josm.testutils.annotations.Projection;
     71import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids;
    6372import org.openstreetmap.josm.testutils.mockers.EDTAssertionMocker;
    6473import org.openstreetmap.josm.testutils.mockers.WindowlessMapViewStateMocker;
    6574import org.openstreetmap.josm.testutils.mockers.WindowlessNavigatableComponentMocker;
     
    134143    /**
    135144     * Enable the use of default preferences.
    136145     * @return this instance, for easy chaining
     146     * @deprecated Use {@link FullPreferences} instead.
    137147     */
     148    @Deprecated
    138149    public JOSMTestRules preferences() {
    139150        josmHome();
    140151        usePreferences = true;
     
    144155    /**
    145156     * Set JOSM home to a valid, empty directory.
    146157     * @return this instance, for easy chaining
     158     * @deprecated Use {@link JosmHome} instead.
    147159     */
     160    @Deprecated
    148161    private JOSMTestRules josmHome() {
    149162        josmHome = new TemporaryFolder();
    150163        return this;
     
    153166    /**
    154167     * Enables the i18n module for this test in english.
    155168     * @return this instance, for easy chaining
     169     * @deprecated Use {org.openstreetmap.josm.testutils.annotations.I18n} instead.
    156170     */
     171    @Deprecated
    157172    public JOSMTestRules i18n() {
    158173        return i18n("en");
    159174    }
     
    162177     * Enables the i18n module for this test.
    163178     * @param language The language to use.
    164179     * @return this instance, for easy chaining
     180     * @deprecated Use {org.openstreetmap.josm.testutils.annotations.I18n} instead.
    165181     */
     182    @Deprecated
    166183    public JOSMTestRules i18n(String language) {
    167184        i18n = language;
    168185        return this;
     
    172189     * Mock this test's assumed JOSM version (as reported by {@link Version}).
    173190     * @param revisionProperties mock contents of JOSM's {@code REVISION} properties file
    174191     * @return this instance, for easy chaining
     192     * @deprecated Use {@link OverrideAssumeRevision} instead.
    175193     */
     194    @Deprecated
    176195    public JOSMTestRules assumeRevision(final String revisionProperties) {
    177196        this.assumeRevisionString = revisionProperties;
    178197        return this;
     
    181200    /**
    182201     * Enable the dev.openstreetmap.org API for this test.
    183202     * @return this instance, for easy chaining
     203     * @deprecated Use {@link OsmApiType} instead.
    184204     */
     205    @Deprecated
    185206    public JOSMTestRules devAPI() {
    186207        preferences();
    187208        useAPI = APIType.DEV;
     
    191212    /**
    192213     * Use the {@link FakeOsmApi} for testing.
    193214     * @return this instance, for easy chaining
     215     * @deprecated Use {@link OsmApiType} instead.
    194216     */
     217    @Deprecated
    195218    public JOSMTestRules fakeAPI() {
    196219        useAPI = APIType.FAKE;
    197220        return this;
     
    200223    /**
    201224     * Set up default projection (Mercator)
    202225     * @return this instance, for easy chaining
     226     * @deprecated Use {@link Projection} instead.
    203227     */
     228    @Deprecated
    204229    public JOSMTestRules projection() {
    205230        useProjection = true;
    206231        return this;
     
    209234    /**
    210235     * Set up loading of NTV2 grit shift files to support projections that need them.
    211236     * @return this instance, for easy chaining
     237     * @deprecated Use {@link ProjectionNadGrids} instead.
    212238     */
     239    @Deprecated
    213240    public JOSMTestRules projectionNadGrids() {
    214241        useProjectionNadGrids = true;
    215242        return this;
     
    218245    /**
    219246     * Set up HTTPS certificates
    220247     * @return this instance, for easy chaining
     248     * @deprecated Use {@link HTTPS} instead.
    221249     */
     250    @Deprecated
    222251    public JOSMTestRules https() {
    223252        useHttps = true;
    224253        return this;
     
    257286     * Use presets in this test.
    258287     * @return this instance, for easy chaining
    259288     * @since 12568
     289     * @deprecated Use {@link Presets} instead.
    260290     */
     291    @Deprecated
    261292    public JOSMTestRules presets() {
    262293        preferences();
    263294        usePresets = true;
     
    268299     * Use boundaries dataset in this test.
    269300     * @return this instance, for easy chaining
    270301     * @since 12545
     302     * @deprecated Use {@link org.openstreetmap.josm.testutils.annotations.Territories} instead.
    271303     */
     304    @Deprecated
    272305    public JOSMTestRules territories() {
    273306        territories = true;
    274307        return this;
     
    299332    /**
    300333     * Re-raise AssertionErrors thrown in the EDT where they would have normally been swallowed.
    301334     * @return this instance, for easy chaining
     335     * @deprecated Use {@link AssertionsInEDT} instead
    302336     */
     337    @Deprecated
    303338    public JOSMTestRules assertionsInEDT() {
    304339        return this.assertionsInEDT(EDTAssertionMocker::new);
    305340    }
     
    309344     * @param edtAssertionMockingRunnable Runnable for initializing this functionality
    310345     *
    311346     * @return this instance, for easy chaining
     347     * @deprecated Use {@link AssertionsInEDT} instead
    312348     */
     349    @Deprecated
    313350    public JOSMTestRules assertionsInEDT(final Runnable edtAssertionMockingRunnable) {
    314351        this.edtAssertionMockingRunnable = edtAssertionMockingRunnable;
    315352        return this;
     
    351388     *         global variables in this test.
    352389     * @return this instance, for easy chaining
    353390     * @since 12557
     391     * @deprecated Use {@link Main} instead
    354392     */
     393    @Deprecated
    355394    public JOSMTestRules main() {
    356395        return this.main(
    357396            WindowlessMapViewStateMocker::new,
     
    368407     *        of {@link org.openstreetmap.josm.gui.NavigatableComponent}, null to skip.
    369408     *
    370409     * @return this instance, for easy chaining
     410     * @deprecated Use {@link Main} instead
    371411     */
     412    @Deprecated
    372413    public JOSMTestRules main(
    373414        final Runnable mapViewStateMockingRunnable,
    374415        final Runnable navigableComponentMockingRunnable
     
    397438        return this;
    398439    }
    399440
    400     private static class MockVersion extends Version {
    401         MockVersion(final String propertiesString) {
     441    /*
     442     * Mock the JOSM version. This should only be used in JOSM Core test extensions.
     443     */
     444    public static class MockVersion extends Version {
     445        public MockVersion(final String propertiesString) {
    402446            super.initFromRevisionInfo(
    403447                new ByteArrayInputStream(propertiesString.getBytes(StandardCharsets.UTF_8))
    404448            );
     
    409453    public Statement apply(Statement base, Description description) {
    410454        // First process any Override* annotations for per-test overrides.
    411455        // The following only work because "option" methods modify JOSMTestRules in-place
    412         final OverrideAssumeRevision overrideAssumeRevision = description.getAnnotation(OverrideAssumeRevision.class);
     456        OverrideAssumeRevision overrideAssumeRevision = description.getAnnotation(OverrideAssumeRevision.class);
    413457        if (overrideAssumeRevision != null) {
    414458            this.assumeRevision(overrideAssumeRevision.value());
    415459        }
     
    790834    /**
    791835     * Override this test's assumed JOSM version (as reported by {@link Version}).
    792836     * @see JOSMTestRules#assumeRevision(String)
     837     * @deprecated Use {@link org.openstreetmap.josm.testutils.annotations.AssumeRevision}
     838     *             when using JUnit 5 Extensions.
    793839     */
    794840    @Documented
    795841    @Retention(RetentionPolicy.RUNTIME)
    796842    @Target(ElementType.METHOD)
     843    @Deprecated
    797844    public @interface OverrideAssumeRevision {
    798845        /**
    799846         * Returns overridden assumed JOSM version.
  • test/unit/org/openstreetmap/josm/testutils/annotations/AnnotationUtils.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import java.lang.annotation.Annotation;
     5import java.lang.reflect.Field;
     6import java.lang.reflect.Modifier;
     7import java.util.Optional;
     8
     9import org.junit.jupiter.api.extension.ExtensionContext;
     10import org.junit.platform.commons.support.AnnotationSupport;
     11
     12/**
     13 * Useful methods for annotation extensions
     14 * @author Taylor Smock
     15 * @since xxx
     16 */
     17final class AnnotationUtils {
     18    private AnnotationUtils() {
     19        // Utils class
     20    }
     21
     22    /**
     23     * Find the first parent annotation
     24     * @param <T> The annotation to find
     25     * @param context The context to search
     26     * @param annotation The annotation to find
     27     * @return See {@link AnnotationSupport#findAnnotation}
     28     */
     29    public static <T extends Annotation> Optional<T> findFirstParentAnnotation(ExtensionContext context, Class<T> annotation) {
     30        ExtensionContext current = context;
     31        do {
     32            Optional<T> foundAnnotation = AnnotationSupport.findAnnotation(current.getElement(), annotation);
     33            if (foundAnnotation.isPresent()) {
     34                return foundAnnotation;
     35            }
     36            current = current.getParent().orElse(null);
     37        } while (current != null);
     38        return Optional.empty();
     39    }
     40
     41    /**
     42     * Reset a static class (all static fields are unset). If they are initialized as part of a static block, please be aware of NPEs.
     43     * @param clazz The class to reset
     44     * @throws ReflectiveOperationException If reflection doesn't work, for whatever reason.
     45     */
     46    public static void resetStaticClass(Class<?> clazz) throws ReflectiveOperationException {
     47        for (Field field : clazz.getDeclaredFields()) {
     48            // Only reset static fields, but not final static fields
     49            if ((field.getModifiers() & Modifier.STATIC) != 0 && (field.getModifiers() & Modifier.FINAL) == 0) {
     50                if (!field.isAccessible()) {
     51                    field.setAccessible(true);
     52                }
     53                field.set(null, null);
     54            }
     55        }
     56    }
     57}
  • test/unit/org/openstreetmap/josm/testutils/annotations/AssertionsInEDT.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.ElementType.TYPE;
     5import static java.lang.annotation.RetentionPolicy.RUNTIME;
     6
     7import java.lang.annotation.Documented;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     10import java.util.Optional;
     11
     12import org.junit.jupiter.api.extension.BeforeEachCallback;
     13import org.junit.jupiter.api.extension.ExtensionContext;
     14import org.junit.platform.commons.support.AnnotationSupport;
     15import org.openstreetmap.josm.testutils.JOSMTestRules;
     16import org.openstreetmap.josm.testutils.mockers.EDTAssertionMocker;
     17
     18import mockit.MockUp;
     19
     20/**
     21 * Raise assertions in the EDT.
     22 * @author Taylor Smock
     23 * @see JOSMTestRules#assertionsInEDT
     24 * @since xxx
     25 */
     26@Documented
     27@Retention(RUNTIME)
     28@Target(TYPE)
     29public @interface AssertionsInEDT {
     30    /**
     31     * Get the mocker to use for the EDT
     32     * @return The mock
     33     */
     34    Class<? extends MockUp<?>> value() default EDTAssertionMocker.class;
     35    /**
     36     * Initialize the mocker for the EDT
     37     * @author Taylor Smock
     38     *
     39     */
     40    class AssertionsInEDTExtension implements BeforeEachCallback {
     41        @Override
     42        public void beforeEach(ExtensionContext context) throws Exception {
     43            Optional<AssertionsInEDT> annotation = AnnotationSupport.findAnnotation(context.getElement(), AssertionsInEDT.class);
     44            if (annotation.isPresent()) {
     45                Class<? extends MockUp<?>> clazz = annotation.get().value();
     46                clazz.getConstructor().newInstance();
     47            }
     48        }
     49    }
     50}
  • test/unit/org/openstreetmap/josm/testutils/annotations/AssumeRevision.java

     
     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.junit.platform.commons.support.AnnotationSupport;
     18import org.openstreetmap.josm.TestUtils;
     19import org.openstreetmap.josm.data.Version;
     20import org.openstreetmap.josm.testutils.JOSMTestRules;
     21
     22
     23/**
     24 * Override this test's assumed JOSM version (as reported by {@link Version}).
     25 * @author Taylor Smock
     26 * @see JOSMTestRules#assumeRevision(String)
     27 * @since xxx
     28 */
     29@Documented
     30@Retention(RetentionPolicy.RUNTIME)
     31@Target({ElementType.METHOD, ElementType.TYPE})
     32@ExtendWith(AssumeRevision.AssumeRevisionExtension.class)
     33public @interface AssumeRevision {
     34    /**
     35     * Returns overridden assumed JOSM version.
     36     * @return overridden assumed JOSM version
     37     */
     38    String value();
     39
     40    /**
     41     * Override the JOSM revision information. Use {@link AssumeRevision} instead of directly using this extension.
     42     * @author Taylor Smock
     43     * @since xxx
     44     */
     45    class AssumeRevisionExtension implements BeforeEachCallback, AfterEachCallback {
     46
     47        @Override
     48        public void afterEach(ExtensionContext context) throws Exception {
     49            Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class));
     50            String originalVersion = store.getOrDefault(store, String.class, null);
     51            if (originalVersion != null) {
     52                TestUtils.setPrivateStaticField(Version.class, "instance", originalVersion);
     53            }
     54        }
     55
     56        @Override
     57        public void beforeEach(ExtensionContext context) throws Exception {
     58            Optional<AssumeRevision> annotation = AnnotationSupport.findAnnotation(context.getElement(), AssumeRevision.class);
     59            if (annotation.isPresent()) {
     60                Store store = context.getStore(Namespace.create(AssumeRevisionExtension.class));
     61                store.put("originalVersion", Version.getInstance());
     62                final Version replacementVersion = new JOSMTestRules.MockVersion(annotation.get().value());
     63                TestUtils.setPrivateStaticField(Version.class, "instance", replacementVersion);
     64            }
     65        }
     66    }
     67}
  • test/unit/org/openstreetmap/josm/testutils/annotations/BasicPreferences.java

     
     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;
     9
     10import org.junit.jupiter.api.extension.AfterAllCallback;
     11import org.junit.jupiter.api.extension.BeforeAllCallback;
     12import org.junit.jupiter.api.extension.ExtendWith;
     13import org.junit.jupiter.api.extension.ExtensionContext;
     14import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
     15import org.openstreetmap.josm.data.Preferences;
     16import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
     17import org.openstreetmap.josm.data.preferences.JosmUrls;
     18import org.openstreetmap.josm.spi.preferences.Config;
     19import org.openstreetmap.josm.testutils.JOSMTestRules;
     20
     21/**
     22 * Allow tests to use JOSM preferences (see {@link JOSMTestRules#preferences()})
     23 * @author Taylor Smock
     24 * @see FullPreferences
     25 * @since xxx
     26 */
     27@Documented
     28@Retention(RetentionPolicy.RUNTIME)
     29@Target(ElementType.TYPE)
     30@ExtendWith(BasicPreferences.BasicPreferencesExtension.class)
     31public @interface BasicPreferences {
     32
     33    /**
     34     * Initialize basic preferences. This is often more than enough for basic tests.
     35     * @author Taylor Smock
     36     *
     37     */
     38    class BasicPreferencesExtension implements BeforeAllCallback, AfterAllCallback {
     39        @Override
     40        public void afterAll(ExtensionContext context) throws Exception {
     41            AnnotationUtils.resetStaticClass(Config.class);
     42        }
     43
     44        @Override
     45        public void beforeAll(ExtensionContext context) throws Exception {
     46            Preferences pref = Preferences.main();
     47            Config.setPreferencesInstance(pref);
     48            Config.setBaseDirectoriesProvider(JosmBaseDirectories.getInstance());
     49            Config.setUrlsProvider(JosmUrls.getInstance());
     50            context.getStore(Namespace.create(BasicPreferencesExtension.class)).put("preferences", pref);
     51        }
     52    }
     53}
  • test/unit/org/openstreetmap/josm/testutils/annotations/DeleteCommandCallback.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.ElementType.TYPE;
     5import static java.lang.annotation.RetentionPolicy.RUNTIME;
     6
     7import java.lang.annotation.Documented;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     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.openstreetmap.josm.actions.DeleteAction;
     16import org.openstreetmap.josm.command.DeleteCommand;
     17
     18/**
     19 * Initialize the DeleteCommand callback with the default callback.
     20 * @author Taylor Smock
     21 * @since xxx
     22 */
     23@Documented
     24@Retention(RUNTIME)
     25@Target(TYPE)
     26@ExtendWith(DeleteCommandCallback.DeleteCommandCallbackExtension.class)
     27public @interface DeleteCommandCallback {
     28    /**
     29     * Initialize and reset the DeleteCommand callback
     30     * @author Taylor Smock
     31     *
     32     */
     33    class DeleteCommandCallbackExtension implements BeforeAllCallback, AfterAllCallback {
     34        @Override
     35        public void afterAll(ExtensionContext context) throws Exception {
     36            AnnotationUtils.resetStaticClass(DeleteCommand.class);
     37        }
     38
     39        @Override
     40        public void beforeAll(ExtensionContext context) throws Exception {
     41            DeleteCommand.setDeletionCallback(DeleteAction.defaultDeletionCallback);
     42        }
     43    }
     44}
  • test/unit/org/openstreetmap/josm/testutils/annotations/FullPreferences.java

     
     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.Map;
     10
     11import org.junit.jupiter.api.extension.BeforeEachCallback;
     12import org.junit.jupiter.api.extension.ExtendWith;
     13import org.junit.jupiter.api.extension.ExtensionContext;
     14import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
     15import org.openstreetmap.josm.TestUtils;
     16import org.openstreetmap.josm.data.Preferences;
     17import org.openstreetmap.josm.spi.preferences.Config;
     18import org.openstreetmap.josm.spi.preferences.Setting;
     19import org.openstreetmap.josm.testutils.JOSMTestRules;
     20import org.openstreetmap.josm.testutils.annotations.BasicPreferences.BasicPreferencesExtension;
     21
     22/**
     23 * Allow tests to use JOSM preferences (see {@link JOSMTestRules#preferences()})
     24 * @author Taylor Smock
     25 * @see BasicPreferences (often enough for simple tests).
     26 * @since xxx
     27 */
     28@Documented
     29@Retention(RetentionPolicy.RUNTIME)
     30@Target(ElementType.TYPE)
     31@JosmHome
     32@BasicPreferences
     33@ExtendWith(FullPreferences.UsePreferencesExtension.class)
     34public @interface FullPreferences {
     35    /**
     36     * Initialize preferences.
     37     */
     38    class UsePreferencesExtension implements BeforeEachCallback {
     39        @Override
     40        public void beforeEach(ExtensionContext context) throws Exception {
     41            Preferences pref = context.getStore(Namespace.create(BasicPreferencesExtension.class)).get("preferences", Preferences.class);
     42            @SuppressWarnings("unchecked")
     43            final Map<String, Setting<?>> defaultsMap = (Map<String, Setting<?>>) TestUtils.getPrivateField(pref, "defaultsMap");
     44            defaultsMap.clear();
     45            pref.resetToInitialState();
     46            pref.enableSaveOnPut(false);
     47            // No pref init -> that would only create the preferences file.
     48            // We force the use of a wrong API server, just in case anyone attempts an upload
     49            Config.getPref().put("osm-server.url", "http://invalid");
     50        }
     51
     52    }
     53}
  • test/unit/org/openstreetmap/josm/testutils/annotations/HTTP.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.ElementType.TYPE;
     5import static java.lang.annotation.RetentionPolicy.RUNTIME;
     6
     7import java.lang.annotation.Documented;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     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.openstreetmap.josm.tools.Http1Client;
     16import org.openstreetmap.josm.tools.HttpClient;
     17
     18/**
     19 * Set up the HttpClient factory
     20 * @author Taylor Smock
     21 * @since xxx
     22 */
     23@Documented
     24@Retention(RUNTIME)
     25@Target(TYPE)
     26@ExtendWith(HTTP.HTTPExtension.class)
     27public @interface HTTP {
     28    /**
     29     * Initialize and reset HttpClient
     30     * @author Taylor Smock
     31     *
     32     */
     33    class HTTPExtension implements BeforeAllCallback, AfterAllCallback {
     34        @Override
     35        public void afterAll(ExtensionContext context) throws Exception {
     36            AnnotationUtils.resetStaticClass(HttpClient.class);
     37        }
     38
     39        @Override
     40        public void beforeAll(ExtensionContext context) throws Exception {
     41            HttpClient.setFactory(Http1Client::new);
     42        }
     43    }
     44}
  • test/unit/org/openstreetmap/josm/testutils/annotations/HTTPS.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.ElementType.TYPE;
     5import static java.lang.annotation.RetentionPolicy.RUNTIME;
     6
     7import java.lang.annotation.Documented;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     10
     11import org.junit.jupiter.api.extension.BeforeAllCallback;
     12import org.junit.jupiter.api.extension.ExtendWith;
     13import org.junit.jupiter.api.extension.ExtensionContext;
     14import org.openstreetmap.josm.io.CertificateAmendment;
     15import org.openstreetmap.josm.testutils.JOSMTestRules;
     16
     17/**
     18 * Set up HTTPS certificates
     19 *
     20 * @author Taylor Smock
     21 * @see JOSMTestRules#https
     22 * @since xxx
     23 */
     24@Documented
     25@Retention(RUNTIME)
     26@Target(TYPE)
     27@BasicPreferences
     28@ExtendWith(HTTPS.HTTPSExtension.class)
     29public @interface HTTPS {
     30
     31    /**
     32     * Set up HTTPS certificates. Only run once.
     33     * @author Taylor Smock
     34     */
     35    class HTTPSExtension implements BeforeAllCallback {
     36        private static boolean initialized;
     37        @Override
     38        public void beforeAll(ExtensionContext context) throws Exception {
     39            if (!initialized) {
     40                synchronized (HTTPSExtension.class) {
     41                    CertificateAmendment.addMissingCertificates();
     42                    initialized = true;
     43                }
     44            }
     45        }
     46
     47    }
     48}
  • test/unit/org/openstreetmap/josm/testutils/annotations/I18n.java

     
     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.BeforeAllCallback;
     12import org.junit.jupiter.api.extension.ExtendWith;
     13import org.junit.jupiter.api.extension.ExtensionContext;
     14import org.junit.platform.commons.support.AnnotationSupport;
     15import org.openstreetmap.josm.testutils.JOSMTestRules;
     16
     17/**
     18 * Enables the i18n module for this test.
     19 * @author Taylor Smock
     20 * @see JOSMTestRules#i18n(String)
     21 *
     22 */
     23@Documented
     24@Retention(RetentionPolicy.RUNTIME)
     25@Target(ElementType.TYPE)
     26@ExtendWith(I18n.I18nExtension.class)
     27public @interface I18n {
     28    /**
     29     * Get the language to use for i18n
     30     * @return The language (default "en").
     31     */
     32    String language() default "en";
     33
     34    /**
     35     * Enables the i18n module for this test.
     36     * @author Taylor Smock
     37     * @see JOSMTestRules#i18n(String)
     38     *
     39     */
     40    class I18nExtension implements BeforeAllCallback {
     41        @Override
     42        public void beforeAll(ExtensionContext context) throws Exception {
     43            Optional<I18n> annotation = AnnotationSupport.findAnnotation(context.getElement(), I18n.class);
     44            String language = "en";
     45            if (annotation.isPresent()) {
     46                language = annotation.get().language();
     47            }
     48            org.openstreetmap.josm.tools.I18n.set(language);
     49        }
     50    }
     51}
  • test/unit/org/openstreetmap/josm/testutils/annotations/IntegrationTest.java

     
     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

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import java.io.File;
     5import java.io.IOException;
     6import java.lang.annotation.Documented;
     7import java.lang.annotation.ElementType;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.RetentionPolicy;
     10import java.lang.annotation.Target;
     11import java.nio.file.FileVisitResult;
     12import java.nio.file.Files;
     13import java.nio.file.Path;
     14import java.nio.file.SimpleFileVisitor;
     15import java.nio.file.attribute.BasicFileAttributes;
     16import java.util.UUID;
     17
     18import org.junit.jupiter.api.extension.AfterAllCallback;
     19import org.junit.jupiter.api.extension.BeforeAllCallback;
     20import org.junit.jupiter.api.extension.ExtendWith;
     21import org.junit.jupiter.api.extension.ExtensionContext;
     22import org.junit.jupiter.api.extension.ExtensionContext.Namespace;
     23import org.openstreetmap.josm.data.preferences.JosmBaseDirectories;
     24import org.openstreetmap.josm.testutils.JOSMTestRules;
     25
     26/**
     27 * Use the JOSM home directory. See {@link JOSMTestRules}.
     28 * Typically only used by {@link FullPreferences}.
     29 *
     30 * @author Taylor Smock
     31 *
     32 */
     33@Documented
     34@Retention(RetentionPolicy.RUNTIME)
     35@Target(ElementType.TYPE)
     36@ExtendWith(JosmHome.JosmHomeExtension.class)
     37public @interface JosmHome {
     38    /**
     39     * Create a JOSM home directory. Prefer using {@link JosmHome}.
     40     * @author Taylor Smock
     41     */
     42    class JosmHomeExtension implements BeforeAllCallback, AfterAllCallback {
     43        @Override
     44        public void afterAll(ExtensionContext context) throws Exception {
     45            Path tempDir = context.getStore(Namespace.create(JosmHome.class)).get("home", Path.class);
     46            Files.walkFileTree(tempDir, new SimpleFileVisitor<Path>() {
     47                @Override
     48                public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException {
     49                    Files.delete(dir);
     50                    return FileVisitResult.CONTINUE;
     51                }
     52
     53                @Override
     54                public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException {
     55                    Files.delete(file);
     56                    return FileVisitResult.CONTINUE;
     57                }
     58            });
     59        }
     60
     61        @Override
     62        public void beforeAll(ExtensionContext context) throws Exception {
     63            Path tempDir = Files.createTempDirectory(UUID.randomUUID().toString());
     64            context.getStore(Namespace.create(JosmHome.class)).put("home", tempDir);
     65            File home = tempDir.toFile();
     66            System.setProperty("josm.home", home.getAbsolutePath());
     67            JosmBaseDirectories.getInstance().clearMemos();
     68        }
     69    }
     70}
  • test/unit/org/openstreetmap/josm/testutils/annotations/LayerEnvironment.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.ElementType.TYPE;
     5import static java.lang.annotation.RetentionPolicy.RUNTIME;
     6
     7import java.lang.annotation.Documented;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     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.openstreetmap.josm.testutils.JOSMTestRules;
     16
     17/**
     18 * Clean up layers before/after the tests
     19 * @author Taylor Smock
     20 * @see JOSMTestRules#cleanLayerEnvironment()
     21 * @since xxx
     22 */
     23@Documented
     24@Retention(RUNTIME)
     25@Target(TYPE)
     26@ExtendWith(LayerEnvironment.LayerEnvironmentExtension.class)
     27public @interface LayerEnvironment {
     28    /**
     29     * Clean up layers
     30     * @author Taylor Smock
     31     *
     32     */
     33    class LayerEnvironmentExtension implements BeforeEachCallback, AfterEachCallback {
     34        @Override
     35        public void afterEach(ExtensionContext context) throws Exception {
     36            beforeEach(context);
     37        }
     38
     39        @Override
     40        public void beforeEach(ExtensionContext context) throws Exception {
     41            JOSMTestRules.cleanLayerEnvironment();
     42        }
     43    }
     44}
  • test/unit/org/openstreetmap/josm/testutils/annotations/Main.java

     
     1// License: GPL. For details, see LICENSE file.
     2package org.openstreetmap.josm.testutils.annotations;
     3
     4import static java.lang.annotation.ElementType.TYPE;
     5import static java.lang.annotation.RetentionPolicy.RUNTIME;
     6
     7import java.lang.annotation.Documented;
     8import java.lang.annotation.Retention;
     9import java.lang.annotation.Target;
     10import java.util.Optional;
     11
     12import org.junit.jupiter.api.extension.AfterAllCallback;
     13import org.junit.jupiter.api.extension.BeforeAllCallback;
     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(TYPE)
     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     * Get the class to use for the navigable component
     43     * @return The class to use for the navigable component.
     44     */
     45    Class<?> navigableComponentMocker() default WindowlessNavigatableComponentMocker.class;
     46
     47    /**
     48     * Initialize the MainApplication
     49     * @author Taylor Smock
     50     */
     51    class MainExtension implements BeforeAllCallback, AfterAllCallback {
     52        @Override
     53        public void afterAll(ExtensionContext context) throws Exception {
     54            MainApplication.getLayerManager().resetState();;
     55            AnnotationUtils.resetStaticClass(MainApplication.class);
     56        }
     57
     58        @Override
     59        public void beforeAll(ExtensionContext context) throws Exception {
     60            Optional<Main> annotation = AnnotationSupport.findAnnotation(context.getElement(), Main.class);
     61            Class<?> mapViewStateMocker = null;
     62            Class<?> navigableComponentMocker = null;
     63            if (annotation.isPresent()) {
     64                mapViewStateMocker = annotation.get().mapViewStateMocker();
     65                navigableComponentMocker = annotation.get().navigableComponentMocker();
     66            }
     67
     68            // apply mockers to MapViewState and NavigableComponent whether we're headless or not
     69            // as we generally don't create the josm main window even in non-headless mode.
     70            if (mapViewStateMocker != null) {
     71                mapViewStateMocker.getConstructor().newInstance();
     72            }
     73            if (navigableComponentMocker != null) {
     74                navigableComponentMocker.getConstructor().newInstance();
     75            }
     76
     77            new MainApplication();
     78            JOSMFixture.initContentPane();
     79            JOSMFixture.initMainPanel(true);
     80            JOSMFixture.initToolbar();
     81            JOSMFixture.initMainMenu();
     82        }
     83    }
     84}
  • test/unit/org/openstreetmap/josm/testutils/annotations/OsmApiType.java

     
     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.BeforeAllCallback;
     14import org.junit.jupiter.api.extension.BeforeEachCallback;
     15import org.junit.jupiter.api.extension.ExtendWith;
     16import org.junit.jupiter.api.extension.ExtensionContext;
     17import org.openstreetmap.josm.io.OsmApi;
     18import org.openstreetmap.josm.spi.preferences.Config;
     19import org.openstreetmap.josm.testutils.FakeOsmApi;
     20import org.openstreetmap.josm.testutils.JOSMTestRules;
     21
     22/**
     23 * Specify the OSM API to use for the test. {@link APIType#NONE} has no effect.
     24 *
     25 * @author Taylor Smock
     26 * @see JOSMTestRules#devAPI()
     27 * @see JOSMTestRules#fakeAPI()
     28 * @since xxx
     29 */
     30@Documented
     31@Retention(RUNTIME)
     32@Target({ TYPE, METHOD })
     33@FullPreferences
     34@HTTP
     35@ExtendWith(OsmApiType.OsmApiTypeExtension.class)
     36public @interface OsmApiType {
     37    /**
     38     * API types to initialize
     39     * @author Taylor Smock
     40     *
     41     */
     42    enum APIType {
     43        NONE, FAKE, DEV;
     44    }
     45
     46    /**
     47     * The API type to use
     48     * @return The API type to use (default NONE)
     49     */
     50    APIType apiType() default APIType.NONE;
     51
     52    /**
     53     * Initialize the OSM api
     54     * @author Taylor Smock
     55     *
     56     */
     57    class OsmApiTypeExtension implements BeforeAllCallback, BeforeEachCallback {
     58
     59        @Override
     60        public void beforeEach(ExtensionContext context) throws Exception {
     61            Optional<OsmApiType> annotation = AnnotationUtils.findFirstParentAnnotation(context, OsmApiType.class);
     62            APIType useAPI = APIType.NONE;
     63            if (annotation.isPresent()) {
     64                useAPI = annotation.get().apiType();
     65            }
     66            // Set API
     67            if (useAPI == APIType.DEV) {
     68                Config.getPref().put("osm-server.url", "https://api06.dev.openstreetmap.org/api");
     69            } else if (useAPI == APIType.FAKE) {
     70                FakeOsmApi api = FakeOsmApi.getInstance();
     71                Config.getPref().put("osm-server.url", api.getServerUrl());
     72            }
     73
     74            // Initialize API
     75            if (useAPI != APIType.NONE) {
     76                OsmApi.getOsmApi().initialize(null);
     77            }
     78        }
     79
     80        @Override
     81        public void beforeAll(ExtensionContext context) throws Exception {
     82            beforeEach(context);
     83        }
     84
     85    }
     86}
  • test/unit/org/openstreetmap/josm/testutils/annotations/Presets.java

     
     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;
     11
     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.openstreetmap.josm.gui.tagging.presets.TaggingPresets;
     17import org.openstreetmap.josm.testutils.JOSMTestRules;
     18
     19/**
     20 * Use presets in this test.
     21 *
     22 * @author Taylor Smock
     23 * @see JOSMTestRules#presets()
     24 * @since xxx
     25 */
     26@Documented
     27@Retention(RUNTIME)
     28@Target({ TYPE, METHOD })
     29@ExtendWith(Presets.PresetsExtension.class)
     30public @interface Presets {
     31    /**
     32     * Initialize the presets
     33     * @author Taylor Smock
     34     *
     35     */
     36    class PresetsExtension implements BeforeAllCallback, BeforeEachCallback {
     37        @Override
     38        public void beforeAll(ExtensionContext context) throws Exception {
     39            TaggingPresets.readFromPreferences();
     40        }
     41
     42        @Override
     43        public void beforeEach(ExtensionContext context) throws Exception {
     44            // TODO only run if method level
     45            beforeAll(context);
     46        }
     47    }
     48}
  • test/unit/org/openstreetmap/josm/testutils/annotations/Projection.java

     
     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}
  • test/unit/org/openstreetmap/josm/testutils/annotations/ProjectionNadGrids.java

     
     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;
     9
     10import org.junit.jupiter.api.extension.BeforeAllCallback;
     11import org.junit.jupiter.api.extension.ExtendWith;
     12import org.junit.jupiter.api.extension.ExtensionContext;
     13import org.openstreetmap.josm.gui.MainApplication;
     14import org.openstreetmap.josm.testutils.JOSMTestRules;
     15
     16/**
     17 * Set up loading of NTV2 grit shift files to support projections that need them.
     18 * @author Taylor Smock
     19 * @see JOSMTestRules#projectionNadGrids()
     20 * @since xxx
     21 */
     22@Documented
     23@Retention(RetentionPolicy.RUNTIME)
     24@Target(ElementType.TYPE)
     25@ExtendWith(ProjectionNadGrids.ProjectionNadGridsExtension.class)
     26public @interface ProjectionNadGrids {
     27    /**
     28     * Set up loading of NTV2 grit shift files to support projections that need them.
     29     * Use {@link ProjectionNadGrids} instead.
     30     * @author Taylor Smock
     31     * @see JOSMTestRules#projectionNadGrids()
     32     */
     33    class ProjectionNadGridsExtension implements BeforeAllCallback {
     34        @Override
     35        public void beforeAll(ExtensionContext context) throws Exception {
     36            MainApplication.setupNadGridSources();
     37        }
     38    }
     39}
  • test/unit/org/openstreetmap/josm/testutils/annotations/SlowTest.java

     
     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 * Use for any test which takes longer than 1 minute
     15 * @author Taylor Smock
     16 * @since xxx
     17 */
     18@Documented
     19@Retention(RUNTIME)
     20@Target({ElementType.TYPE, ElementType.METHOD})
     21@Tag("slowTest")
     22public @interface SlowTest {
     23
     24}
  • test/unit/org/openstreetmap/josm/testutils/annotations/Territories.java

     
     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@ExtendWith(Territories.TerritoriesExtension.class)
     29public @interface Territories {
     30    /**
     31     * Initialization states. Please note that the highest initialization state holds.
     32     * @author Taylor Smock
     33     */
     34    enum Initialize {
     35        /** Don't initialize */
     36        NONE,
     37        /** Initialize only internal data */
     38        INTERNAL,
     39        /** Initialize internal and external data */
     40        ALL
     41    }
     42
     43    /**
     44     * The way to initialize Territories
     45     * @return The value to use
     46     */
     47    Initialize value() default Initialize.INTERNAL;
     48
     49    /**
     50     * Initialize boundaries prior to use
     51     * @author Taylor Smock
     52     *
     53     */
     54    class TerritoriesExtension implements BeforeAllCallback, AfterAllCallback {
     55        @Override
     56        public void afterAll(ExtensionContext context) throws Exception {
     57            synchronized (TerritoriesExtension.class) {
     58                org.openstreetmap.josm.tools.Territories.uninitialize();
     59            }
     60        }
     61
     62        @Override
     63        public void beforeAll(ExtensionContext context) throws Exception {
     64            Optional<Territories> annotation = AnnotationSupport.findAnnotation(context.getElement(), Territories.class);
     65            if (annotation.isPresent()) {
     66                Initialize current = annotation.get().value();
     67                // Avoid potential race conditions if tests are parallelized
     68                synchronized (TerritoriesExtension.class) {
     69                    if (current == Initialize.INTERNAL) {
     70                        org.openstreetmap.josm.tools.Territories.initializeInternalData();
     71                    } else if (current == Initialize.ALL) {
     72                        org.openstreetmap.josm.tools.Territories.initialize();
     73                    }
     74                }
     75            }
     76        }
     77    }
     78}
  • test/unit/org/openstreetmap/josm/testutils/annotations/TimeZoneAnnotation.java

     
     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.TimeZone;
     11
     12import org.junit.jupiter.api.extension.AfterAllCallback;
     13import org.junit.jupiter.api.extension.BeforeEachCallback;
     14import org.junit.jupiter.api.extension.ExtendWith;
     15import org.junit.jupiter.api.extension.ExtensionContext;
     16import org.openstreetmap.josm.tools.date.DateUtils;
     17
     18/**
     19 * Set the default timezone
     20 * @author Taylor Smock
     21 * @since xxx
     22 */
     23@Documented
     24@Retention(RUNTIME)
     25@Target({ElementType.TYPE, ElementType.METHOD})
     26@ExtendWith(TimeZoneAnnotation.TimeZoneExtension.class)
     27public @interface TimeZoneAnnotation {
     28    /**
     29     * Set the default timezone
     30     * @author Taylor Smock
     31     */
     32    class TimeZoneExtension implements BeforeEachCallback, AfterAllCallback {
     33        @Override
     34        public void afterAll(ExtensionContext context) {
     35            TimeZone.setDefault(null);
     36            TimeZone.getDefault().getDisplayName();
     37        }
     38
     39        @Override
     40        public void beforeEach(ExtensionContext context) throws Exception {
     41            TimeZone.setDefault(DateUtils.UTC);
     42        }
     43    }
     44}
  • test/unit/org/openstreetmap/josm/tools/ExceptionUtilTest.java

     
    1212
    1313import org.junit.jupiter.api.BeforeEach;
    1414import org.junit.jupiter.api.Test;
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.openstreetmap.josm.io.ChangesetClosedException;
    1716import org.openstreetmap.josm.io.IllegalDataException;
    1817import org.openstreetmap.josm.io.MissingOAuthAccessTokenException;
     
    2120import org.openstreetmap.josm.io.OsmApiException;
    2221import org.openstreetmap.josm.io.OsmApiInitializationException;
    2322import org.openstreetmap.josm.io.auth.CredentialsManager;
    24 import org.openstreetmap.josm.testutils.JOSMTestRules;
     23import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     24import org.openstreetmap.josm.testutils.annotations.OsmApiType;
    2525import org.openstreetmap.josm.tools.date.DateUtils;
    2626import org.openstreetmap.josm.tools.date.DateUtilsTest;
    2727
    28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    29 
    3028/**
    3129 * Unit tests of {@link ExceptionUtil} class.
    3230 */
     31@FullPreferences
     32@OsmApiType(apiType = OsmApiType.APIType.FAKE)
    3333class ExceptionUtilTest {
    34 
    35     /**
    36      * Setup rule.
    37      */
    38     @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules test = new JOSMTestRules().preferences().fakeAPI();
    41 
    4234    private static String baseUrl;
    4335    private static String serverUrl;
    4436    private static String host;
  • test/unit/org/openstreetmap/josm/tools/GeometryTest.java

     
    1414import java.util.List;
    1515
    1616import org.junit.Assert;
    17 import org.junit.jupiter.api.extension.RegisterExtension;
    1817import org.junit.jupiter.api.Test;
    1918import org.openstreetmap.josm.TestUtils;
    2019import org.openstreetmap.josm.data.coor.EastNorth;
     
    2726import org.openstreetmap.josm.data.osm.Way;
    2827import org.openstreetmap.josm.data.osm.search.SearchCompiler;
    2928import org.openstreetmap.josm.io.OsmReader;
    30 import org.openstreetmap.josm.testutils.JOSMTestRules;
     29import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     30import org.openstreetmap.josm.testutils.annotations.Projection;
    3131
    32 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    33 
    3432/**
    3533 * Unit tests of {@link Geometry} class.
    3634 */
     35@BasicPreferences // For primitives
     36@Projection // For primitives
    3737class GeometryTest {
    3838    /**
    39      * Primitives need preferences and projection.
    40      */
    41     @RegisterExtension
    42     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    43     public JOSMTestRules test = new JOSMTestRules().preferences().projection();
    44 
    45     /**
    4639     * Test of {@link Geometry#getLineLineIntersection} method.
    4740     */
    4841    @Test
  • test/unit/org/openstreetmap/josm/tools/OptionParserTest.java

     
    33
    44import static org.junit.jupiter.api.Assertions.assertEquals;
    55import static org.junit.jupiter.api.Assertions.assertFalse;
     6import static org.junit.jupiter.api.Assertions.assertThrows;
    67import static org.junit.jupiter.api.Assertions.assertTrue;
    7 import static org.junit.jupiter.api.Assertions.assertThrows;
    88
    99import java.util.ArrayList;
    1010import java.util.Arrays;
     
    1212import java.util.concurrent.atomic.AtomicBoolean;
    1313import java.util.concurrent.atomic.AtomicReference;
    1414
    15 import org.junit.jupiter.api.extension.RegisterExtension;
    1615import org.junit.jupiter.api.Test;
    17 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1816import org.openstreetmap.josm.tools.OptionParser.OptionCount;
    1917import org.openstreetmap.josm.tools.OptionParser.OptionParseException;
    2018
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    22 
    2319/**
    2420 * Test for {@link OptionParser}
    2521 * @author Michael Zangl
    2622 */
    2723class OptionParserTest {
    28     /**
    29      * Setup test.
    30      */
    31     @RegisterExtension
    32     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    33     public JOSMTestRules test = new JOSMTestRules().i18n();
    34 
    3524    // A reason for moving to jupiter...
    3625    @Test
    3726    void testEmptyParserRejectsLongopt() {
  • test/unit/org/openstreetmap/josm/tools/SearchCompilerQueryWizardTest.java

     
    66
    77import org.junit.jupiter.api.Disabled;
    88import org.junit.jupiter.api.Test;
    9 import org.junit.jupiter.api.extension.RegisterExtension;
    10 import org.openstreetmap.josm.testutils.JOSMTestRules;
     9import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1110
    12 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    13 
    1411/**
    1512 * Unit tests of {@link SearchCompilerQueryWizard} class.
    1613 */
     14@org.openstreetmap.josm.testutils.annotations.I18n(language = "de")
     15@BasicPreferences // Due to OsmPrimitives being used
    1716class SearchCompilerQueryWizardTest {
    18     /**
    19      * Base test environment is enough
    20      */
    21     @RegisterExtension
    22     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    23     public JOSMTestRules test = new JOSMTestRules().i18n("de");
    24 
    2517    private static String constructQuery(String s) {
    2618        return SearchCompilerQueryWizard.constructQuery(s);
    2719    }
  • test/unit/org/openstreetmap/josm/tools/TextTagParserTest.java

     
    1010import java.util.List;
    1111import java.util.Map;
    1212
    13 import org.junit.jupiter.api.extension.RegisterExtension;
    1413import org.junit.jupiter.api.Test;
    15 import org.openstreetmap.josm.testutils.JOSMTestRules;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1615
    17 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    18 
    1916/**
    2017 * Unit tests of {@link TextTagParser} class.
    2118 */
     19@BasicPreferences
    2220class TextTagParserTest {
    2321    /**
    24      * Some of this depends on preferences.
    25      */
    26     @RegisterExtension
    27     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    28     public JOSMTestRules test = new JOSMTestRules().preferences();
    29 
    30     /**
    3122     * Test of {@link TextTagParser#unescape} method.
    3223     */
    3324    @Test
  • test/unit/org/openstreetmap/josm/tools/UtilsTest.java

     
    2222import java.util.regex.Pattern;
    2323
    2424import org.junit.jupiter.api.Test;
    25 import org.junit.jupiter.api.extension.RegisterExtension;
    26 import org.openstreetmap.josm.testutils.JOSMTestRules;
    2725
    28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2926import net.trajano.commons.testing.UtilityClassTestUtil;
    3027
    3128/**
     
    3330 */
    3431class UtilsTest {
    3532    /**
    36      * Use default, basic test rules.
    37      */
    38     @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     public JOSMTestRules rules = new JOSMTestRules();
    41 
    42     /**
    4333     * Tests that {@code Utils} satisfies utility class criteria.
    4434     * @throws ReflectiveOperationException if an error occurs
    4535     */
  • test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

     
    1616
    1717import org.junit.jupiter.api.Disabled;
    1818import org.junit.jupiter.api.Test;
    19 import org.junit.jupiter.api.extension.RegisterExtension;
    20 import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     20import org.openstreetmap.josm.testutils.annotations.TimeZoneAnnotation;
    2121import org.openstreetmap.josm.tools.UncheckedParseException;
    2222
    23 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2423import net.trajano.commons.testing.UtilityClassTestUtil;
    2524
    2625/**
    2726 * Unit tests of {@link DateUtils} class.
    2827 */
     28@TimeZoneAnnotation
     29@BasicPreferences
    2930public class DateUtilsTest {
    30 
    3131    /**
    32      * Set the timezone and timeout.
    33      * <p>
    34      * Timeouts need to be disabled because we change the time zone.
    35      */
    36     @RegisterExtension
    37     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().i18n().preferences();
    39 
    40     /**
    4132     * Tests that {@code DateUtils} satisfies utility class criteria.
    4233     * @throws ReflectiveOperationException if an error occurs
    4334     */