Changeset 18893 in josm


Ignore:
Timestamp:
2023-11-02T13:14:51+01:00 (4 months ago)
Author:
taylor.smock
Message:

Fix #16567: Upgrade to JUnit 5

JOSMTestRules and JOSMTestFixture can reset the default JOSM profile, which can
be unexpected for new contributors. This updates all tests to use JUnit 5 and
the new JUnit 5 annotations.

This also renames MapCSSStyleSourceFilterTest to MapCSSStyleSourceFilterPerformanceTest
to match the naming convention for performance tests and fixes some lint issues.

This was tested by running all tests individually and together.

Location:
trunk/test
Files:
4 added
31 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    r17275 r18893  
    1212import java.io.FileInputStream;
    1313import java.io.FileNotFoundException;
    14 import java.io.FileOutputStream;
    1514import java.io.IOException;
    1615import java.io.OutputStreamWriter;
    1716import java.io.PrintWriter;
    1817import java.nio.charset.StandardCharsets;
     18import java.nio.file.Files;
    1919import java.text.MessageFormat;
    2020import java.util.HashSet;
     
    2626import org.junit.jupiter.api.BeforeEach;
    2727import org.junit.jupiter.api.Test;
    28 import org.openstreetmap.josm.JOSMFixture;
    2928import org.openstreetmap.josm.TestUtils;
    3029import org.openstreetmap.josm.data.APIDataSet;
     
    4342import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    4443import org.openstreetmap.josm.spi.preferences.Config;
     44import org.openstreetmap.josm.testutils.annotations.TestUser;
     45import org.openstreetmap.josm.tools.JosmRuntimeException;
    4546import org.openstreetmap.josm.tools.Logging;
    4647
     
    5253 */
    5354@SuppressFBWarnings(value = "CRLF_INJECTION_LOGS")
     55@org.openstreetmap.josm.testutils.annotations.OsmApi(org.openstreetmap.josm.testutils.annotations.OsmApi.APIType.DEV)
     56@TestUser
    5457class OsmServerBackreferenceReaderTest {
    5558    private static final Logger logger = Logger.getLogger(OsmServerBackreferenceReader.class.getName());
     
    7679        }
    7780        fail("Cannot find relation "+i);
    78         return null;
     81        throw new JosmRuntimeException("Cannot reach this point due to fail() above");
    7982    }
    8083
     
    166169        logger.info("initializing ...");
    167170
    168         JOSMFixture.createFunctionalTestFixture().init();
    169 
    170171        Config.getPref().put("osm-server.auth-method", "basic");
    171172
     
    197198        try (
    198199            PrintWriter pw = new PrintWriter(
    199                     new OutputStreamWriter(new FileOutputStream(dataSetCacheOutputFile), StandardCharsets.UTF_8)
     200                    new OutputStreamWriter(Files.newOutputStream(dataSetCacheOutputFile.toPath()), StandardCharsets.UTF_8)
    200201        )) {
    201202            logger.info(MessageFormat.format("caching test data set in ''{0}'' ...", dataSetCacheOutputFile.toString()));
  • trunk/test/performance/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSStyleSourceFilterPerformanceTest.java

    r18892 r18893  
    1919@Projection
    2020@Timeout(value = 15, unit = TimeUnit.MINUTES)
    21 class MapCSSStyleSourceFilterTest {
     21class MapCSSStyleSourceFilterPerformanceTest {
    2222
    2323    private static final int TEST_RULE_COUNT = 10000;
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/AbstractDownloadTaskTestParent.java

    r18106 r18893  
    66import static com.github.tomakehurst.wiremock.client.WireMock.urlEqualTo;
    77
    8 import org.junit.jupiter.api.extension.RegisterExtension;
    9 import org.openstreetmap.josm.testutils.JOSMTestRules;
    108import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
     9import org.openstreetmap.josm.testutils.annotations.HTTPS;
    1110
    1211import com.github.tomakehurst.wiremock.WireMockServer;
    13 
    14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1512
    1613/**
    1714 * Superclass of {@link DownloadGpsTaskTest}, {@link DownloadOsmTaskTest} and {@link DownloadNotesTaskTest}.
    1815 */
     16@BasicWiremock
     17@HTTPS
    1918public abstract class AbstractDownloadTaskTestParent {
    20 
    21     /**
    22      * Setup test.
    23      */
    24     @RegisterExtension
    25     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    26     JOSMTestRules test = new JOSMTestRules().https();
    27 
    2819    /**
    2920     * HTTP mock.
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadGpsTaskTest.java

    r18106 r18893  
    1010import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.data.gpx.GpxData;
    12 import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
    1312
    1413/**
    1514 * Unit tests for class {@link DownloadGpsTask}.
    1615 */
    17 @BasicWiremock
    1816class DownloadGpsTaskTest extends AbstractDownloadTaskTestParent {
    1917
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadNotesTaskTest.java

    r18106 r18893  
    1010import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.data.osm.NoteData;
    12 import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
    1312
    1413/**
    1514 * Unit tests for class {@link DownloadNotesTask}.
    1615 */
    17 @BasicWiremock
    1816class DownloadNotesTaskTest extends AbstractDownloadTaskTestParent {
    1917
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/DownloadOsmTaskTest.java

    r18106 r18893  
    1010import org.junit.jupiter.api.Test;
    1111import org.openstreetmap.josm.data.osm.DataSet;
    12 import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
    1312
    1413/**
    1514 * Unit tests for class {@link DownloadOsmTask}.
    1615 */
    17 @BasicWiremock
    1816class DownloadOsmTaskTest extends AbstractDownloadTaskTestParent {
    1917
  • trunk/test/unit/org/openstreetmap/josm/actions/downloadtasks/PluginDownloadTaskTest.java

    r18106 r18893  
    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.Preferences;
     
    1918import org.openstreetmap.josm.plugins.PluginDownloadTask;
    2019import org.openstreetmap.josm.plugins.PluginInformation;
    21 import org.openstreetmap.josm.testutils.JOSMTestRules;
    22 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    23 import org.openstreetmap.josm.testutils.annotations.BasicWiremock;
     20import org.openstreetmap.josm.testutils.annotations.AssumeRevision;
    2421import org.openstreetmap.josm.tools.Utils;
    25 
    26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2722
    2823/**
    2924 * Unit tests for class {@link PluginDownloadTask}.
    3025 */
    31 @BasicWiremock
    32 @BasicPreferences
     26@AssumeRevision("Revision: 8000\n")
    3327class PluginDownloadTaskTest extends AbstractDownloadTaskTestParent {
    3428    protected String pluginPath;
    35 
    36     /**
    37      * Setup test.
    38      */
    39     @RegisterExtension
    40     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    41     public JOSMTestRules testRule = new JOSMTestRules().https().assumeRevision(
    42         "Revision: 8000\n"
    43     );
    4429
    4530    @Override
  • trunk/test/unit/org/openstreetmap/josm/data/oauth/SignpostAdaptersTest.java

    r17275 r18893  
    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.HTTPS;
    1918import org.openstreetmap.josm.tools.HttpClient;
    2019
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2220import net.trajano.commons.testing.UtilityClassTestUtil;
    2321
     
    2523 * Unit tests for class {@link SignpostAdapters}.
    2624 */
     25@HTTPS
    2726class 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();
    3527
    3628    private static HttpClient newClient() throws MalformedURLException {
  • trunk/test/unit/org/openstreetmap/josm/data/validation/routines/DomainValidatorTestIT.java

    r18691 r18893  
    4646import java.util.regex.Pattern;
    4747
    48 import org.junit.jupiter.api.extension.RegisterExtension;
    4948import org.junit.jupiter.api.Test;
    50 import org.openstreetmap.josm.testutils.JOSMTestRules;
     49import org.openstreetmap.josm.testutils.annotations.HTTPS;
    5150import org.openstreetmap.josm.tools.Logging;
    5251
     
    5857 * @version $Revision: 1723861 $
    5958 */
     59@HTTPS
    6060class DomainValidatorTestIT {
    61 
    62     /**
    63      * Setup rule
    64      */
    65     @RegisterExtension
    66     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    67     public JOSMTestRules test = new JOSMTestRules().https();
    68 
    6961    /**
    7062     * Download and process local copy of http://data.iana.org/TLD/tlds-alpha-by-domain.txt
  • trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

    r18690 r18893  
    3535import javax.swing.plaf.metal.MetalLookAndFeel;
    3636
    37 import mockit.Mock;
    38 import mockit.MockUp;
    3937import org.awaitility.Awaitility;
    4038import org.awaitility.Durations;
    4139import org.junit.jupiter.api.Test;
    42 import org.junit.jupiter.api.extension.RegisterExtension;
     40import org.junit.jupiter.api.Timeout;
    4341import org.openstreetmap.josm.TestUtils;
    4442import org.openstreetmap.josm.actions.JosmAction;
     
    5755import org.openstreetmap.josm.plugins.PluginListParser;
    5856import org.openstreetmap.josm.spi.preferences.Config;
    59 import org.openstreetmap.josm.testutils.JOSMTestRules;
     57import org.openstreetmap.josm.testutils.annotations.HTTPS;
     58import org.openstreetmap.josm.testutils.annotations.Main;
     59import org.openstreetmap.josm.testutils.annotations.OsmApi;
     60import org.openstreetmap.josm.testutils.annotations.Projection;
    6061import org.openstreetmap.josm.tools.Logging;
    6162import org.openstreetmap.josm.tools.PlatformManager;
    6263import org.openstreetmap.josm.tools.Shortcut;
     64import org.openstreetmap.josm.tools.bugreport.BugReportQueue;
    6365
    6466import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    65 import org.openstreetmap.josm.tools.bugreport.BugReportQueue;
     67import mockit.Mock;
     68import mockit.MockUp;
    6669
    6770/**
    6871 * Unit tests of {@link MainApplication} class.
    6972 */
     73@HTTPS
     74@Main
     75@OsmApi(OsmApi.APIType.DEV)
     76@Projection
     77@Timeout(20)
    7078public class MainApplicationTest {
    71 
    72     /**
    73      * Setup test.
    74      */
    75     @RegisterExtension
    76     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    77     public JOSMTestRules test = new JOSMTestRules().main().projection().https().devAPI().timeout(20000);
    78 
    7979    /**
    8080     * Make sure {@link MainApplication#contentPanePrivate} is initialized.
     
    249249    void testPostConstructorProcessCmdLineEmpty() {
    250250        // Check the method accepts no arguments
    251         MainApplication.postConstructorProcessCmdLine(new ProgramArguments());
     251        assertDoesNotThrow(() -> MainApplication.postConstructorProcessCmdLine(new ProgramArguments()));
    252252    }
    253253
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/MinimapDialogTest.java

    r18694 r18893  
    2828import javax.swing.JPopupMenu;
    2929
    30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3130import org.awaitility.Awaitility;
    32 import org.junit.Before;
    33 import org.junit.Rule;
    34 import org.junit.Test;
     31import org.junit.jupiter.api.Test;
    3532import org.openstreetmap.josm.TestUtils;
    3633import org.openstreetmap.josm.data.Bounds;
    3734import org.openstreetmap.josm.data.DataSource;
    38 import org.openstreetmap.josm.data.SystemOfMeasurement;
    3935import org.openstreetmap.josm.data.imagery.ImageryInfo;
    4036import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
     
    5248import org.openstreetmap.josm.spi.preferences.Config;
    5349import org.openstreetmap.josm.testutils.ImagePatternMatching;
    54 import org.openstreetmap.josm.testutils.JOSMTestRules;
     50import org.openstreetmap.josm.testutils.annotations.FakeImagery;
     51import org.openstreetmap.josm.testutils.annotations.Main;
     52import org.openstreetmap.josm.testutils.annotations.MeasurementSystem;
     53import org.openstreetmap.josm.testutils.annotations.Projection;
    5554
    5655/**
    5756 * Unit tests of {@link MinimapDialog} class.
    5857 */
    59 public class MinimapDialogTest {
    60 
    61     /**
    62      * Setup tests
    63      */
    64     @Rule
    65     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    66     public JOSMTestRules josmTestRules = new JOSMTestRules().main().projection().fakeImagery();
    67 
    68     @Before
    69     public void beforeAll() {
    70         // Needed since testShowDownloadedAreaLayerSwitching expects the measurement to be imperial
    71         SystemOfMeasurement.setSystemOfMeasurement(SystemOfMeasurement.IMPERIAL);
    72     }
    73 
     58@FakeImagery
     59@Main
     60@Projection
     61// Needed since testShowDownloadedAreaLayerSwitching expects the measurement to be imperial
     62@MeasurementSystem("Imperial")
     63class MinimapDialogTest {
    7464    /**
    7565     * Unit test of {@link MinimapDialog} class.
    7666     */
    7767    @Test
    78     public void testMinimapDialog() {
     68    void testMinimapDialog() {
    7969        MinimapDialog dlg = new MinimapDialog();
    8070        dlg.showDialog();
     
    206196     */
    207197    @Test
    208     public void testSourceSwitching() {
     198    void testSourceSwitching() {
    209199        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    210200        // (not that there's a data layer for it to use)
     
    252242     */
    253243    @Test
    254     public void testRefreshSourcesRetainsSelection() {
     244    void testRefreshSourcesRetainsSelection() {
    255245        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    256246        // (not that there's a data layer for it to use)
     
    289279     */
    290280    @Test
    291     public void testRemovedSourceStillSelected() {
     281    void testRemovedSourceStillSelected() {
    292282        // relevant prefs starting out empty, should choose the first source and have shown download area enabled
    293283        // (not that there's a data layer for it to use)
     
    321311     */
    322312    @Test
    323     public void testTileSourcesFromCurrentLayers() {
     313    void testTileSourcesFromCurrentLayers() {
    324314        // relevant prefs starting out empty, should choose the first (ImageryLayerInfo) source and have shown download area enabled
    325315        // (not that there's a data layer for it to use)
     
    454444     */
    455445    @Test
    456     public void testSourcePrefObeyed() {
     446    void testSourcePrefObeyed() {
    457447        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    458448
     
    480470     */
    481471    @Test
    482     public void testSourcePrefInvalid() {
     472    void testSourcePrefInvalid() {
    483473        Config.getPref().put("slippy_map_chooser.mapstyle", "Hooloovoo Tiles");
    484474
     
    501491     */
    502492    @Test
    503     public void testViewportAspectRatio() {
     493    void testViewportAspectRatio() {
    504494        // Add a test layer to the layer manager to get the MapFrame & MapView
    505495        MainApplication.getLayerManager().addLayer(new TestLayer());
     
    640630     */
    641631    @Test
    642     public void testShowDownloadedArea() {
     632    void testShowDownloadedArea() {
    643633        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    644634        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", false);
     
    798788     */
    799789    @Test
    800     public void testShowDownloadedAreaLayerSwitching() {
     790    void testShowDownloadedAreaLayerSwitching() {
    801791        Config.getPref().put("slippy_map_chooser.mapstyle", "Green Tiles");
    802792        Config.getPref().putBoolean("slippy_map_chooser.show_downloaded_area", true);
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/layer/CycleLayerActionTest.java

    r18690 r18893  
    55import static org.openstreetmap.josm.tools.I18n.tr;
    66
    7 import org.junit.Before;
    8 import org.junit.Rule;
    9 import org.junit.Test;
     7import org.junit.jupiter.api.BeforeEach;
     8import org.junit.jupiter.api.Test;
    109import org.openstreetmap.josm.data.imagery.ImageryInfo;
    1110import org.openstreetmap.josm.data.imagery.ImageryLayerInfo;
     
    1514import org.openstreetmap.josm.gui.layer.MainLayerManager;
    1615import org.openstreetmap.josm.gui.layer.OsmDataLayer;
    17 import org.openstreetmap.josm.testutils.JOSMTestRules;
    18 
    19 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     16import org.openstreetmap.josm.testutils.annotations.FakeImagery;
     17import org.openstreetmap.josm.testutils.annotations.Main;
     18import org.openstreetmap.josm.testutils.annotations.Projection;
    2019
    2120/**
     
    2423 * @author Taylor Smock
    2524 */
    26 public class CycleLayerActionTest {
    27     /** Layers need a projection */
    28     @Rule
    29     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    30     public JOSMTestRules test = new JOSMTestRules().main().preferences().projection().fakeImagery();
    31 
     25@FakeImagery
     26@Main
     27@Projection
     28class CycleLayerActionTest {
    3229    private CycleLayerDownAction cycleDown;
    3330    private CycleLayerUpAction cycleUp;
     
    3734     * Set up common items (make layers, etc.)
    3835     */
    39     @Before
    40     public void setUp() {
     36    @BeforeEach
     37    void setUp() {
    4138        cycleDown = new CycleLayerDownAction();
    4239        cycleUp = new CycleLayerUpAction();
     
    5148     */
    5249    @Test
    53     public void testDownBottom() {
     50    void testDownBottom() {
    5451        manager.setActiveLayer(manager.getLayers().get(0));
    5552        cycleDown.actionPerformed(null);
     
    6158     */
    6259    @Test
    63     public void testUpTop() {
     60    void testUpTop() {
    6461        manager.setActiveLayer(manager.getLayers().get(manager.getLayers().size() - 1));
    6562        cycleUp.actionPerformed(null);
     
    7168     */
    7269    @Test
    73     public void testDown() {
     70    void testDown() {
    7471        manager.setActiveLayer(manager.getLayers().get(3));
    7572        cycleDown.actionPerformed(null);
     
    8178     */
    8279    @Test
    83     public void testUp() {
     80    void testUp() {
    8481        manager.setActiveLayer(manager.getLayers().get(3));
    8582        cycleUp.actionPerformed(null);
     
    9188     */
    9289    @Test
    93     public void testNoLayers() {
     90    void testNoLayers() {
    9491        manager.getLayers().forEach(manager::removeLayer);
    9592        cycleUp.actionPerformed(null);
     
    10299     */
    103100    @Test
    104     public void testWithAerialImagery() {
     101    void testWithAerialImagery() {
    105102        final ImageryInfo magentaTilesInfo = ImageryLayerInfo.instance.getLayers().stream()
    106103                .filter(i -> i.getName().equals("Magenta Tiles")).findAny().get();
  • trunk/test/unit/org/openstreetmap/josm/gui/help/HelpBrowserTest.java

    r17121 r18893  
    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;
     
    1818import org.openstreetmap.josm.tools.PlatformManager;
    1919
    20 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2120import mockit.Expectations;
    2221import mockit.Injectable;
     
    2625 * Unit tests of {@link HelpBrowser} class.
    2726 */
     27@FullPreferences
     28@HTTPS
    2829class HelpBrowserTest {
    2930
     
    3132    static final String URL_2 = "https://josm.openstreetmap.de/wiki/Introduction";
    3233    static final String URL_3 = "https://josm.openstreetmap.de/javadoc";
    33 
    34     /**
    35      * Setup tests
    36      */
    37     @RegisterExtension
    38     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    39     static JOSMTestRules test = new JOSMTestRules().preferences().https();
    4034
    4135    static IHelpBrowser newHelpBrowser() {
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/GpxLayerTest.java

    r18690 r18893  
    2323import org.junit.jupiter.api.BeforeEach;
    2424import org.junit.jupiter.api.Test;
    25 import org.junit.jupiter.api.extension.RegisterExtension;
    2625import org.openstreetmap.josm.TestUtils;
    2726import org.openstreetmap.josm.data.gpx.GpxData;
     
    3635import org.openstreetmap.josm.gui.widgets.HtmlPanel;
    3736import org.openstreetmap.josm.io.GpxReaderTest;
    38 import org.openstreetmap.josm.testutils.JOSMTestRules;
     37import org.openstreetmap.josm.testutils.annotations.I18n;
     38import org.openstreetmap.josm.testutils.annotations.Main;
     39import org.openstreetmap.josm.testutils.annotations.MeasurementSystem;
     40import org.openstreetmap.josm.testutils.annotations.Projection;
    3941import org.openstreetmap.josm.tools.date.DateUtils;
    4042import org.xml.sax.SAXException;
    41 
    42 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    4343
    4444/**
    4545 * Unit tests of {@link GpxLayer} class.
    4646 */
     47@I18n
     48@Main
     49@MeasurementSystem
     50@Projection
    4751public class GpxLayerTest {
    48 
    49     /**
    50      * Setup tests
    51      */
    52     @RegisterExtension
    53     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    54     public JOSMTestRules test = new JOSMTestRules().main().projection().i18n().metricSystem();
    55 
    5652    /**
    5753     * Setup test.
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/MainLayerManagerTest.java

    r18394 r18893  
    1313import java.util.logging.LogRecord;
    1414
    15 import org.junit.jupiter.api.BeforeAll;
    1615import org.junit.jupiter.api.BeforeEach;
    1716import org.junit.jupiter.api.Test;
    18 import org.openstreetmap.josm.JOSMFixture;
    1917import org.openstreetmap.josm.data.osm.DataSet;
    2018import org.openstreetmap.josm.gui.layer.MainLayerManager.ActiveLayerChangeEvent;
     
    6260    protected static class LoggingHandler extends Handler {
    6361
    64         private List<LogRecord> records = new ArrayList<>();
     62        private final List<LogRecord> records = new ArrayList<>();
    6563
    6664        @Override
     
    7977        }
    8078
    81     }
    82 
    83     @BeforeAll
    84     public static void setUpClass() {
    85         JOSMFixture.createUnitTestFixture().init();
    8679    }
    8780
     
    153146        CapturingActiveLayerChangeListener listener2 = new CapturingActiveLayerChangeListener();
    154147        layerManagerWithActive.addAndFireActiveLayerChangeListener(listener2);
    155         assertSame(listener2.lastEvent.getPreviousActiveLayer(), null);
    156         assertSame(listener2.lastEvent.getPreviousDataLayer(), null);
     148        assertNull(listener2.lastEvent.getPreviousActiveLayer());
     149        assertNull(listener2.lastEvent.getPreviousDataLayer());
    157150
    158151        layerManagerWithActive.setActiveLayer(layer1);
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/DownloadWmsAlongTrackActionTest.java

    r18690 r18893  
    1111
    1212import org.awaitility.Awaitility;
    13 import org.junit.Rule;
    14 import org.junit.Test;
     13import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.Timeout;
     15import org.openstreetmap.josm.TestUtils;
    1516import org.openstreetmap.josm.actions.MergeLayerActionTest.MergeLayerExtendedDialogMocker;
    1617import org.openstreetmap.josm.data.gpx.GpxData;
     
    1920import org.openstreetmap.josm.gui.layer.TMSLayer;
    2021import org.openstreetmap.josm.gui.layer.gpx.DownloadWmsAlongTrackAction.PrecacheWmsTask;
    21 import org.openstreetmap.josm.TestUtils;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
    23 import org.openstreetmap.josm.testutils.TileSourceRule;
     22import org.openstreetmap.josm.testutils.annotations.FakeImagery;
     23import org.openstreetmap.josm.testutils.annotations.Main;
     24import org.openstreetmap.josm.testutils.annotations.Projection;
    2425import org.openstreetmap.josm.testutils.mockers.JOptionPaneSimpleMocker;
    25 
    26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2726
    2827/**
    2928 * Unit tests of {@link DownloadWmsAlongTrackAction} class.
    3029 */
    31 public class DownloadWmsAlongTrackActionTest {
    32 
    33     /**
    34      * Setup test.
    35      */
    36     @Rule
    37     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().main().projection().fakeImagery().timeout(20000);
     30@FakeImagery
     31@Main
     32@Projection
     33@Timeout(20)
     34class DownloadWmsAlongTrackActionTest {
    3935
    4036    /**
     
    4238     */
    4339    @Test
    44     public void testNoLayer() {
     40    void testNoLayer() {
    4541        TestUtils.assumeWorkingJMockit();
    4642        final JOptionPaneSimpleMocker jopsMocker = new JOptionPaneSimpleMocker(
     
    6157     */
    6258    @Test
    63     public void testTMSLayer() throws Exception {
     59    void testTMSLayer(FakeImagery.FakeImageryWireMockExtension fakeImageryWireMockExtension) throws Exception {
    6460        TestUtils.assumeWorkingJMockit();
    6561        final MergeLayerExtendedDialogMocker edMocker = new MergeLayerExtendedDialogMocker();
    6662        edMocker.getMockResultMap().put("Please select the imagery layer.", "Download");
    6763
    68         final TileSourceRule tileSourceRule = this.test.getTileSourceRule();
    69 
    7064        final TMSLayer layer = new TMSLayer(
    71             tileSourceRule.getSourcesList().get(0).getImageryInfo(tileSourceRule.port())
     65                fakeImageryWireMockExtension.getSourcesList().get(0).getImageryInfo(fakeImageryWireMockExtension.getRuntimeInfo().getHttpPort())
    7266        );
    7367        try {
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/WebMarkerTest.java

    r17275 r18893  
    77
    88import org.junit.jupiter.api.Test;
    9 import org.junit.jupiter.api.extension.RegisterExtension;
    109import org.openstreetmap.josm.TestUtils;
    1110import org.openstreetmap.josm.data.coor.LatLon;
    1211import org.openstreetmap.josm.data.gpx.GpxData;
    1312import org.openstreetmap.josm.data.gpx.WayPoint;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
     13import org.openstreetmap.josm.testutils.annotations.FullPreferences;
     14import org.openstreetmap.josm.testutils.annotations.HTTPS;
     15import org.openstreetmap.josm.tools.PlatformHook;
    1516import org.openstreetmap.josm.tools.PlatformManager;
    16 import org.openstreetmap.josm.tools.PlatformHook;
    17 
    18 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    1917
    2018import mockit.Expectations;
     
    2523 * Unit tests of {@link WebMarker} class.
    2624 */
     25@FullPreferences
     26@HTTPS
    2727class WebMarkerTest {
    28 
    29     /**
    30      * Setup tests
    31      */
    32     @RegisterExtension
    33     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    34     public JOSMTestRules test = new JOSMTestRules().preferences().https();
    35 
    3628    /**
    3729     * Unit test of {@link WebMarker#WebMarker}.
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/MapCSSParserTestIT.java

    r17275 r18893  
    44import org.junit.jupiter.api.Disabled;
    55import org.junit.jupiter.api.Test;
    6 import org.junit.jupiter.api.extension.RegisterExtension;
    76import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.MapCSSParser;
    8 import org.openstreetmap.josm.testutils.JOSMTestRules;
    9 
    10 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     7import org.openstreetmap.josm.testutils.annotations.HTTPS;
     8import org.openstreetmap.josm.testutils.annotations.Projection;
    119
    1210/**
    1311 * Integration tests of {@link MapCSSParser}.
    1412 */
     13@HTTPS
     14@Projection
    1515class MapCSSParserTestIT {
    16 
    17     /**
    18      * Setup rule
    19      */
    20     @RegisterExtension
    21     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    22     public JOSMTestRules test = new JOSMTestRules().https().projection();
    23 
    2416    /**
    2517     * Checks Kothic stylesheets
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

    r18870 r18893  
    3030import org.junit.jupiter.api.BeforeAll;
    3131import org.junit.jupiter.api.Disabled;
    32 import org.junit.jupiter.api.extension.RegisterExtension;
     32import org.junit.jupiter.api.Timeout;
    3333import org.junit.jupiter.api.parallel.Execution;
    3434import org.junit.jupiter.api.parallel.ExecutionMode;
     
    6666import org.openstreetmap.josm.io.imagery.ApiKeyProvider;
    6767import org.openstreetmap.josm.io.imagery.WMSImagery.WMSGetCapabilitiesException;
    68 import org.openstreetmap.josm.testutils.JOSMTestRules;
     68import org.openstreetmap.josm.testutils.annotations.HTTPS;
     69import org.openstreetmap.josm.testutils.annotations.I18n;
     70import org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids;
    6971import org.openstreetmap.josm.tools.HttpClient;
    7072import org.openstreetmap.josm.tools.HttpClient.Response;
     
    7274import org.openstreetmap.josm.tools.Utils;
    7375
    74 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    75 
    7676/**
    7777 * Integration tests of {@link ImageryPreference} class.
    7878 */
     79@HTTPS
     80@I18n
     81@org.openstreetmap.josm.testutils.annotations.Projection
     82@ProjectionNadGrids
     83@Timeout(value = 40, unit = TimeUnit.MINUTES)
    7984public class ImageryPreferenceTestIT {
    8085
     
    8287    private static final LatLon GREENWICH = new LatLon(51.47810, -0.00170);
    8388    private static final int DEFAULT_ZOOM = 12;
    84 
    85     /**
    86      * Setup rule
    87      */
    88     @RegisterExtension
    89     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    90     static JOSMTestRules test = new JOSMTestRules().https().i18n().preferences().projection().projectionNadGrids()
    91                                                    .timeout((int) TimeUnit.MINUTES.toMillis(40));
    9289
    9390    /** Entry to test */
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java

    r17677 r18893  
    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;
     
    2223import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction;
    2324import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.AssignmentInstruction;
    24 import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase;
    2525import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule;
    2626import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource;
    27 import org.openstreetmap.josm.testutils.JOSMTestRules;
     27import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase;
     28import org.openstreetmap.josm.testutils.annotations.HTTPS;
    2829import org.openstreetmap.josm.tools.ImageProvider;
    29 
    30 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    3130
    3231/**
    3332 * Integration tests of {@link MapPaintPreference} class.
    3433 */
     34@HTTPS
     35@Timeout(value = 15, unit = TimeUnit.MINUTES)
    3536class MapPaintPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    36 
    37     /**
    38      * Setup rule
    39      */
    40     @RegisterExtension
    41     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    42     public static JOSMTestRules test = new JOSMTestRules().https().timeout(15000*60).parameters();
    43 
    4437    /**
    4538     * Setup test
     
    6659     * @param url URL
    6760     * @param source source entry to test
    68      * @throws Exception in case of error
    6961     */
    7062    @ParameterizedTest(name = "{0} - {1}")
    7163    @MethodSource("data")
    72     void testStyleValidity(String displayName, String url, ExtendedSourceEntry source) throws Exception {
     64    void testStyleValidity(String displayName, String url, ExtendedSourceEntry source) {
    7365        assumeFalse(isIgnoredSubstring(source, source.url));
    7466        StyleSource style = MapPaintStyles.addStyle(source);
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java

    r17695 r18893  
    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;
     
    2829import org.openstreetmap.josm.gui.tagging.presets.items.Link;
    2930import org.openstreetmap.josm.spi.preferences.Config;
    30 import org.openstreetmap.josm.testutils.JOSMTestRules;
     31import org.openstreetmap.josm.testutils.annotations.HTTPS;
    3132import org.openstreetmap.josm.tools.HttpClient;
    3233import org.openstreetmap.josm.tools.HttpClient.Response;
     
    3536import org.xml.sax.SAXException;
    3637
    37 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    38 
    3938/**
    4039 * Integration tests of {@link TaggingPresetPreference} class.
    4140 */
     41@HTTPS
     42@Timeout(value = 20, unit = TimeUnit.MINUTES)
    4243class TaggingPresetPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    43 
    44     /**
    45      * Setup rule
    46      */
    47     @RegisterExtension
    48     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    49     public static JOSMTestRules test = new JOSMTestRules().https().timeout(10000*120).parameters();
    50 
    5144    /**
    5245     * Setup test
     
    7871     * @param url URL
    7972     * @param source source entry to test
    80      * @throws Exception in case of error
    8173     */
    8274    @ParameterizedTest(name = "{0} - {1}")
    8375    @MethodSource("data")
    84     void testPresetsValidity(String displayName, String url, ExtendedSourceEntry source) throws Exception {
     76    void testPresetsValidity(String displayName, String url, ExtendedSourceEntry source) {
    8577        assumeFalse(isIgnoredSubstring(source, source.url));
    8678        List<String> ignoredErrors = new ArrayList<>();
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java

    r17677 r18893  
    1414
    1515import org.junit.jupiter.api.BeforeAll;
    16 import org.junit.jupiter.api.extension.RegisterExtension;
     16import org.junit.jupiter.api.Timeout;
    1717import org.junit.jupiter.api.parallel.Execution;
    1818import org.junit.jupiter.api.parallel.ExecutionMode;
     
    2424import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult;
    2525import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase;
    26 import org.openstreetmap.josm.testutils.JOSMTestRules;
    27 
    28 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     26import org.openstreetmap.josm.testutils.annotations.HTTPS;
    2927
    3028/**
    3129 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
    3230 */
     31@HTTPS
     32@Timeout(20)
    3333class ValidatorTagCheckerRulesPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
    34 
    35     /**
    36      * Setup rule
    37      */
    38     @RegisterExtension
    39     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    40     static JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);
    41 
    4234    /**
    4335     * Setup test
  • trunk/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTestIT.java

    r18690 r18893  
    1313import javax.net.ssl.SSLHandshakeException;
    1414
    15 import org.junit.ClassRule;
    1615import org.junit.jupiter.api.BeforeAll;
    1716import org.junit.jupiter.api.Test;
     17import org.junit.jupiter.api.Timeout;
    1818import org.openstreetmap.josm.TestUtils;
    19 import org.openstreetmap.josm.testutils.JOSMTestRules;
    20 
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     19import org.openstreetmap.josm.testutils.annotations.HTTPS;
    2220
    2321/**
    2422 * Integration tests of {@link CertificateAmendment} class.
    2523 */
     24@HTTPS
     25@Timeout(20)
    2626class 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 
    3527    private static final List<String> errorsToIgnore = new ArrayList<>();
    3628
  • trunk/test/unit/org/openstreetmap/josm/io/NetworkManagerTest.java

    r17275 r18893  
    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;
    15 
    16 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     13import org.openstreetmap.josm.testutils.annotations.HTTPS;
     14import org.openstreetmap.josm.testutils.annotations.Main;
     15import org.openstreetmap.josm.testutils.annotations.OsmApi;
     16import org.openstreetmap.josm.testutils.annotations.Projection;
    1717
    1818/**
    1919 * Unit tests of {@link NetworkManager} class.
    2020 */
     21@HTTPS
     22@Main
     23@OsmApi(OsmApi.APIType.DEV)
     24@Projection
    2125class NetworkManagerTest {
    22 
    23     /**
    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 
    3026    /**
    3127     * Unit test of {@link NetworkManager#addNetworkError},
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java

    r17698 r18893  
    1414import org.junit.jupiter.api.BeforeEach;
    1515import org.junit.jupiter.api.Test;
    16 import org.junit.jupiter.api.extension.RegisterExtension;
    1716import org.openstreetmap.josm.spi.preferences.Config;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.AssertionsInEDT;
     18import org.openstreetmap.josm.testutils.annotations.HTTPS;
    1919import org.openstreetmap.josm.tools.Utils;
    20 
    21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2220
    2321/**
    2422 * Unit tests for Remote Control
    2523 */
     24@AssertionsInEDT
     25@HTTPS
    2626class RemoteControlTest {
    2727
    2828    private String httpBase;
    29 
    30     /**
    31      * Setup test.
    32      */
    33     @RegisterExtension
    34     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    35     public JOSMTestRules test = new JOSMTestRules().preferences().https().assertionsInEDT();
    3629
    3730    /**
     
    6558        HttpURLConnection connection = (HttpURLConnection) new URL(url).openConnection();
    6659        connection.connect();
    67         assertEquals(connection.getResponseCode(), HttpURLConnection.HTTP_BAD_REQUEST);
     60        assertEquals(HttpURLConnection.HTTP_BAD_REQUEST, connection.getResponseCode());
    6861        try (InputStream is = connection.getErrorStream()) {
    6962            String responseBody = new String(Utils.readBytesFromStream(is), StandardCharsets.UTF_8);
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

    r18799 r18893  
    2929import org.junit.jupiter.api.Test;
    3030import org.junit.jupiter.api.Timeout;
    31 import org.junit.jupiter.api.extension.RegisterExtension;
    3231import org.junit.platform.commons.util.ReflectionUtils;
    3332import org.openstreetmap.josm.TestUtils;
     
    4140import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    4241import org.openstreetmap.josm.spi.preferences.Config;
    43 import org.openstreetmap.josm.testutils.JOSMTestRules;
    4442import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     43import org.openstreetmap.josm.testutils.annotations.HTTPS;
    4544import org.openstreetmap.josm.testutils.annotations.Main;
    4645import org.openstreetmap.josm.testutils.annotations.Projection;
     
    5049import org.openstreetmap.josm.tools.Utils;
    5150
    52 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    53 
    5451/**
    5552 * Integration tests of {@link PluginHandler} class.
    5653 */
    5754@BasicPreferences
     55@HTTPS
    5856@Main
    5957@Projection
     
    6361
    6462    private static final List<String> errorsToIgnore = new ArrayList<>();
    65     /**
    66      * Setup test.
    67      */
    68     @RegisterExtension
    69     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    70     public static JOSMTestRules test = new JOSMTestRules().https();
    7163
    7264    /**
  • trunk/test/unit/org/openstreetmap/josm/spi/lifecycle/LifecycleTest.java

    r17275 r18893  
    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;
    10 
    11 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     8import org.openstreetmap.josm.testutils.annotations.HTTPS;
     9import org.openstreetmap.josm.testutils.annotations.Main;
     10import org.openstreetmap.josm.testutils.annotations.OsmApi;
     11import org.openstreetmap.josm.testutils.annotations.Projection;
    1212
    1313/**
    1414 * Unit tests of {@link Lifecycle} class.
    1515 */
     16@HTTPS
     17@Main
     18@OsmApi(OsmApi.APIType.DEV)
     19@Projection
    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
  • trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java

    r18870 r18893  
    5858import org.openstreetmap.josm.gui.preferences.imagery.ImageryPreferenceTestIT;
    5959import org.openstreetmap.josm.gui.util.GuiHelper;
    60 import org.openstreetmap.josm.io.CertificateAmendment;
    6160import org.openstreetmap.josm.io.OsmApi;
    6261import org.openstreetmap.josm.io.OsmApiInitializationException;
     
    6564import org.openstreetmap.josm.spi.preferences.Config;
    6665import org.openstreetmap.josm.spi.preferences.Setting;
     66import org.openstreetmap.josm.testutils.annotations.HTTPS;
    6767import org.openstreetmap.josm.testutils.annotations.JosmDefaults;
    6868import org.openstreetmap.josm.testutils.annotations.MapPaintStyles;
     
    136136     * @param millis The timeout duration in milliseconds.
    137137     * @return this instance, for easy chaining
     138     * @see org.junit.jupiter.api.Timeout
    138139     */
    139140    public JOSMTestRules timeout(int millis) {
     
    145146     * Enable the use of default preferences.
    146147     * @return this instance, for easy chaining
     148     * @see org.openstreetmap.josm.testutils.annotations.BasicPreferences
     149     * @see org.openstreetmap.josm.testutils.annotations.FullPreferences
    147150     */
    148151    public JOSMTestRules preferences() {
     
    164167     * Enables the i18n module for this test in english.
    165168     * @return this instance, for easy chaining
     169     * @see org.openstreetmap.josm.testutils.annotations.I18n
    166170     */
    167171    public JOSMTestRules i18n() {
     
    173177     * @param language The language to use.
    174178     * @return this instance, for easy chaining
     179     * @see org.openstreetmap.josm.testutils.annotations.I18n
    175180     */
    176181    public JOSMTestRules i18n(String language) {
     
    183188     * @param revisionProperties mock contents of JOSM's {@code REVISION} properties file
    184189     * @return this instance, for easy chaining
     190     * @see org.openstreetmap.josm.testutils.annotations.AssumeRevision
    185191     */
    186192    public JOSMTestRules assumeRevision(final String revisionProperties) {
     
    192198     * Enable the dev.openstreetmap.org API for this test.
    193199     * @return this instance, for easy chaining
     200     * @see org.openstreetmap.josm.testutils.annotations.OsmApi.APIType#DEV
    194201     */
    195202    public JOSMTestRules devAPI() {
     
    202209     * Use the {@link FakeOsmApi} for testing.
    203210     * @return this instance, for easy chaining
     211     * @see org.openstreetmap.josm.testutils.annotations.OsmApi.APIType#FAKE
    204212     */
    205213    public JOSMTestRules fakeAPI() {
     
    211219     * Set up default projection (Mercator)
    212220     * @return this instance, for easy chaining
     221     * @see org.openstreetmap.josm.testutils.annotations.Projection
    213222     */
    214223    public JOSMTestRules projection() {
     
    220229     * Set up loading of NTV2 grit shift files to support projections that need them.
    221230     * @return this instance, for easy chaining
     231     * @see org.openstreetmap.josm.testutils.annotations.ProjectionNadGrids
    222232     */
    223233    public JOSMTestRules projectionNadGrids() {
     
    229239     * Set up HTTPS certificates
    230240     * @return this instance, for easy chaining
     241     * @see HTTPS
    231242     */
    232243    public JOSMTestRules https() {
     
    247258     * Allow the memory manager to contain items after execution of the test cases.
    248259     * @return this instance, for easy chaining
     260     * @see org.openstreetmap.josm.testutils.annotations.MemoryManagerLeaks
    249261     */
    250262    public JOSMTestRules memoryManagerLeaks() {
     
    256268     * Use map styles in this test.
    257269     * @return this instance, for easy chaining
     270     * @see MapPaintStyles
    258271     * @since 11777
    259272     */
     
    267280     * Use presets in this test.
    268281     * @return this instance, for easy chaining
     282     * @see TaggingPresets
    269283     * @since 12568
    270284     */
     
    278292     * Use boundaries dataset in this test.
    279293     * @return this instance, for easy chaining
     294     * @see Territories
    280295     * @since 12545
    281296     */
     
    300315     * Force metric measurement system.
    301316     * @return this instance, for easy chaining
     317     * @see org.openstreetmap.josm.testutils.annotations.MeasurementSystem
    302318     * @since 15400
    303319     */
     
    310326     * Re-raise AssertionErrors thrown in the EDT where they would have normally been swallowed.
    311327     * @return this instance, for easy chaining
     328     * @see org.openstreetmap.josm.testutils.annotations.AssertionsInEDT
    312329     */
    313330    public JOSMTestRules assertionsInEDT() {
     
    320337     *
    321338     * @return this instance, for easy chaining
     339     * @see org.openstreetmap.josm.testutils.annotations.AssertionsInEDT
    322340     */
    323341    public JOSMTestRules assertionsInEDT(final Runnable edtAssertionMockingRunnable) {
     
    330348     *
    331349     * @return this instance, for easy chaining
     350     * @see org.openstreetmap.josm.testutils.annotations.FakeImagery
    332351     */
    333352    public JOSMTestRules fakeImagery() {
     
    350369     *
    351370     * @return this instance, for easy chaining
     371     * @see org.openstreetmap.josm.testutils.annotations.FakeImagery
    352372     */
    353373    public JOSMTestRules fakeImagery(TileSourceRule tileSourceRule) {
     
    361381     *         global variables in this test.
    362382     * @return this instance, for easy chaining
     383     * @see org.openstreetmap.josm.testutils.annotations.Main
    363384     * @since 12557
    364385     */
     
    379400     *
    380401     * @return this instance, for easy chaining
     402     * @see org.openstreetmap.josm.testutils.annotations.AssertionsInEDT
    381403     */
    382404    public JOSMTestRules main(
     
    561583        if (useHttps) {
    562584            try {
    563                 CertificateAmendment.addMissingCertificates();
     585                new HTTPS.HTTPSExtension().beforeEach(null);
    564586            } catch (IOException | GeneralSecurityException ex) {
    565587                throw new JosmRuntimeException(ex);
  • trunk/test/unit/org/openstreetmap/josm/testutils/annotations/BasicWiremock.java

    r18106 r18893  
    88import java.lang.annotation.Documented;
    99import java.lang.annotation.ElementType;
     10import java.lang.annotation.Inherited;
    1011import java.lang.annotation.Retention;
    1112import java.lang.annotation.RetentionPolicy;
     
    5152 * @since 18106
    5253 */
     54@Inherited
    5355@Documented
    5456@Retention(RetentionPolicy.RUNTIME)
  • trunk/test/unit/org/openstreetmap/josm/testutils/annotations/JosmDefaults.java

    r18870 r18893  
    6565        @Override
    6666        public void afterEach(ExtensionContext context) throws Exception {
    67             MemoryManagerTest.resetState(false);
     67            MemoryManagerTest.resetState(AnnotationUtils.findFirstParentAnnotation(context, MemoryManagerLeaks.class).isPresent());
    6868
    6969            Window[] windows = Window.getWindows();
  • trunk/test/unit/org/openstreetmap/josm/tools/MemoryManagerTest.java

    r18690 r18893  
    22package org.openstreetmap.josm.tools;
    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;
     
    87import static org.junit.jupiter.api.Assertions.assertThrows;
    98import static org.junit.jupiter.api.Assertions.assertTrue;
     9import static org.junit.jupiter.api.Assertions.fail;
    1010
    1111import java.util.List;
    1212
    1313import org.junit.jupiter.api.Test;
    14 import org.junit.jupiter.api.extension.RegisterExtension;
    15 import org.openstreetmap.josm.testutils.JOSMTestRules;
     14import org.openstreetmap.josm.testutils.annotations.MemoryManagerLeaks;
    1615import org.openstreetmap.josm.tools.MemoryManager.MemoryHandle;
    1716import org.openstreetmap.josm.tools.MemoryManager.NotEnoughMemoryException;
    18 
    19 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2017
    2118/**
     
    2320 * @author Michael Zangl
    2421 */
     22@MemoryManagerLeaks
    2523public class MemoryManagerTest {
    26     /**
    27      * Base test environment
    28      */
    29     @RegisterExtension
    30     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    31     public JOSMTestRules test = new JOSMTestRules().memoryManagerLeaks();
    32 
    3324    /**
    3425     * Test {@link MemoryManager#allocateMemory(String, long, java.util.function.Supplier)}
  • trunk/test/unit/org/openstreetmap/josm/tools/PlatformHookWindowsTest.java

    r17688 r18893  
    22package org.openstreetmap.josm.tools;
    33
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    45import static org.junit.jupiter.api.Assertions.assertEquals;
    56import static org.junit.jupiter.api.Assertions.assertFalse;
     
    1718import org.junit.jupiter.api.BeforeAll;
    1819import org.junit.jupiter.api.Test;
    19 import org.junit.jupiter.api.extension.RegisterExtension;
    2020import org.openstreetmap.josm.TestUtils;
    2121import org.openstreetmap.josm.spi.preferences.Config;
    22 import org.openstreetmap.josm.testutils.JOSMTestRules;
     22import org.openstreetmap.josm.testutils.annotations.HTTPS;
    2323
    24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2524import mockit.Expectations;
    2625import mockit.Mocked;
     
    2928 * Unit tests of {@link PlatformHookWindows} class.
    3029 */
     30@HTTPS
    3131class PlatformHookWindowsTest {
    32 
    33     /**
    34      * Setup tests
    35      */
    36     @RegisterExtension
    37     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    38     public JOSMTestRules test = new JOSMTestRules().preferences().https();
    39 
    4032    static PlatformHookWindows hook;
    4133
     
    5345    @Test
    5446    void testStartupHook() {
    55         hook.startupHook((a, b, c, d) -> System.out.println("java callback"), u -> System.out.println("webstart callback"));
     47        final PlatformHook.JavaExpirationCallback javaCallback = (a, b, c, d) -> System.out.println("java callback");
     48        final PlatformHook.WebStartMigrationCallback webstartCallback = u -> System.out.println("webstart callback");
     49        assertDoesNotThrow(() -> hook.startupHook(javaCallback, webstartCallback));
    5650    }
    5751
     
    7973    @Test
    8074    void testAfterPrefStartupHook() {
    81         hook.afterPrefStartupHook();
     75        assertDoesNotThrow(hook::afterPrefStartupHook);
    8276    }
    8377
     
    9690        }};
    9791
    98         hook.openUrl(Config.getUrls().getJOSMWebsite());
     92        assertDoesNotThrow(() -> hook.openUrl(Config.getUrls().getJOSMWebsite()));
    9993    }
    10094
     
    122116        }};
    123117
    124         hook.openUrl(Config.getUrls().getJOSMWebsite());
     118        assertDoesNotThrow(() -> hook.openUrl(Config.getUrls().getJOSMWebsite()));
    125119    }
    126120
     
    196190    @Test
    197191    void testInitSystemShortcuts() {
    198         hook.initSystemShortcuts();
     192        assertDoesNotThrow(hook::initSystemShortcuts);
    199193    }
    200194}
Note: See TracChangeset for help on using the changeset viewer.