Ignore:
Timestamp:
2023-03-21T14:49:10+01:00 (21 months ago)
Author:
taylor.smock
Message:

See #16567: Convert most plugin tests to JUnit 5

Location:
applications/editors/josm/plugins/opendata
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/test/unit/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModuleTest.java

    r35269 r36064  
    22package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertFalse;
    64
    7 import org.junit.Rule;
    8 import org.junit.Test;
    9 import org.openstreetmap.josm.testutils.JOSMTestRules;
     5import static org.junit.jupiter.api.Assertions.assertEquals;
     6import static org.junit.jupiter.api.Assertions.assertFalse;
     7
     8import org.junit.jupiter.api.Test;
     9import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1010
    1111/**
    1212 * Unit tests of {@link ToulouseModule} class.
    1313 */
    14 public class ToulouseModuleTest {
    15 
    16     /**
    17      * Setup test.
    18      */
    19     @Rule
    20     public JOSMTestRules rules = new JOSMTestRules().preferences();
    21 
     14@BasicPreferences
     15class ToulouseModuleTest {
    2216    @Test
    23     public void testHandlersConstruction() {
     17    void testHandlersConstruction() {
    2418        ToulouseModule module = new ToulouseModule(null);
    2519        assertFalse(module.getHandlers().isEmpty());
  • applications/editors/josm/plugins/opendata/modules/fr.toulouse/test/unit/org/openstreetmap/josm/plugins/opendata/modules/fr/toulouse/ToulouseModuleTestIT.java

    r35272 r36064  
    22package org.openstreetmap.josm.plugins.opendata.modules.fr.toulouse;
    33
    4 import static org.junit.Assert.assertTrue;
     4
     5import static org.junit.jupiter.api.Assertions.assertTrue;
    56
    67import java.io.IOException;
     
    89import java.util.TreeMap;
    910
    10 import org.junit.Rule;
    11 import org.junit.Test;
     11import org.junit.jupiter.api.Test;
     12import org.junit.jupiter.api.Timeout;
    1213import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
     14import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1415import org.openstreetmap.josm.tools.HttpClient;
    1516
     
    1718 * Integration tests of {@link ToulouseModule} class.
    1819 */
    19 public class ToulouseModuleTestIT {
    20 
    21     /**
    22      * Setup test.
    23      */
    24     @Rule
    25     public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(30_000);
    26 
     20@BasicPreferences
     21@Timeout(30)
     22class ToulouseModuleTestIT {
    2723    @Test
    28     public void testUrlValidity() throws IOException {
     24    void testUrlValidity() throws IOException {
    2925        Map<String, Integer> errors = new TreeMap<>();
    3026        for (AbstractDataSetHandler handler : new ToulouseModule(null).getNewlyInstanciatedHandlers()) {
     
    3430            }
    3531        }
    36         assertTrue(errors.toString(), errors.isEmpty());
     32        assertTrue(errors.isEmpty(), errors.toString());
    3733    }
    3834}
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/archive/ZipReaderTest.java

    r35899 r36064  
    33
    44import java.io.File;
    5 import java.io.FileInputStream;
    65import java.io.InputStream;
     6import java.nio.file.Files;
    77import java.nio.file.Path;
    88import java.util.Map.Entry;
     9import java.util.concurrent.TimeUnit;
    910
    1011import org.junit.jupiter.api.Test;
    11 import org.junit.jupiter.api.extension.RegisterExtension;
     12import org.junit.jupiter.api.Timeout;
    1213import org.openstreetmap.josm.data.osm.DataSet;
    1314import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    14 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1515import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     16import org.openstreetmap.josm.testutils.annotations.Projection;
    1617import org.openstreetmap.josm.tools.Logging;
    1718
     
    2021 */
    2122@BasicPreferences
     23@Projection
     24@Timeout(value = 10, unit = TimeUnit.MINUTES)
    2225class ZipReaderTest {
    23 
    24     /**
    25      * Setup test.
    26      */
    27     @RegisterExtension
    28     public JOSMTestRules rules = new JOSMTestRules().projection().noTimeout();
    29 
    3026    /**
    3127     * Test for various zip files reading
     
    3733            File zipfile = p.toFile();
    3834            Logging.info("Testing reading file "+zipfile.getPath());
    39             try (InputStream is = new FileInputStream(zipfile)) {
     35            try (InputStream is = Files.newInputStream(zipfile.toPath())) {
    4036                for (Entry<File, DataSet> entry : ZipReader.parseDataSets(is, null, null, false).entrySet()) {
    4137                    String name = entry.getKey().getName();
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/datasets/DataSetUpdaterTest.java

    r35899 r36064  
    22package org.openstreetmap.josm.plugins.opendata.core.io.datasets;
    33
     4import static org.junit.jupiter.api.Assertions.assertFalse;
     5import static org.junit.jupiter.api.Assertions.assertTrue;
     6
    47import java.io.File;
    5 import java.io.FileInputStream;
    68import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.util.concurrent.TimeUnit;
    711import java.util.function.Predicate;
    812
    913import org.junit.jupiter.api.Test;
     14import org.junit.jupiter.api.Timeout;
    1015import org.junit.jupiter.api.extension.RegisterExtension;
    1116import org.openstreetmap.josm.TestUtils;
     
    1722import org.openstreetmap.josm.testutils.JOSMTestRules;
    1823import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    19 
    20 import static org.junit.jupiter.api.Assertions.assertFalse;
    21 import static org.junit.jupiter.api.Assertions.assertTrue;
     24import org.openstreetmap.josm.testutils.annotations.Projection;
    2225
    2326/**
     
    2528 */
    2629@BasicPreferences
     30@Projection
     31@Timeout(value = 1, unit = TimeUnit.MINUTES)
    2732class DataSetUpdaterTest {
    2833
     
    3136     */
    3237    @RegisterExtension
    33     JOSMTestRules rules = new JOSMTestRules().projection().devAPI().timeout(60000);
     38    JOSMTestRules rules = new JOSMTestRules().devAPI();
    3439
    3540    /**
     
    4045    void testTicket11166() throws Exception {
    4146        File file = new File(TestUtils.getRegressionDataFile(11166, "raba760dissJosm.zip"));
    42         try (InputStream is = new FileInputStream(file)) {
     47        try (InputStream is = Files.newInputStream(file.toPath())) {
    4348            Predicate<? super Way> p = w -> w.getNodesCount() >= 0.9 * OsmApi.getOsmApi().getCapabilities().getMaxWayNodes();
    4449            DataSet ds = ZipReader.parseDataSet(is, null, null, false);
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/GmlReaderTest.java

    r35899 r36064  
    66
    77import java.io.File;
    8 import java.io.FileInputStream;
    98import java.io.InputStream;
     9import java.nio.file.Files;
     10import java.util.concurrent.TimeUnit;
    1011
    1112import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
     13import org.junit.jupiter.api.Timeout;
    1314import org.openstreetmap.josm.TestUtils;
    1415import org.openstreetmap.josm.data.osm.Node;
    15 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1616import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     17import org.openstreetmap.josm.testutils.annotations.Projection;
    1718
    1819/**
     
    2021 */
    2122@BasicPreferences
     23@Projection
     24@Timeout(value = 1, unit = TimeUnit.MINUTES)
    2225class GmlReaderTest {
    23 
    24     /**
    25      * Setup test.
    26      */
    27     @RegisterExtension
    28     JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);
    29 
    3026    /**
    3127     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/11624">#11624</a>
     
    3531    void testTicket11624() throws Exception {
    3632        File file = new File(TestUtils.getRegressionDataFile(11624, "temp3.gml"));
    37         try (InputStream is = new FileInputStream(file)) {
     33        try (InputStream is = Files.newInputStream(file.toPath())) {
    3834            for (Node n : GmlReader.parseDataSet(is, null, null).getNodes()) {
    3935                assertNotNull(n.getCoor(), n.toString());
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/KmlReaderTest.java

    r35910 r36064  
    88
    99import org.junit.jupiter.api.Test;
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.openstreetmap.josm.TestUtils;
    1211import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    13 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1412import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     13import org.openstreetmap.josm.testutils.annotations.Projection;
    1514
    1615/**
     
    1817 */
    1918@BasicPreferences
     19@Projection
    2020class KmlReaderTest {
    21 
    22     /**
    23      * Setup test.
    24      */
    25     @RegisterExtension
    26     JOSMTestRules rules = new JOSMTestRules().projection();
    27 
    2821    /**
    2922     * Unit test of {@link KmlReader#COLOR_PATTERN}
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/MifReaderTest.java

    r35899 r36064  
    88
    99import org.junit.jupiter.api.Test;
    10 import org.junit.jupiter.api.extension.RegisterExtension;
    1110import org.openstreetmap.josm.TestUtils;
    1211import org.openstreetmap.josm.data.osm.DataSet;
     
    1413import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    1514import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1715import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     16import org.openstreetmap.josm.testutils.annotations.Projection;
    1817
    1918/**
     
    2120 */
    2221@BasicPreferences
     22@Projection
    2323class MifReaderTest {
    24 
    25     /**
    26      * Setup test.
    27      */
    28     @RegisterExtension
    29     JOSMTestRules rules = new JOSMTestRules().projection();
    30 
    3124    private static AbstractDataSetHandler newHandler(final String epsgCode) {
    3225        AbstractDataSetHandler handler = new AbstractDataSetHandler() {
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/ShpReaderTest.java

    r35899 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.opendata.core.io.geographic;
    3 
    4 import java.io.File;
    5 import java.io.FileInputStream;
    6 import java.io.InputStream;
    7 import java.util.Collection;
    8 import java.util.Objects;
    9 
    10 import org.junit.jupiter.api.Disabled;
    11 import org.junit.jupiter.api.Test;
    12 import org.junit.jupiter.api.extension.RegisterExtension;
    13 import org.openstreetmap.josm.TestUtils;
    14 import org.openstreetmap.josm.data.coor.LatLon;
    15 import org.openstreetmap.josm.data.osm.Node;
    16 import org.openstreetmap.josm.data.osm.Way;
    17 import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
    19 import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    203
    214import static org.junit.jupiter.api.Assertions.assertEquals;
     
    258import static org.junit.jupiter.api.Assertions.assertTrue;
    269
     10import java.io.File;
     11import java.io.FileInputStream;
     12import java.io.InputStream;
     13import java.nio.file.Files;
     14import java.util.Collection;
     15import java.util.Objects;
     16import java.util.concurrent.TimeUnit;
     17
     18import org.junit.jupiter.api.Disabled;
     19import org.junit.jupiter.api.Test;
     20import org.junit.jupiter.api.Timeout;
     21import org.openstreetmap.josm.TestUtils;
     22import org.openstreetmap.josm.data.coor.LatLon;
     23import org.openstreetmap.josm.data.osm.Node;
     24import org.openstreetmap.josm.data.osm.Way;
     25import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
     26import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     27import org.openstreetmap.josm.testutils.annotations.Projection;
     28
    2729/**
    2830 * Unit tests of {@link ShpReader} class.
    2931 */
    3032@BasicPreferences
     33@Projection
     34@Timeout(value = 1, unit = TimeUnit.MINUTES)
    3135class ShpReaderTest {
    32 
    33     /**
    34      * Setup test.
    35      */
    36     @RegisterExtension
    37     JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);
    38 
    3936    /**
    4037     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12714">#12714</a>
     
    4441    void testTicket12714() throws Exception {
    4542        File file = new File(TestUtils.getRegressionDataFile(12714, "linhas.shp"));
    46         try (InputStream is = new FileInputStream(file)) {
     43        try (InputStream is = Files.newInputStream(file.toPath())) {
    4744            for (Node n : ShpReader.parseDataSet(is, file, null, null).getNodes()) {
    4845                assertNotNull(n.getCoor(), n.toString());
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/geographic/TabReaderTest.java

    r35899 r36064  
    33
    44import java.io.File;
    5 import java.io.FileInputStream;
    65import java.io.InputStream;
     6import java.nio.file.Files;
     7import java.util.concurrent.TimeUnit;
    78
    89import org.junit.jupiter.api.Test;
    9 import org.junit.jupiter.api.extension.RegisterExtension;
     10import org.junit.jupiter.api.Timeout;
    1011import org.openstreetmap.josm.TestUtils;
    1112import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    12 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1313import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     14import org.openstreetmap.josm.testutils.annotations.Projection;
    1415
    1516/**
     
    1718 */
    1819@BasicPreferences
     20@Projection
     21@Timeout(value = 1, unit = TimeUnit.MINUTES)
    1922class TabReaderTest {
    20 
    21     /**
    22      * Setup test.
    23      */
    24     @RegisterExtension
    25     JOSMTestRules rules = new JOSMTestRules().projection().timeout(60000);
    26 
    2723    /**
    2824     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/15159">#15159</a>
     
    3228    void testTicket15159() throws Exception {
    3329        File file = new File(TestUtils.getRegressionDataFile(15159, "Sanisette.tab"));
    34         try (InputStream is = new FileInputStream(file)) {
     30        try (InputStream is = Files.newInputStream(file.toPath())) {
    3531            NonRegFunctionalTests.testGeneric("#15159", TabReader.parseDataSet(is, file, null, null));
    3632        }
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/CsvReaderTest.java

    r35899 r36064  
    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.EastNorth;
     
    1312import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    1413import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    15 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1614import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     15import org.openstreetmap.josm.testutils.annotations.Projection;
    1716
    1817/**
     
    2019 */
    2120@BasicPreferences
     21@Projection
    2222class CsvReaderTest {
    23 
    24     /**
    25      * Setup test.
    26      */
    27     @RegisterExtension
    28     JOSMTestRules rules = new JOSMTestRules().projection();
    29 
    3023    private static AbstractDataSetHandler newHandler(final String epsgCode) {
    3124        AbstractDataSetHandler handler = new AbstractDataSetHandler() {
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/OdsReaderTest.java

    r35899 r36064  
    55
    66import org.junit.jupiter.api.Test;
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    87import org.openstreetmap.josm.TestUtils;
    98import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    10 import org.openstreetmap.josm.testutils.JOSMTestRules;
    119import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
     10import org.openstreetmap.josm.testutils.annotations.Projection;
    1211
    1312/**
     
    1514 */
    1615@BasicPreferences
     16@Projection
    1717class OdsReaderTest {
    18 
    19     /**
    20      * Setup test.
    21      */
    22     @RegisterExtension
    23     JOSMTestRules rules = new JOSMTestRules().projection();
    2418
    2519    /**
  • applications/editors/josm/plugins/opendata/test/unit/org/openstreetmap/josm/plugins/opendata/core/io/tabular/XlsReaderTest.java

    r35899 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.opendata.core.io.tabular;
     3
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
    36
    47import java.io.InputStream;
    58
    69import org.junit.jupiter.api.Test;
    7 import org.junit.jupiter.api.extension.RegisterExtension;
    810import org.openstreetmap.josm.TestUtils;
    911import org.openstreetmap.josm.data.coor.EastNorth;
     
    1416import org.openstreetmap.josm.plugins.opendata.core.datasets.AbstractDataSetHandler;
    1517import org.openstreetmap.josm.plugins.opendata.core.io.NonRegFunctionalTests;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
    1718import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    18 
    19 import static org.junit.jupiter.api.Assertions.assertEquals;
    20 import static org.junit.jupiter.api.Assertions.assertNotNull;
     19import org.openstreetmap.josm.testutils.annotations.Projection;
    2120
    2221/**
     
    2423 */
    2524@BasicPreferences
     25@Projection
    2626class XlsReaderTest {
    27 
    28     /**
    29      * Setup test.
    30      */
    31     @RegisterExtension
    32     public JOSMTestRules rules = new JOSMTestRules().projection();
    33 
    3427    private static AbstractDataSetHandler newHandler(final String epsgCode) {
    3528        AbstractDataSetHandler handler = new AbstractDataSetHandler() {
Note: See TracChangeset for help on using the changeset viewer.