Changeset 7150 in josm for trunk/test/functional


Ignore:
Timestamp:
2014-05-20T14:21:46+02:00 (11 years ago)
Author:
simon04
Message:

Fix OsmServerBackreferenceReaderTest initialization. However, several tests fail.

File:
1 edited

Legend:

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

    r7082 r7150  
    1414import java.nio.charset.StandardCharsets;
    1515import java.text.MessageFormat;
    16 import java.util.ArrayList;
    1716import java.util.HashSet;
    1817import java.util.Set;
     
    2423import org.openstreetmap.josm.JOSMFixture;
    2524import org.openstreetmap.josm.Main;
     25import org.openstreetmap.josm.actions.upload.CyclicUploadDependencyException;
     26import org.openstreetmap.josm.data.APIDataSet;
    2627import org.openstreetmap.josm.data.coor.LatLon;
    2728import org.openstreetmap.josm.data.osm.Changeset;
    2829import org.openstreetmap.josm.data.osm.DataSet;
    2930import org.openstreetmap.josm.data.osm.Node;
    30 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    3131import org.openstreetmap.josm.data.osm.OsmPrimitiveType;
    3232import org.openstreetmap.josm.data.osm.Relation;
     
    128128     * @throws OsmTransferException
    129129     */
    130     static public void createDataSetOnServer(DataSet ds) throws OsmTransferException {
     130    static public void createDataSetOnServer(APIDataSet ds) throws OsmTransferException, CyclicUploadDependencyException {
    131131        logger.info("creating data set on the server ...");
    132         ArrayList<OsmPrimitive> primitives = new ArrayList<>();
    133         primitives.addAll(ds.getNodes());
    134         primitives.addAll(ds.getWays());
    135         primitives.addAll(ds.getRelations());
     132        ds.adjustRelationUploadOrder();
    136133        OsmServerWriter writer = new OsmServerWriter();
    137134        Changeset cs  = new Changeset();
    138         writer.uploadOsm(new UploadStrategySpecification().setStrategy(UploadStrategy.SINGLE_REQUEST_STRATEGY), primitives, cs, NullProgressMonitor.INSTANCE);
     135        writer.uploadOsm(
     136                new UploadStrategySpecification().setStrategy(UploadStrategy.SINGLE_REQUEST_STRATEGY),
     137                ds.getPrimitives(), cs, NullProgressMonitor.INSTANCE);
    139138        OsmApi.getOsmApi().closeChangeset(cs, NullProgressMonitor.INSTANCE);
    140139    }
     
    143142
    144143    @BeforeClass
    145     public static void init() throws OsmTransferException {
     144    public static void init() throws OsmTransferException, CyclicUploadDependencyException {
    146145        logger.info("initializing ...");
    147146
     
    169168        testDataSet = buildTestDataSet();
    170169        logger.info("uploading test data set ...");
    171         createDataSetOnServer(testDataSet);
     170        createDataSetOnServer(new APIDataSet(testDataSet));
    172171
    173172        try (
     
    212211        reader.setReadFull(false);
    213212        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
     213        printNumberOfPrimitives(referers);
    214214        assertEquals(10, referers.getNodes().size());
    215215        assertEquals(1, referers.getWays().size());
     
    221221    }
    222222
     223    private void printNumberOfPrimitives(DataSet referers) {
     224        System.out.println("#nodes=" + referers.getNodes().size() +
     225                " #ways=" + referers.getWays().size() +
     226                " #relations=" + referers.getRelations().size());
     227    }
     228
    223229    @Test
    224230    public void testBackrefrenceForNode_Full() throws OsmTransferException {
     
    231237        reader.setReadFull(true);
    232238        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
     239        printNumberOfPrimitives(referers);
    233240        assertEquals(10, referers.getNodes().size());
    234241        assertEquals(1, referers.getWays().size());
     
    251258        reader.setReadFull(false);
    252259        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
     260        printNumberOfPrimitives(referers);
    253261        assertEquals(0, referers.getNodes().size()); // no nodes loaded
    254262        assertEquals(6, referers.getWays().size());  // 6 ways referred by two relations
     
    310318        reader.setReadFull(false);
    311319        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
     320        printNumberOfPrimitives(referers);
    312321
    313322        Set<Long> referringRelationsIds = new HashSet<>();
Note: See TracChangeset for help on using the changeset viewer.