Changeset 6562 in josm for trunk/test


Ignore:
Timestamp:
2013-12-29T14:14:58+01:00 (6 years ago)
Author:
simon04
Message:

fix #9327 - tagging presets: fix handling of nested <reference>s, refactor railway presets

Location:
trunk/test
Files:
2 added
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/TaggingPresetReaderTest.java

    r6471 r6562  
    11// License: GPL. For details, see LICENSE file.
    22package org.openstreetmap.josm.gui.tagging;
    3 
    4 import java.io.IOException;
    5 import java.util.Collection;
    63
    74import org.junit.Assert;
    85import org.junit.BeforeClass;
    96import org.junit.Test;
     7import org.openstreetmap.TestUtils;
    108import org.openstreetmap.josm.Main;
    11 import org.openstreetmap.josm.data.Preferences;
     9import org.openstreetmap.josm.tools.Utils;
    1210import org.xml.sax.SAXException;
     11
     12import java.io.IOException;
     13import java.util.Collection;
     14import java.util.List;
     15
     16import static org.CustomMatchers.hasSize;
     17import static org.hamcrest.CoreMatchers.is;
     18import static org.junit.Assert.assertThat;
    1319
    1420/**
     
    1622 */
    1723public class TaggingPresetReaderTest {
    18     /**
    19      * path to test data root directory
    20      */
    21     private static String testdataroot;
    22    
     24
    2325    @BeforeClass
    2426    public static void setUpClass() {
    2527        Main.initApplicationPreferences();
    26         testdataroot = System.getProperty("josm.test.data");
    27         if (testdataroot == null || testdataroot.isEmpty()) {
    28             testdataroot = "test/data";
    29             System.out.println("System property josm.test.data is not set, using '" + testdataroot + "'");
    30         }
    3128    }
    3229
     
    3734     */
    3835    protected static String getRegressionDataDir(int ticketid) {
    39         return testdataroot + "/regress/" + ticketid;
     36        return TestUtils.getTestDataRoot() + "/regress/" + ticketid;
    4037    }
    4138
     
    6461    }
    6562
     63    @Test
     64    public void testNestedChunks() throws Exception {
     65        final Collection<TaggingPreset> presets = TaggingPresetReader.readAll(TestUtils.getTestDataRoot() + "preset_chunk.xml", true);
     66        assertThat(presets, hasSize(1));
     67        final TaggingPreset abc =  presets.iterator().next();
     68        final List<String> keys = Utils.transform(abc.data, new Utils.Function<TaggingPresetItem, String>() {
     69            @Override
     70            public String apply(TaggingPresetItem x) {
     71                return ((TaggingPresetItems.Key) x).key;
     72            }
     73        });
     74        assertThat(keys.toString(), is("[A1, A2, A3, B1, B2, B3, C1, C2, C3]"));
     75    }
     76
    6677    /**
    6778     * Validate internal presets
Note: See TracChangeset for help on using the changeset viewer.