Search in sources :

Example 1 with NullChangeWriter

use of org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter in project osmosis by openstreetmap.

the class XmlChangeReaderWriterTest method testNonDeleteLatLonNotSet.

/**
 * Tests non-acceptance of nodes in a non-delete change with lat/lon attribute not set.
 *
 * @throws Exception if something goes wrong.
 */
@Test(expected = OsmosisRuntimeException.class)
public void testNonDeleteLatLonNotSet() throws Exception {
    File inputFile = dataUtils.createDataFile("v0_6/xml-create-no-coordinates.osc");
    XmlChangeReader reader = new XmlChangeReader(inputFile, false, CompressionMethod.None);
    reader.setChangeSink(new NullChangeWriter());
    reader.run();
}
Also used : NullChangeWriter(org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter) File(java.io.File) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Example 2 with NullChangeWriter

use of org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter in project osmosis by openstreetmap.

the class ChangeSimplifierTest method badSortOrderId.

/**
 * Tests that badly ordered input (with respect to the ids) is detected correctly.
 *
 * @throws Exception
 *             if anything fails.
 */
@Test
public void badSortOrderId() throws Exception {
    ChangeSimplifier simplifier = new ChangeSimplifier();
    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    node = new Node(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 2), 1, 1);
    simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    try {
        node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 1), 1, 1);
        simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
        if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
            return;
        }
        throw e;
    }
    Assert.fail("Expected exception not thrown");
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) NullChangeWriter(org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Date(java.util.Date) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Example 3 with NullChangeWriter

use of org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter in project osmosis by openstreetmap.

the class ChangeSimplifierTest method badSortOrderType.

/**
 * Tests that badly ordered input (with respect to the ids) is detected correctly.
 *
 * @throws Exception
 *             if anything fails.
 */
@Test
public void badSortOrderType() throws Exception {
    ChangeSimplifier simplifier = new ChangeSimplifier();
    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    Way way;
    way = new Way(new CommonEntityData(2, 2, new Date(), OsmUser.NONE, 2));
    simplifier.process(new ChangeContainer(new WayContainer(way), ChangeAction.Modify));
    try {
        node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 1), 1, 1);
        simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
        if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
            return;
        }
        throw e;
    }
    Assert.fail("Expected exception not thrown");
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) WayContainer(org.openstreetmap.osmosis.core.container.v0_6.WayContainer) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) NullChangeWriter(org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Way(org.openstreetmap.osmosis.core.domain.v0_6.Way) Date(java.util.Date) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Example 4 with NullChangeWriter

use of org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter in project osmosis by openstreetmap.

the class ChangeSimplifierTest method badSortOrderVersion.

/**
 * Tests that badly ordered input (with respect to the version) is detected correctly.
 *
 * @throws Exception
 *             if anything fails.
 */
@Test
public void badSortOrderVersion() throws Exception {
    ChangeSimplifier simplifier = new ChangeSimplifier();
    simplifier.setChangeSink(new NullChangeWriter());
    simplifier.initialize(new HashMap<String, Object>());
    Node node;
    node = new Node(new CommonEntityData(1, 2, new Date(), OsmUser.NONE, 2), 1, 1);
    simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    try {
        node = new Node(new CommonEntityData(1, 1, new Date(), OsmUser.NONE, 1), 1, 1);
        simplifier.process(new ChangeContainer(new NodeContainer(node), ChangeAction.Modify));
    } catch (OsmosisRuntimeException e) {
        if (e.getMessage().startsWith("Pipeline entities are not sorted")) {
            return;
        }
        throw e;
    }
    Assert.fail("Expected exception not thrown");
}
Also used : CommonEntityData(org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData) ChangeContainer(org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer) NullChangeWriter(org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter) Node(org.openstreetmap.osmosis.core.domain.v0_6.Node) NodeContainer(org.openstreetmap.osmosis.core.container.v0_6.NodeContainer) Date(java.util.Date) OsmosisRuntimeException(org.openstreetmap.osmosis.core.OsmosisRuntimeException) AbstractDataTest(org.openstreetmap.osmosis.testutil.AbstractDataTest) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 NullChangeWriter (org.openstreetmap.osmosis.core.misc.v0_6.NullChangeWriter)4 AbstractDataTest (org.openstreetmap.osmosis.testutil.AbstractDataTest)4 Date (java.util.Date)3 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)3 ChangeContainer (org.openstreetmap.osmosis.core.container.v0_6.ChangeContainer)3 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)3 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)3 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)3 File (java.io.File)1 WayContainer (org.openstreetmap.osmosis.core.container.v0_6.WayContainer)1 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)1