Changeset 11974 in josm for trunk/test/unit


Ignore:
Timestamp:
2017-04-22T17:57:11+02:00 (7 years ago)
Author:
Don-vip
Message:

add unit tests, javadoc

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

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/plugin/PluginPreferenceTest.java

    r10378 r11974  
    1717import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1818import org.openstreetmap.josm.plugins.PluginDownloadTask;
     19import org.openstreetmap.josm.plugins.PluginException;
    1920import org.openstreetmap.josm.plugins.PluginInformation;
    2021
     
    4142
    4243    /**
     44     * Returns a dummy plugin information.
     45     * @return a dummy plugin information
     46     * @throws PluginException if an error occurs
     47     */
     48    public static PluginInformation getDummyPluginInformation() throws PluginException {
     49        return new PluginInformation(
     50                new File(TestUtils.getTestDataRoot() + "plugin/dummy_plugin.jar"), "dummy_plugin");
     51    }
     52
     53    /**
    4354     * Unit test of {@link PluginPreference#buildDownloadSummary}.
    4455     * @throws Exception if an error occurs
     
    4657    @Test
    4758    public void testBuildDownloadSummary() throws Exception {
    48         final PluginInformation dummy = new PluginInformation(
    49                 new File(TestUtils.getTestDataRoot() + "plugin/dummy_plugin.jar"), "dummy_plugin");
     59        final PluginInformation dummy = getDummyPluginInformation();
    5060        assertEquals("", PluginPreference.buildDownloadSummary(
    5161                new PluginDownloadTask(NullProgressMonitor.INSTANCE, Collections.<PluginInformation>emptyList(), "")));
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java

    r10758 r11974  
    1515import org.openstreetmap.josm.JOSMFixture;
    1616import org.openstreetmap.josm.Main;
     17import org.openstreetmap.josm.gui.preferences.plugin.PluginPreferenceTest;
    1718import org.openstreetmap.josm.plugins.PluginHandler.DeprecatedPlugin;
     19import org.openstreetmap.josm.plugins.PluginHandler.PluginInformationAction;
    1820import org.openstreetmap.josm.tools.Utils;
    1921
     
    8486        assertFalse(plugins.contains("gpsbabelgui"));
    8587    }
     88
     89    /**
     90     * Unit test of {@link PluginInformationAction} class.
     91     * @throws PluginException if an error occurs
     92     */
     93    @Test
     94    public void testPluginInformationAction() throws PluginException {
     95        PluginInformationAction action = new PluginInformationAction(PluginPreferenceTest.getDummyPluginInformation());
     96        assertEquals(
     97                "Ant-Version: Apache Ant 1.9.6\n" +
     98                "Author: Don-vip\n" +
     99                "Created-By: 1.7.0_91-b02 (Oracle Corporation)\n" +
     100                "Manifest-Version: 1.0\n" +
     101                "Plugin-Canloadatruntime: true\n" +
     102                "Plugin-Class: org.openstreetmap.josm.plugins.fr.epci.EpciPlugin\n" +
     103                "Plugin-Date: 2015-11-19T08:21:07.645033Z\n" +
     104                "Plugin-Description: Handling of French EPCIs (boundary=local_authority)\n" +
     105                "Plugin-Early: true\n" +
     106                "Plugin-Link: http://wiki.openstreetmap.org/wiki/FR:JOSM/Fr:Plugin/EPCI-fr\n" +
     107                "Plugin-Mainversion: 7001\n" +
     108                "Plugin-Version: 31772\n", action.getText());
     109        action.actionPerformed(null);
     110    }
    86111}
  • trunk/test/unit/org/openstreetmap/josm/tools/template_engine/TemplateParserTest.java

    r11057 r11974  
    237237
    238238    @Test
     239    public void testSetAnd() throws ParseError {
     240        TemplateParser parser = new TemplateParser("!{(parent(type=child) type=parent) & (parent type=child subtype=parent) '{name}'}");
     241        DatasetFactory ds = new DatasetFactory();
     242        Relation parent1 = ds.addRelation(1);
     243        parent1.put("type", "parent");
     244        parent1.put("subtype", "parent");
     245        parent1.put("name", "name_parent1");
     246        Node child = ds.addNode(1);
     247        child.put("type", "child");
     248        parent1.addMember(new RelationMember("", child));
     249
     250        StringBuilder sb = new StringBuilder();
     251        TemplateEntry entry = parser.parse();
     252        entry.appendText(sb, child);
     253
     254        Assert.assertEquals("name_parent1", sb.toString());
     255    }
     256
     257    @Test
    239258    public void testSetOr() throws ParseError {
    240259        TemplateParser parser = new TemplateParser("!{(parent(type=type1) type=parent1) | (parent type=type2 type=parent2) '{name}'}");
Note: See TracChangeset for help on using the changeset viewer.