Changeset 16781 in josm for trunk/test/unit


Ignore:
Timestamp:
2020-07-17T12:07:19+02:00 (4 years ago)
Author:
GerdP
Message:

fix #19432: Split way: AIOOB: Problem with member check with duplicate members

  • don't store position of member, instead always search it
  • improve calculation of missing(incomplete) way members and store the result instead of calculating it twice
  • add unit test
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/command/SplitWayCommandTest.java

    r16200 r16781  
    367367        }
    368368    }
     369
     370    /**
     371     * Non-regression test for issue #19432 (AIOOB: Problem with member check with duplicate members)
     372     *
     373     * @throws IOException if any I/O error occurs
     374     * @throws IllegalDataException if OSM parsing fails
     375     */
     376    @Test
     377    public void testTicket19432() throws IOException, IllegalDataException {
     378        try (InputStream is = TestUtils.getRegressionDataStream(19432, "josm_split_way_exception_example.osm.bz2")) {
     379            DataSet ds = OsmReader.parseDataSet(is, null);
     380
     381            Way splitWay = (Way) ds.getPrimitiveById(632576744L, OsmPrimitiveType.WAY);
     382            Node splitNode = (Node) ds.getPrimitiveById(1523436358L, OsmPrimitiveType.NODE);
     383
     384            final Optional<SplitWayCommand> result = SplitWayCommand.splitWay(
     385                    splitWay,
     386                    SplitWayCommand.buildSplitChunks(splitWay, Collections.singletonList(splitNode)),
     387                    new ArrayList<>(),
     388                    Strategy.keepLongestChunk(),
     389                    // This split requires no additional downloads. If any are needed, this command will fail.
     390                    SplitWayCommand.WhenRelationOrderUncertain.SPLIT_ANYWAY
     391            );
     392
     393            // Should not result in aborting the split.
     394            assertTrue(result.isPresent());
     395        }
     396    }
    369397}
Note: See TracChangeset for help on using the changeset viewer.