Changeset 18807 in josm for trunk/test/unit


Ignore:
Timestamp:
2023-08-15T15:16:08+02:00 (16 months ago)
Author:
taylor.smock
Message:

Allow importing geojson files that were saved to a session file

  • GeoJSONImporter now extends OsmImporter instead of FileImporter and deprecates the parseDataSet(String) method.
Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/SessionLoadActionTest.java

    r17275 r18807  
    44import static org.junit.jupiter.api.Assertions.assertFalse;
    55
    6 import org.junit.jupiter.api.extension.RegisterExtension;
    76import org.junit.jupiter.api.Test;
    87import org.openstreetmap.josm.data.imagery.ImageryInfo;
    98import org.openstreetmap.josm.data.imagery.ImageryInfo.ImageryType;
    109import org.openstreetmap.josm.gui.layer.TMSLayer;
    11 import org.openstreetmap.josm.testutils.JOSMTestRules;
    12 
    13 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     10import org.openstreetmap.josm.testutils.annotations.Main;
     11import org.openstreetmap.josm.testutils.annotations.Projection;
    1412
    1513/**
    1614 * Unit tests for class {@link SessionLoadAction}.
    1715 */
     16@Main
     17@Projection
    1818class SessionLoadActionTest {
    19 
    20     /**
    21      * Setup test.
    22      */
    23     @RegisterExtension
    24     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    25     public JOSMTestRules test = new JOSMTestRules().main().projection();
    26 
    2719    /**
    2820     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17702">Bug #17702</a>.
  • trunk/test/unit/org/openstreetmap/josm/io/session/SessionReaderTest.java

    r18690 r18807  
    1515import java.util.List;
    1616
    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;
     20import org.openstreetmap.josm.data.osm.Node;
    2121import org.openstreetmap.josm.gui.MainApplication;
    2222import org.openstreetmap.josm.gui.layer.AbstractTileSourceLayer;
     
    2828import org.openstreetmap.josm.gui.layer.markerlayer.MarkerLayer;
    2929import org.openstreetmap.josm.io.IllegalDataException;
    30 import org.openstreetmap.josm.testutils.JOSMTestRules;
    31 
    32 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     30import org.openstreetmap.josm.testutils.annotations.Projection;
    3331
    3432/**
    3533 * Unit tests for Session reading.
    3634 */
     35@Projection
    3736class SessionReaderTest {
    38 
    39     /**
    40      * Setup tests.
    41      */
    42     @RegisterExtension
    43     @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    44     public JOSMTestRules test = new JOSMTestRules().projection();
    45 
    4637    private static String getSessionDataDir() {
    4738        return TestUtils.getTestDataRoot() + "/sessions";
     
    161152    }
    162153
     154    @Test
     155    void testReadGeojson() throws IOException, IllegalDataException {
     156        final List<Layer> layers = testRead("geojson.jos");
     157        assertEquals(1, layers.size());
     158        final OsmDataLayer osmDataLayer = assertInstanceOf(OsmDataLayer.class, layers.get(0));
     159        assertEquals("Geojson layer name", osmDataLayer.getName());
     160        assertEquals(1, osmDataLayer.getDataSet().allPrimitives().size());
     161        final Node node = assertInstanceOf(Node.class, osmDataLayer.getDataSet().allPrimitives().iterator().next());
     162        assertEquals(2d, node.lat(), 1e-9);
     163        assertEquals(1d, node.lon(), 1e-9);
     164        assertEquals("Test point", node.get("name"));
     165    }
     166
    163167    /**
    164168     * Non-regression test for <a href="https://josm.openstreetmap.de/ticket/17701">Bug #17701</a>.
Note: See TracChangeset for help on using the changeset viewer.