Changeset 18893 in josm for trunk/test/functional


Ignore:
Timestamp:
2023-11-02T13:14:51+01:00 (10 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.

File:
1 edited

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()));
Note: See TracChangeset for help on using the changeset viewer.