Changeset 10123 in josm


Ignore:
Timestamp:
2016-04-09T01:35:58+02:00 (8 years ago)
Author:
Don-vip
Message:

fix unit test failing with clean jenkins workspace

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/plugins/PluginListParser.java

    r8846 r10123  
    3434     * @throws PluginListParseException if plugin manifest cannot be parsed
    3535     */
    36     protected static PluginInformation createInfo(String name, String url, String manifest) throws PluginListParseException {
     36    public static PluginInformation createInfo(String name, String url, String manifest) throws PluginListParseException {
    3737        try {
    3838            return new PluginInformation(
  • trunk/src/org/openstreetmap/josm/plugins/ReadLocalPluginInformationTask.java

    r10043 r10123  
    1616import org.openstreetmap.josm.Main;
    1717import org.openstreetmap.josm.gui.PleaseWaitRunnable;
     18import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    1819import org.openstreetmap.josm.gui.progress.ProgressMonitor;
    1920import org.openstreetmap.josm.io.OsmTransferException;
     
    136137
    137138    protected void scanLocalPluginRepository(ProgressMonitor monitor, File pluginsDirectory) {
    138         if (pluginsDirectory == null) return;
     139        if (pluginsDirectory == null)
     140            return;
     141        if (monitor == null)
     142            monitor = NullProgressMonitor.INSTANCE;
    139143        try {
    140144            monitor.beginTask("");
  • trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java

    r10122 r10123  
    66import static org.junit.Assert.assertNull;
    77
     8import java.util.Arrays;
    89import java.util.Collection;
    910
     
    1617import org.openstreetmap.josm.gui.SplashScreen.SplashProgressMonitor;
    1718import org.openstreetmap.josm.plugins.PluginHandler;
     19import org.openstreetmap.josm.plugins.PluginHandlerTestIT;
    1820import org.openstreetmap.josm.plugins.PluginInformation;
     21import org.openstreetmap.josm.plugins.PluginListParseException;
     22import org.openstreetmap.josm.plugins.PluginListParser;
    1923
    2024/**
     
    3337    /**
    3438     * Test of {@link MainApplication#updateAndLoadEarlyPlugins} and {@link MainApplication#loadLatePlugins} methods.
     39     * @throws PluginListParseException if an error occurs
    3540     */
    3641    @Test
    37     public void testUpdateAndLoadPlugins() {
     42    public void testUpdateAndLoadPlugins() throws PluginListParseException {
    3843        final String old = System.getProperty("josm.plugins");
    3944        try {
     
    4651            });
    4752            Collection<PluginInformation> plugins = MainApplication.updateAndLoadEarlyPlugins(null, monitor);
     53            if (plugins.isEmpty()) {
     54                PluginHandlerTestIT.downloadPlugins(Arrays.asList(
     55                        newPluginInformation("buildings_tools"),
     56                        newPluginInformation("plastic_laf")));
     57                plugins = MainApplication.updateAndLoadEarlyPlugins(null, monitor);
     58            }
    4859            assertEquals(2, plugins.size());
    4960            assertNotNull(PluginHandler.getPlugin("plastic_laf"));
     
    5970        }
    6071    }
     72
     73    private static PluginInformation newPluginInformation(String plugin) throws PluginListParseException {
     74        //return new PluginInformation(new File(TestUtils.getTestDataRoot()+File.separator+"plugin"+File.separator+plugin+".jar"));
     75        return PluginListParser.createInfo(plugin+".jar", "https://svn.openstreetmap.org/applications/editors/josm/dist/"+plugin+".jar",
     76                "");
     77    }
    6178}
  • trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java

    r9815 r10123  
    77
    88import java.util.Arrays;
     9import java.util.Collection;
    910import java.util.Iterator;
    1011import java.util.List;
     
    6667        System.out.println("Filtered plugin list contains " + plugins.size() + " plugins");
    6768
    68         // Update the locally installed plugins
    69         PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(NullProgressMonitor.INSTANCE, plugins, null);
    70         pluginDownloadTask.run();
    71         assertTrue(pluginDownloadTask.getFailedPlugins().toString(), pluginDownloadTask.getFailedPlugins().isEmpty());
    72         assertEquals(plugins.size(), pluginDownloadTask.getDownloadedPlugins().size());
    73 
    74         // Update Plugin info for downloaded plugins
    75         PluginHandler.refreshLocalUpdatedPluginInfo(pluginDownloadTask.getDownloadedPlugins());
     69        // Download plugins
     70        downloadPlugins(plugins);
    7671
    7772        // Load early plugins
     
    8378        assertTrue(PluginHandler.pluginLoadingExceptions.toString(), PluginHandler.pluginLoadingExceptions.isEmpty());
    8479    }
     80
     81    /**
     82     * Download plugins
     83     * @param plugins plugins to download
     84     */
     85    public static void downloadPlugins(Collection<PluginInformation> plugins) {
     86        // Update the locally installed plugins
     87        PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(NullProgressMonitor.INSTANCE, plugins, null);
     88        pluginDownloadTask.run();
     89        assertTrue(pluginDownloadTask.getFailedPlugins().toString(), pluginDownloadTask.getFailedPlugins().isEmpty());
     90        assertEquals(plugins.size(), pluginDownloadTask.getDownloadedPlugins().size());
     91
     92        // Update Plugin info for downloaded plugins
     93        PluginHandler.refreshLocalUpdatedPluginInfo(pluginDownloadTask.getDownloadedPlugins());
     94    }
    8595}
Note: See TracChangeset for help on using the changeset viewer.