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

See #16567: Convert most plugin tests to JUnit 5

Location:
applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io/PbfExporterTest.java

    r32927 r36064  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.plugins.pbf.io;
     3
     4import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
    35
    46import java.io.FileInputStream;
     
    68import java.nio.file.Files;
    79import java.nio.file.Path;
     10import java.nio.file.Paths;
    811
    9 import org.junit.Rule;
    10 import org.junit.Test;
     12import org.junit.jupiter.api.Test;
     13import org.junit.jupiter.api.Timeout;
    1114import org.openstreetmap.josm.TestUtils;
    1215import org.openstreetmap.josm.data.osm.DataSet;
     
    1417import org.openstreetmap.josm.io.Compression;
    1518import org.openstreetmap.josm.io.OsmReader;
    16 import org.openstreetmap.josm.testutils.JOSMTestRules;
     19import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1720
    1821/**
    1922 * Unit tests for {@link PbfExporter}.
    2023 */
    21 public class PbfExporterTest {
    22 
    23     /**
    24      * Setup test.
    25      */
    26     @Rule
    27     public JOSMTestRules rules = new JOSMTestRules().preferences().timeout(20000);
    28 
     24@BasicPreferences
     25@Timeout(20)
     26class PbfExporterTest {
    2927    /**
    3028     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/11169">Ticket #11169</a>.
     
    3230     */
    3331    @Test
    34     public void testTicket11169() throws Exception {
     32    void testTicket11169() throws Exception {
    3533        try (InputStream is = Compression.ZIP.getUncompressedInputStream(
    36                 new FileInputStream(TestUtils.getRegressionDataFile(11169, "Portsmouth_Area.osm.zip")))) {
     34                Files.newInputStream(Paths.get(TestUtils.getRegressionDataFile(11169, "Portsmouth_Area.osm.zip"))))) {
    3735            DataSet ds = OsmReader.parseDataSet(is, null);
    3836            Path out = Files.createTempFile("pbf-bug-11169", "pbf");
    39             new PbfExporter().doSave(out.toFile(), new OsmDataLayer(ds, null, null));
     37            PbfExporter exporter = new PbfExporter();
     38            assertDoesNotThrow(() -> exporter.doSave(out.toFile(), new OsmDataLayer(ds, null, null)));
    4039            Files.delete(out);
    4140        }
  • applications/editors/josm/plugins/pbf/test/unit/org/openstreetmap/josm/plugins/pbf/io/PbfImporterTest.java

    r34848 r36064  
    22package org.openstreetmap.josm.plugins.pbf.io;
    33
    4 import static org.junit.Assert.assertEquals;
    5 import static org.junit.Assert.assertNotNull;
    6 import static org.junit.Assert.assertNull;
     4import static org.junit.jupiter.api.Assertions.assertEquals;
     5import static org.junit.jupiter.api.Assertions.assertNotNull;
     6import static org.junit.jupiter.api.Assertions.assertNull;
    77
    88import java.io.IOException;
    99
    10 import org.junit.Rule;
    11 import org.junit.Test;
     10import org.junit.jupiter.api.Test;
    1211import org.openstreetmap.josm.TestUtils;
    1312import org.openstreetmap.josm.data.osm.DataSet;
     
    1615import org.openstreetmap.josm.data.osm.User;
    1716import org.openstreetmap.josm.io.IllegalDataException;
    18 import org.openstreetmap.josm.testutils.JOSMTestRules;
     17import org.openstreetmap.josm.testutils.annotations.BasicPreferences;
    1918
    2019/**
    2120 * Unit tests for {@link PbfImporter}.
    2221 */
    23 public class PbfImporterTest {
    24 
    25     /**
    26      * Setup test.
    27      */
    28     @Rule
    29     public JOSMTestRules rules = new JOSMTestRules().preferences();
    30 
     22@BasicPreferences
     23class PbfImporterTest {
    3124    private static void checkUserNull(OsmPrimitive osm, boolean hasToBeNull) {
    3225        User usr = osm.getUser();
    3326        if (hasToBeNull) {
    34             assertNull(osm + " -> " + usr, usr);
     27            assertNull(usr, osm + " -> " + usr);
    3528        } else {
    36             assertNotNull(osm + " -> " + usr, usr);
     29            assertNotNull(usr, osm + " -> " + usr);
    3730        }
    3831    }
     
    5548     */
    5649    @Test
    57     public void testParseDataSet() throws Exception {
     50    void testParseDataSet() throws Exception {
    5851        doTestMonaco(TestUtils.getTestDataRoot() + "/monaco-latest.osm.pbf", false);
    5952    }
     
    6457     */
    6558    @Test
    66     public void testTicket10132() throws Exception {
     59    void testTicket10132() throws Exception {
    6760        doTestMonaco(TestUtils.getRegressionDataFile(10132, "Monaco-SP.osm.pbf"), true);
    6861    }
     
    7366     */
    7467    @Test
    75     public void testTicket12567() throws Exception {
     68    void testTicket12567() throws Exception {
    7669        DataSet ds = new PbfImporter().parseDataSet(TestUtils.getRegressionDataFile(12567, "12390008.osm.pbf"));
    7770        assertNotNull(ds);
     
    8679     */
    8780    @Test
    88     public void testTicket14545() throws Exception {
     81    void testTicket14545() throws Exception {
    8982        DataSet ds = new PbfImporter().parseDataSet(TestUtils.getRegressionDataFile(14545, "reg14545.osm.pbf"));
    9083        assertNotNull(ds);
Note: See TracChangeset for help on using the changeset viewer.