Changeset 10373 in josm for trunk/test


Ignore:
Timestamp:
2016-06-14T19:26:16+02:00 (4 years ago)
Author:
Don-vip
Message:

fix #12949 - Use test rule instead of JOSMFixture to speed up tests (patch by michael2402) - gsoc-core

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

Legend:

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

    r10364 r10373  
    88import java.util.List;
    99
    10 import org.junit.BeforeClass;
     10import org.junit.Rule;
    1111import org.junit.Test;
    12 import org.openstreetmap.josm.JOSMFixture;
    1312import org.openstreetmap.josm.Main;
    1413import org.openstreetmap.josm.data.imagery.ImageryInfo;
    1514import org.openstreetmap.josm.gui.layer.TMSLayer;
    1615import org.openstreetmap.josm.gui.layer.WMSLayer;
     16import org.openstreetmap.josm.testutils.JOSMTestRules;
    1717
    1818/**
     
    2020 */
    2121public final class AddImageryLayerActionTest {
    22 
    2322    /**
    24      * Setup test.
     23     * We need prefs for this. We need platform for actions and the OSM API for checking blacklist.
    2524     */
    26     @BeforeClass
    27     public static void setUp() {
    28         JOSMFixture.createUnitTestFixture().init(true);
    29     }
     25    @Rule
     26    public JOSMTestRules test = new JOSMTestRules().preferences().platform().fakeAPI();
    3027
    3128    /**
     
    3532    public void testEnabledState() {
    3633        assertFalse(new AddImageryLayerAction(new ImageryInfo()).isEnabled());
    37         assertFalse(new AddImageryLayerAction(new ImageryInfo("google", "http://maps.google.com/api", "tms", null, null)).isEnabled());
    3834        assertTrue(new AddImageryLayerAction(new ImageryInfo("foo_tms", "http://bar", "tms", null, null)).isEnabled());
    3935        assertTrue(new AddImageryLayerAction(new ImageryInfo("foo_bing", "http://bar", "bing", null, null)).isEnabled());
  • trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java

    r10299 r10373  
    55import static org.junit.Assert.assertFalse;
    66import static org.junit.Assert.assertTrue;
    7 
    8 import org.junit.Before;
     7import static org.junit.Assert.fail;
     8
     9import org.junit.Rule;
    910import org.junit.Test;
    10 import org.openstreetmap.josm.JOSMFixture;
    1111import org.openstreetmap.josm.actions.search.SearchCompiler.Match;
    1212import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError;
     
    2323import org.openstreetmap.josm.data.osm.Way;
    2424import org.openstreetmap.josm.data.osm.WayData;
     25import org.openstreetmap.josm.testutils.JOSMTestRules;
    2526import org.openstreetmap.josm.tools.date.DateUtils;
    2627
     
    3132
    3233    /**
    33      * Setup test.
    34      */
    35     @Before
    36     public void setUp() {
    37         JOSMFixture.createUnitTestFixture().init();
    38     }
     34     * We need prefs for this. We access preferences when creating OSM primitives.
     35     */
     36    @Rule
     37    public JOSMTestRules test = new JOSMTestRules().preferences();
    3938
    4039    private static final class SearchContext {
     
    390389        try {
    391390            SearchCompiler.compile("foo type bar");
    392             throw new RuntimeException();
     391            fail();
    393392        } catch (ParseError parseError) {
    394393            assertEquals("<html>Expecting <code>:</code> after <i>type</i>", parseError.getMessage());
Note: See TracChangeset for help on using the changeset viewer.