Ignore:
Timestamp:
2017-04-15T20:20:00+02:00 (7 years ago)
Author:
Don-vip
Message:

improve unit test coverage of utilities classes thanks to https://trajano.github.io/commons-testing

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

Legend:

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

    r10966 r11921  
    1414import org.junit.Test;
    1515import org.openstreetmap.josm.Main.DownloadParamType;
     16import org.openstreetmap.josm.Main.MasterWindowListener;
    1617import org.openstreetmap.josm.testutils.JOSMTestRules;
    1718
     
    8182        assertNotNull(Main.toolbar);
    8283    }
     84
     85    /**
     86     * Unit test of {@link Main.MasterWindowListener}.
     87     */
     88    @Test
     89    public void testMasterWindowListener() {
     90        MasterWindowListener.setup();
     91        MasterWindowListener.teardown();
     92        assertNotNull(MasterWindowListener.getInstance());
     93    }
    8394}
  • trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java

    r10945 r11921  
    2323
    2424import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     25import net.trajano.commons.testing.UtilityClassTestUtil;
    2526
    2627/**
     
    3435    @Rule
    3536    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    36     public JOSMTestRules test = new JOSMTestRules();
     37    public JOSMTestRules test = new JOSMTestRules().projection();
    3738
    3839    @Test(expected = OrthogonalizeAction.InvalidUserInputException.class)
     
    8485    }
    8586
     87    /**
     88     * Tests that {@code OrthogonalizeAction.EN} satisfies utility class criterias.
     89     * @throws ReflectiveOperationException if an error occurs
     90     */
     91    @Test
     92    public void testUtilityClass() throws ReflectiveOperationException {
     93        UtilityClassTestUtil.assertUtilityClassWellDefined(OrthogonalizeAction.EN.class);
     94    }
     95
    8696    DataSet performTest(String... search) throws Exception {
    8797        try (FileInputStream in = new FileInputStream(TestUtils.getTestDataRoot() + "orthogonalize.osm")) {
  • trunk/test/unit/org/openstreetmap/josm/actions/SelectByInternalPointActionTest.java

    r11324 r11921  
    2121
    2222import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     23import net.trajano.commons.testing.UtilityClassTestUtil;
    2324
    2425/**
     
    3334    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3435    public JOSMTestRules rules = new JOSMTestRules().preferences().projection();
     36
     37    /**
     38     * Tests that {@code SelectByInternalPointAction} satisfies utility class criterias.
     39     * @throws ReflectiveOperationException if an error occurs
     40     */
     41    @Test
     42    public void testUtilityClass() throws ReflectiveOperationException {
     43        UtilityClassTestUtil.assertUtilityClassWellDefined(SelectByInternalPointAction.class);
     44    }
    3545
    3646    /**
  • trunk/test/unit/org/openstreetmap/josm/corrector/ReverseWayTagCorrectorTest.java

    r11069 r11921  
    1919
    2020import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     21import net.trajano.commons.testing.UtilityClassTestUtil;
    2122
    2223/**
     
    3132    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3233    public JOSMTestRules test = new JOSMTestRules();
     34
     35    /**
     36     * Tests that {@code ReverseWayTagCorrector.TagSwitcher} satisfies utility class criterias.
     37     * @throws ReflectiveOperationException if an error occurs
     38     */
     39    @Test
     40    public void testUtilityClass() throws ReflectiveOperationException {
     41        UtilityClassTestUtil.assertUtilityClassWellDefined(ReverseWayTagCorrector.TagSwitcher.class);
     42    }
    3343
    3444    /**
  • trunk/test/unit/org/openstreetmap/josm/data/CustomConfiguratorTest.java

    r10962 r11921  
    1818import org.openstreetmap.josm.Main;
    1919import org.openstreetmap.josm.TestUtils;
     20import org.openstreetmap.josm.data.CustomConfigurator.PreferencesUtils;
    2021import org.openstreetmap.josm.testutils.JOSMTestRules;
    2122import org.openstreetmap.josm.tools.Utils;
    2223
    2324import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     25import net.trajano.commons.testing.UtilityClassTestUtil;
    2426
    2527/**
     
    118120        assertEquals(9, pref.getCollection("lorem_ipsum").size());
    119121    }
     122
     123    /**
     124     * Tests that {@code PreferencesUtils} satisfies utility class criterias.
     125     * @throws ReflectiveOperationException if an error occurs
     126     */
     127    @Test
     128    public void testUtilityClass() throws ReflectiveOperationException {
     129        UtilityClassTestUtil.assertUtilityClassWellDefined(PreferencesUtils.class);
     130    }
    120131}
  • trunk/test/unit/org/openstreetmap/josm/data/cache/JCSCacheManagerTest.java

    r11324 r11921  
    1616
    1717import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import net.trajano.commons.testing.UtilityClassTestUtil;
    1819
    1920/**
     
    2829    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2930    public JOSMTestRules test = new JOSMTestRules().preferences();
     31
     32    /**
     33     * Tests that {@code JCSCacheManager} satisfies utility class criterias.
     34     * @throws ReflectiveOperationException if an error occurs
     35     */
     36    @Test
     37    public void testUtilityClass() throws ReflectiveOperationException {
     38        UtilityClassTestUtil.assertUtilityClassWellDefined(JCSCacheManager.class);
     39    }
    3040
    3141    /**
  • trunk/test/unit/org/openstreetmap/josm/data/oauth/SignpostAdaptersTest.java

    r10945 r11921  
    1919
    2020import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     21import net.trajano.commons.testing.UtilityClassTestUtil;
    2122
    2223/**
     
    3435    private static HttpClient newClient() throws MalformedURLException {
    3536        return HttpClient.create(new URL("https://www.openstreetmap.org"));
     37    }
     38
     39    /**
     40     * Tests that {@code SignpostAdapters} satisfies utility class criterias.
     41     * @throws ReflectiveOperationException if an error occurs
     42     */
     43    @Test
     44    public void testUtilityClass() throws ReflectiveOperationException {
     45        UtilityClassTestUtil.assertUtilityClassWellDefined(SignpostAdapters.class);
    3646    }
    3747
  • trunk/test/unit/org/openstreetmap/josm/gui/datatransfer/ClipboardUtilsTest.java

    r10604 r11921  
    2121
    2222import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     23import net.trajano.commons.testing.UtilityClassTestUtil;
    2324
    2425/**
     
    120121        assertNull(ClipboardUtils.getSystemSelection());
    121122    }
     123
     124    /**
     125     * Tests that {@code ClipboardUtils} satisfies utility class criterias.
     126     * @throws ReflectiveOperationException if an error occurs
     127     */
     128    @Test
     129    public void testUtilityClass() throws ReflectiveOperationException {
     130        UtilityClassTestUtil.assertUtilityClassWellDefined(ClipboardUtils.class);
     131    }
    122132}
  • trunk/test/unit/org/openstreetmap/josm/gui/mappaint/mapcss/ConditionFactoryTest.java

    r11562 r11921  
    66import org.openstreetmap.josm.gui.mappaint.mapcss.Condition.Context;
    77import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.Op;
     8import org.openstreetmap.josm.gui.mappaint.mapcss.ConditionFactory.PseudoClasses;
    89import org.openstreetmap.josm.testutils.JOSMTestRules;
    910
    1011import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     12import net.trajano.commons.testing.UtilityClassTestUtil;
    1113
    1214/**
     
    3032        ConditionFactory.createKeyValueCondition("name", "Rodovia ([A-Z]{2,3}-[0-9]{2,4}", Op.REGEX, Context.PRIMITIVE, false);
    3133    }
     34
     35    /**
     36     * Tests that {@code PseudoClasses} satisfies utility class criterias.
     37     * @throws ReflectiveOperationException if an error occurs
     38     */
     39    @Test
     40    public void testUtilityClass() throws ReflectiveOperationException {
     41        UtilityClassTestUtil.assertUtilityClassWellDefined(PseudoClasses.class);
     42    }
    3243}
  • trunk/test/unit/org/openstreetmap/josm/gui/tagging/presets/TaggingPresetReaderTest.java

    r10758 r11921  
    1313
    1414import org.junit.Assert;
    15 import org.junit.BeforeClass;
     15import org.junit.Rule;
    1616import org.junit.Test;
    17 import org.openstreetmap.josm.JOSMFixture;
    1817import org.openstreetmap.josm.TestUtils;
    1918import org.openstreetmap.josm.gui.tagging.presets.items.Check;
    2019import org.openstreetmap.josm.gui.tagging.presets.items.Key;
     20import org.openstreetmap.josm.testutils.JOSMTestRules;
    2121import org.xml.sax.SAXException;
     22
     23import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
    2224
    2325/**
     
    2729
    2830    /**
    29      * Setup test.
     31     * Setup rule
    3032     */
    31     @BeforeClass
    32     public static void setUp() {
    33         JOSMFixture.createUnitTestFixture().init();
    34     }
     33    @Rule
     34    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     35    public JOSMTestRules test = new JOSMTestRules().platform();
    3536
    3637    /**
  • trunk/test/unit/org/openstreetmap/josm/io/CertificateAmendmentTest.java

    r10324 r11921  
    99
    1010import org.junit.Assert;
    11 import org.junit.BeforeClass;
     11import org.junit.Rule;
    1212import org.junit.Test;
    13 import org.openstreetmap.josm.JOSMFixture;
     13import org.openstreetmap.josm.testutils.JOSMTestRules;
     14
     15import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     16import net.trajano.commons.testing.UtilityClassTestUtil;
    1417
    1518/**
     
    1922
    2023    /**
    21      * Setup test.
     24     * Setup rule
    2225     */
    23     @BeforeClass
    24     public static void setUp() {
    25         JOSMFixture.createUnitTestFixture().init();
     26    @Rule
     27    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
     28    public JOSMTestRules test = new JOSMTestRules();
     29
     30    /**
     31     * Tests that {@code CertificateAmendment} satisfies utility class criterias.
     32     * @throws ReflectiveOperationException if an error occurs
     33     */
     34    @Test
     35    public void testUtilityClass() throws ReflectiveOperationException {
     36        UtilityClassTestUtil.assertUtilityClassWellDefined(CertificateAmendment.class);
    2637    }
    2738
     
    5869    @Test
    5970    public void testStartSSL() throws IOException {
    60         connect("https://map.dgpsonline.eu", true);
    61         connect("https://www.startssl.com", true);
     71        // StartSSL is untrusted
     72        connect("https://www.startssl.com", false);
    6273    }
    6374
  • trunk/test/unit/org/openstreetmap/josm/tools/FontsManagerTest.java

    r11202 r11921  
    1212
    1313import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     14import net.trajano.commons.testing.UtilityClassTestUtil;
    1415
    1516/**
     
    4243        }
    4344    }
     45
     46    /**
     47     * Tests that {@code FontsManager} satisfies utility class criterias.
     48     * @throws ReflectiveOperationException if an error occurs
     49     */
     50    @Test
     51    public void testUtilityClass() throws ReflectiveOperationException {
     52        UtilityClassTestUtil.assertUtilityClassWellDefined(FontsManager.class);
     53    }
    4454}
  • trunk/test/unit/org/openstreetmap/josm/tools/RightAndLefthandTrafficTest.java

    r11324 r11921  
    1010
    1111import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     12import net.trajano.commons.testing.UtilityClassTestUtil;
    1213
    1314/**
     
    2122    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    2223    public JOSMTestRules rules = new JOSMTestRules().platform().projection().commands();
     24
     25    /**
     26     * Tests that {@code RightAndLefthandTraffic} satisfies utility class criterias.
     27     * @throws ReflectiveOperationException if an error occurs
     28     */
     29    @Test
     30    public void testUtilityClass() throws ReflectiveOperationException {
     31        UtilityClassTestUtil.assertUtilityClassWellDefined(RightAndLefthandTraffic.class);
     32    }
    2333
    2434    /**
  • trunk/test/unit/org/openstreetmap/josm/tools/TerritoriesTest.java

    r11360 r11921  
    1010
    1111import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     12import net.trajano.commons.testing.UtilityClassTestUtil;
    1213
    1314/**
     
    2324
    2425    /**
    25      * Test of {@link Territories#getIso3166Codes} method.
     26     * Tests that {@code Territories} satisfies utility class criterias.
     27     * @throws ReflectiveOperationException if an error occurs
    2628     */
    2729    @Test
    28     public void testGetIso3166Codes() {
     30    public void testUtilityClass() throws ReflectiveOperationException {
     31        UtilityClassTestUtil.assertUtilityClassWellDefined(Territories.class);
     32    }
     33
     34    /**
     35     * Test of {@link Territories#isIso3166Code} method.
     36     */
     37    @Test
     38    public void testIsIso3166Code() {
    2939        check("Paris", new LatLon(48.8567, 2.3508), "EU", "FR", "FX");
    3040    }
  • trunk/test/unit/org/openstreetmap/josm/tools/UtilsTest.java

    r11435 r11921  
    1818
    1919import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     20import net.trajano.commons.testing.UtilityClassTestUtil;
    2021
    2122/**
     
    2930    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3031    public JOSMTestRules rules = new JOSMTestRules();
     32
     33    /**
     34     * Tests that {@code Utils} satisfies utility class criterias.
     35     * @throws ReflectiveOperationException if an error occurs
     36     */
     37    @Test
     38    public void testUtilityClass() throws ReflectiveOperationException {
     39        UtilityClassTestUtil.assertUtilityClassWellDefined(Utils.class);
     40    }
    3141
    3242    /**
  • trunk/test/unit/org/openstreetmap/josm/tools/date/DateUtilsTest.java

    r11486 r11921  
    1616
    1717import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
     18import net.trajano.commons.testing.UtilityClassTestUtil;
    1819
    1920/**
     
    3031    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    3132    public JOSMTestRules test = new JOSMTestRules().i18n().preferences();
     33
     34    /**
     35     * Tests that {@code DateUtils} satisfies utility class criterias.
     36     * @throws ReflectiveOperationException if an error occurs
     37     */
     38    @Test
     39    public void testUtilityClass() throws ReflectiveOperationException {
     40        UtilityClassTestUtil.assertUtilityClassWellDefined(DateUtils.class);
     41    }
    3242
    3343    /**
     
    209219        }
    210220    }
    211 
    212     /**
    213      * Unit test to reach 100% code coverage.
    214      */
    215     @Test
    216     @SuppressFBWarnings(value = "ISC_INSTANTIATE_STATIC_CLASS")
    217     public void testCoverage() {
    218         assertNotNull(new DateUtils());
    219     }
    220221}
Note: See TracChangeset for help on using the changeset viewer.