Changeset 14121 in josm for trunk/test


Ignore:
Timestamp:
2018-08-11T17:51:12+02:00 (16 months ago)
Author:
Don-vip
Message:

see #15229 - deprecate all Main methods related to network features. New NetworkManager class

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
1 added
1 edited

Legend:

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

    r14120 r14121  
    22package org.openstreetmap.josm;
    33
    4 import static org.junit.Assert.assertEquals;
    54import static org.junit.Assert.assertFalse;
    65import static org.junit.Assert.assertNotNull;
    76import static org.junit.Assert.assertTrue;
    8 
    9 import java.net.MalformedURLException;
    10 import java.net.URL;
    11 import java.util.Map;
    127
    138import org.junit.Rule;
     
    1611import org.openstreetmap.josm.Main.InitializationTask;
    1712import org.openstreetmap.josm.data.coor.conversion.CoordinateFormatManager;
    18 import org.openstreetmap.josm.io.OnlineResource;
    1913import org.openstreetmap.josm.testutils.JOSMTestRules;
    2014
     
    4034        Main.preConstructorInit();
    4135        assertNotNull(CoordinateFormatManager.getDefaultFormat());
    42     }
    43 
    44     /**
    45      * Unit test of {@link Main#addNetworkError}, {@link Main#getNetworkErrors} and {@link Main#clearNetworkErrors}.
    46      * @throws MalformedURLException if any error occurs
    47      */
    48     @Test
    49     public void testNetworkErrors() throws MalformedURLException {
    50         Main.clearNetworkErrors();
    51         assertTrue(Main.getNetworkErrors().isEmpty());
    52         Main.addNetworkError("http://url1", new Exception("exception_1"));
    53         Main.addNetworkError(new URL("http://url2"), new Exception("exception_2"));
    54         Map<String, Throwable> errors = Main.getNetworkErrors();
    55         assertEquals(2, errors.size());
    56         assertEquals("exception_1", errors.get("http://url1").getMessage());
    57         assertEquals("exception_2", errors.get("http://url2").getMessage());
    58         Main.clearNetworkErrors();
    59         assertTrue(Main.getNetworkErrors().isEmpty());
    60     }
    61 
    62     /**
    63      * Unit test of {@link Main#setOffline} and {@link Main#getOfflineResources}.
    64      */
    65     @Test
    66     public void testOfflineRessources() {
    67         Main.setOnline(OnlineResource.ALL);
    68         assertTrue(Main.getOfflineResources().isEmpty());
    69         assertFalse(Main.isOffline(OnlineResource.JOSM_WEBSITE));
    70         Main.setOffline(OnlineResource.JOSM_WEBSITE);
    71         assertTrue(Main.isOffline(OnlineResource.JOSM_WEBSITE));
    72         Main.setOnline(OnlineResource.JOSM_WEBSITE);
    73         assertFalse(Main.isOffline(OnlineResource.JOSM_WEBSITE));
    74         Main.setOffline(OnlineResource.ALL);
    75         assertTrue(Main.isOffline(OnlineResource.JOSM_WEBSITE));
    76         assertTrue(Main.isOffline(OnlineResource.OSM_API));
    77         Main.setOnline(OnlineResource.ALL);
    7836    }
    7937
Note: See TracChangeset for help on using the changeset viewer.