src/test/java/de/blau/android/osm/OscTest.java
/**
     * Read and apply osc file
     * 
     * Unit test version of ApplyOSCTest
     */
Read and apply osc file

Unit test version of ApplyOSCTest
Read and apply osc file Unit test version of ApplyOSCTest
@Test
    public void readAndApplyOsc() {
        final OsmParser osmParser = new OsmParser();
        osmParser.clearBoundingBoxes();
        try (final InputStream in = getClass().getResourceAsStream("/" + OscTestCommon.OSM_FILE)) {
            osmParser.start(in);
            StorageDelegator d = new StorageDelegator();
            try {
                d.reset(false);
                d.setCurrentStorage(osmParser.getStorage()); 
                d.fixupApiStorage();
                OscTestCommon.checkInitialState(d);
                InputStream input = getClass().getResourceAsStream("/" + OscTestCommon.OSC_FILE);
                OsmChangeParser parser = new OsmChangeParser();
                try {
                    parser.start(input);
                    Storage osc = parser.getStorage();
                    d.applyOsc(osc, null);
                    OscTestCommon.checkNewState(d);
                } catch (SAXException | IOException | ParserConfigurationException | IllegalArgumentException | IllegalStateException e) {
                    fail(e.getMessage());
                }
                String path = SavingHelper.export(ApplicationProvider.getApplicationContext(), d);
                assertNotNull(path); 
            } catch (Exception e) {
                fail(e.getMessage());
            }
        } catch (SAXException | IOException | ParserConfigurationException e1) {
            fail(e1.getMessage());
        }
    }
@ Test public void readAndApplyOsc ( ) { final OsmParser osmParser = new OsmParser ( ) ; osmParser . clearBoundingBoxes ( ) ; try ( final InputStream in = getClass ( ) . getResourceAsStream ( "/" + OscTestCommon . OSM_FILE ) ) { osmParser . start ( in ) ; StorageDelegator d = new StorageDelegator ( ) ; try { d . reset ( false ) ; d . setCurrentStorage ( osmParser . getStorage ( ) ) ; d . fixupApiStorage ( ) ; OscTestCommon . checkInitialState ( d ) ; InputStream input = getClass ( ) . getResourceAsStream ( "/" + OscTestCommon . OSC_FILE ) ; OsmChangeParser parser = new OsmChangeParser ( ) ; try { parser . start ( input ) ; Storage osc = parser . getStorage ( ) ; d . applyOsc ( osc , null ) ; OscTestCommon . checkNewState ( d ) ; } catch ( SAXException | IOException | ParserConfigurationException | IllegalArgumentException | IllegalStateException e ) { fail ( e . getMessage ( ) ) ; } String path = SavingHelper . export ( ApplicationProvider . getApplicationContext ( ) , d ) ; assertNotNull ( path ) ; } catch ( Exception e ) { fail ( e . getMessage ( ) ) ; } } catch ( SAXException | IOException | ParserConfigurationException e1 ) { fail ( e1 . getMessage ( ) ) ; } }
Read and apply osc file
Read and apply osc file
// this sets dirty flag // some more tests might be a good idea