Changeset 12842 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-09-13T16:32:24+02:00 (7 years ago)
Author:
bastiK
Message:

see #15229 - fix test deprecations

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/MergeNodesActionTest.java

    r12562 r12842  
    4343    @Test(expected = IllegalStateException.class)
    4444    public void testSelectTargetLocationNodeInvalidMode() {
    45         Main.pref.putInteger("merge-nodes.mode", -1);
     45        Main.pref.putInt("merge-nodes.mode", -1);
    4646        MergeNodesAction.selectTargetLocationNode(Arrays.asList(new Node(0), new Node(1)));
    4747    }
     
    5252    @Test
    5353    public void testSelectTargetLocationNode() {
    54         Main.pref.putInteger("merge-nodes.mode", 0);
     54        Main.pref.putInt("merge-nodes.mode", 0);
    5555        assertEquals(1, MergeNodesAction.selectTargetLocationNode(Arrays.asList(new Node(0), new Node(1))).getId());
    5656
    57         Main.pref.putInteger("merge-nodes.mode", 1);
     57        Main.pref.putInt("merge-nodes.mode", 1);
    5858        assertEquals(LatLon.ZERO, MergeNodesAction.selectTargetLocationNode(
    5959                Arrays.asList(new Node(LatLon.NORTH_POLE), new Node(LatLon.SOUTH_POLE))).getCoor());
    6060
    61         Main.pref.putInteger("merge-nodes.mode", 2);
     61        Main.pref.putInt("merge-nodes.mode", 2);
    6262        assertEquals(LatLon.NORTH_POLE, MergeNodesAction.selectTargetLocationNode(
    6363                Arrays.asList(new Node(LatLon.NORTH_POLE))).getCoor());
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/properties/RecentTagCollectionTest.java

    r12659 r12842  
    1414import org.openstreetmap.josm.data.osm.search.SearchParseError;
    1515import org.openstreetmap.josm.data.osm.search.SearchSetting;
    16 import org.openstreetmap.josm.data.preferences.CollectionProperty;
     16import org.openstreetmap.josm.data.preferences.ListProperty;
    1717import org.openstreetmap.josm.testutils.JOSMTestRules;
    1818
     
    5353        assertEquals(Arrays.asList(foo, baz), recentTags.toList());
    5454
    55         final CollectionProperty pref = new CollectionProperty("properties.recent-tags", Collections.<String>emptyList());
     55        final ListProperty pref = new ListProperty("properties.recent-tags", Collections.<String>emptyList());
    5656        recentTags.saveToPreference(pref);
    5757        assertEquals(Arrays.asList("name", "foo", "name", "baz"), pref.get());
  • trunk/test/unit/org/openstreetmap/josm/gui/io/CustomConfiguratorTest.java

    r12826 r12842  
    4444        File tmp = File.createTempFile("josm.testExportPreferencesKeysToFile.lorem_ipsum", ".xml");
    4545
    46         Main.pref.putCollection("lorem_ipsum", Arrays.asList(
     46        Main.pref.putList("lorem_ipsum", Arrays.asList(
    4747                "Lorem ipsum dolor sit amet, consectetur adipiscing elit.",
    4848                "Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.",
     
    5757        String xml = Utils.join("\n", Files.readAllLines(tmp.toPath(), StandardCharsets.UTF_8));
    5858        assertTrue(xml.contains("<preferences operation=\"replace\">"));
    59         for (String entry : Main.pref.getCollection("lorem_ipsum")) {
     59        for (String entry : Main.pref.getList("lorem_ipsum")) {
    6060            assertTrue(entry + "\nnot found in:\n" + xml, xml.contains(entry));
    6161        }
    6262
    63         Main.pref.putCollection("test", Arrays.asList("11111111", "2222222", "333333333"));
     63        Main.pref.putList("test", Arrays.asList("11111111", "2222222", "333333333"));
    6464        CustomConfigurator.exportPreferencesKeysByPatternToFile(tmp.getAbsolutePath(), true, "test");
    6565        xml = Utils.join("\n", Files.readAllLines(tmp.toPath(), StandardCharsets.UTF_8));
    6666        assertTrue(xml.contains("<preferences operation=\"append\">"));
    67         for (String entry : Main.pref.getCollection("test")) {
     67        for (String entry : Main.pref.getList("test")) {
    6868            assertTrue(entry + "\nnot found in:\n" + xml, xml.contains(entry));
    6969        }
     
    7979    public void testReadXML() throws IOException {
    8080        // Test 1 - read(dir, file) + append
    81         Main.pref.putCollection("test", Collections.<String>emptyList());
    82         assertTrue(Main.pref.getCollection("test").isEmpty());
     81        Main.pref.putList("test", Collections.<String>emptyList());
     82        assertTrue(Main.pref.getList("test").isEmpty());
    8383        CustomConfigurator.readXML(TestUtils.getTestDataRoot() + "customconfigurator", "append.xml");
    8484        String log = PreferencesUtils.getLog();
    8585        assertFalse(log, log.contains("Error"));
    86         assertFalse(Main.pref.getCollection("test").isEmpty());
     86        assertFalse(Main.pref.getList("test").isEmpty());
    8787
    8888        // Test 2 - read(file, pref) + replace
     
    9090        // avoid messing up preferences file (that makes all following unit tests fail)
    9191        pref.enableSaveOnPut(false);
    92         pref.putCollection("lorem_ipsum", Arrays.asList("only 1 string"));
    93         assertEquals(1, pref.getCollection("lorem_ipsum").size());
     92        pref.putList("lorem_ipsum", Arrays.asList("only 1 string"));
     93        assertEquals(1, pref.getList("lorem_ipsum").size());
    9494        CustomConfigurator.readXML(new File(TestUtils.getTestDataRoot() + "customconfigurator", "replace.xml"), pref);
    9595        log = PreferencesUtils.getLog();
    9696        assertFalse(log, log.contains("Error"));
    97         assertEquals(9, pref.getCollection("lorem_ipsum").size());
     97        assertEquals(9, pref.getList("lorem_ipsum").size());
    9898    }
    9999}
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java

    r12564 r12842  
    4242    @Test
    4343    public void testTicket12312() throws FileNotFoundException, IOException, SAXException {
    44         Main.pref.put("draw.rawgps.colors.dynamic.layer 12312", true);
    45         Main.pref.putInteger("draw.rawgps.colors.layer 12312", GpxDrawHelper.ColorMode.VELOCITY.toIndex());
     44        Main.pref.putBoolean("draw.rawgps.colors.dynamic.layer 12312", true);
     45        Main.pref.putInt("draw.rawgps.colors.layer 12312", GpxDrawHelper.ColorMode.VELOCITY.toIndex());
    4646        final List<String> colors = calculateColors(TestUtils.getRegressionDataFile(12312, "single_trackpoint.gpx"), "12312", 1);
    4747        assertEquals("[#FF00FF]", colors.toString());
     
    6868    @Test
    6969    public void testVelocity() throws IOException, SAXException {
    70         Main.pref.putInteger("draw.rawgps.colors.layer 001", GpxDrawHelper.ColorMode.VELOCITY.toIndex());
     70        Main.pref.putInt("draw.rawgps.colors.layer 001", GpxDrawHelper.ColorMode.VELOCITY.toIndex());
    7171        final List<String> colors = calculateColors("data_nodist/2094047.gpx", "001", 10);
    7272        assertEquals("[#FF00FF, #FFAD00, #FFA800, #FFA800, #FF9E00, #FF9400, #FF7000, #FF7000, #FF8000, #FF9400]", colors.toString());
     
    8181    @Test
    8282    public void testVelocityDynamic() throws IOException, SAXException {
    83         Main.pref.putInteger("draw.rawgps.colors.layer 002", GpxDrawHelper.ColorMode.VELOCITY.toIndex());
    84         Main.pref.put("draw.rawgps.colors.dynamic.layer 002", true);
     83        Main.pref.putInt("draw.rawgps.colors.layer 002", GpxDrawHelper.ColorMode.VELOCITY.toIndex());
     84        Main.pref.putBoolean("draw.rawgps.colors.dynamic.layer 002", true);
    8585        final List<String> colors = calculateColors("data_nodist/2094047.gpx", "002", 10);
    8686        assertEquals("[#FF00FF, #00FFE0, #00FFC2, #00FFC2, #00FF75, #00FF3D, #99FF00, #94FF00, #38FF00, #00FF38]", colors.toString());
     
    9595    @Test
    9696    public void testDirection() throws IOException, SAXException {
    97         Main.pref.putInteger("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.DIRECTION.toIndex());
     97        Main.pref.putInt("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.DIRECTION.toIndex());
    9898        final List<String> colors = calculateColors("data_nodist/2094047.gpx", "003", 10);
    9999        assertEquals("[#FF00FF, #EAEC25, #EDEA26, #EDE525, #ECD322, #EBB81D, #E85A0D, #E73708, #E84D0B, #EA8A15]", colors.toString());
     
    108108    @Test
    109109    public void testTime() throws IOException, SAXException {
    110         Main.pref.putInteger("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.TIME.toIndex());
     110        Main.pref.putInt("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.TIME.toIndex());
    111111        final List<String> colors = calculateColors("data_nodist/2094047.gpx", "003", 10);
    112112        assertEquals("[#FF00FF, #FF0000, #FF0000, #FF0500, #FF0500, #FF0A00, #FF0A00, #FF1F00, #FF2E00, #FF3300]", colors.toString());
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java

    r12636 r12842  
    4040    @Before
    4141    public void setUp() {
    42         Main.pref.put("marker.traceaudio", true);
     42        Main.pref.putBoolean("marker.traceaudio", true);
    4343    }
    4444
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/audio/AudioPreferenceTest.java

    r10378 r12842  
    3636    @Test
    3737    public void testAddGui() {
    38         Main.pref.put("audio.menuinvisible", true);
     38        Main.pref.putBoolean("audio.menuinvisible", true);
    3939        PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null);
    40         Main.pref.put("audio.menuinvisible", false);
     40        Main.pref.putBoolean("audio.menuinvisible", false);
    4141        PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null);
    4242    }
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTest.java

    r12632 r12842  
    4242    public void testAddGui() {
    4343        String fileUrl = new File(TestUtils.getTestDataRoot()+"__files/imagery/maps.xml").toURI().toString();
    44         Main.pref.putCollection("imagery.layers.sites", Arrays.asList(fileUrl));
     44        Main.pref.putList("imagery.layers.sites", Arrays.asList(fileUrl));
    4545        PreferencesTestUtils.doTestPreferenceSettingAddGui(new ImageryPreference.Factory(), null);
    4646    }
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java

    r12649 r12842  
    5858        assertFalse(sources.isEmpty());
    5959        // Double traditional timeouts to avoid random problems
    60         Main.pref.putInteger("socket.timeout.connect", 30);
    61         Main.pref.putInteger("socket.timeout.read", 60);
     60        Main.pref.putInt("socket.timeout.connect", 30);
     61        Main.pref.putInt("socket.timeout.read", 60);
    6262        Map<Object, Throwable> allErrors = new HashMap<>();
    6363        Set<String> allMessages = new HashSet<>();
  • trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java

    r12620 r12842  
    5252        RemoteControl.start();
    5353        disableCertificateValidation();
    54         httpBase = "http://127.0.0.1:"+Main.pref.getInteger("remote.control.port", 8111);
    55         httpsBase = "https://127.0.0.1:"+Main.pref.getInteger("remote.control.https.port", 8112);
     54        httpBase = "http://127.0.0.1:"+Main.pref.getInt("remote.control.port", 8111);
     55        httpsBase = "https://127.0.0.1:"+Main.pref.getInt("remote.control.https.port", 8112);
    5656    }
    5757
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

    r12754 r12842  
    148148        PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(NullProgressMonitor.INSTANCE, plugins, null);
    149149        // Increase default timeout to avoid random network errors on big jar files
    150         int defTimeout = Main.pref.getInteger("socket.timeout.read", 30);
    151         Main.pref.putInteger("socket.timeout.read", 2 * defTimeout);
     150        int defTimeout = Main.pref.getInt("socket.timeout.read", 30);
     151        Main.pref.putInt("socket.timeout.read", 2 * defTimeout);
    152152        pluginDownloadTask.run();
    153153        // Restore default timeout
    154         Main.pref.putInteger("socket.timeout.read", defTimeout);
     154        Main.pref.putInt("socket.timeout.read", defTimeout);
    155155        assertTrue(pluginDownloadTask.getFailedPlugins().toString(), pluginDownloadTask.getFailedPlugins().isEmpty());
    156156        assertEquals(plugins.size(), pluginDownloadTask.getDownloadedPlugins().size());
Note: See TracChangeset for help on using the changeset viewer.