Changeset 8938 in josm
- Timestamp:
- 2015-10-24T14:58:06+02:00 (9 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/plugins/PluginDownloadTask.java
r8855 r8938 162 162 for (PluginInformation d : toUpdate) { 163 163 if (canceled) return; 164 progressMonitor.subTask(tr("Downloading Plugin {0}...", d.name)); 164 String message = tr("Downloading Plugin {0}...", d.name); 165 Main.info(message); 166 progressMonitor.subTask(message); 165 167 progressMonitor.worked(1); 166 168 File pluginFile = new File(pluginDir, d.name + ".jar.new"); -
trunk/src/org/openstreetmap/josm/plugins/PluginHandler.java
r8928 r8938 232 232 233 233 /** 234 * All exceptions that occured during plugin loading 235 * @since 8938 236 */ 237 public static final Map<String, Exception> pluginLoadingExceptions = new HashMap<>(); 238 239 /** 234 240 * Global plugin ClassLoader. 235 241 */ … … 279 285 // notify user about removed deprecated plugins 280 286 // 281 StringBuilder sb = new StringBuilder( );287 StringBuilder sb = new StringBuilder(32); 282 288 sb.append("<html>") 283 289 .append(trn( … … 308 314 * 309 315 * Asks the user for every unmaintained plugin whether it should be removed. 316 * @param parent The parent Component used to display warning popup 310 317 * 311 318 * @param plugins the collection of plugins … … 316 323 continue; 317 324 } 318 String msg = 325 String msg = tr("<html>Loading of the plugin \"{0}\" was requested." 319 326 + "<br>This plugin is no longer developed and very likely will produce errors." 320 327 +"<br>It should be disabled.<br>Delete from preferences?</html>", unmaintained); … … 702 709 msg = null; 703 710 } catch (PluginException e) { 711 pluginLoadingExceptions.put(plugin.name, e); 704 712 Main.error(e); 705 713 if (e.getCause() instanceof ClassNotFoundException) { … … 708 716 } 709 717 } catch (Exception e) { 718 pluginLoadingExceptions.put(plugin.name, e); 710 719 Main.error(e); 711 720 } … … 1449 1458 } 1450 1459 1460 /** 1461 * Returns the set of deprecated and unmaintained plugins. 1462 * @return set of deprecated and unmaintained plugins names. 1463 * @since 8938 1464 */ 1465 public static Set<String> getDeprecatedAndUnmaintainedPlugins() { 1466 Set<String> result = new HashSet<>(DEPRECATED_PLUGINS.size() + UNMAINTAINED_PLUGINS.length); 1467 for (DeprecatedPlugin dp : DEPRECATED_PLUGINS) { 1468 result.add(dp.name); 1469 } 1470 result.addAll(Arrays.asList(UNMAINTAINED_PLUGINS)); 1471 return result; 1472 } 1473 1451 1474 private static class UpdatePluginsMessagePanel extends JPanel { 1452 1475 private JMultilineLabel lblMessage; -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTest.java
r8937 r8938 2 2 package org.openstreetmap.josm.plugins; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertTrue; 5 7 8 import java.util.Iterator; 6 9 import java.util.List; 10 import java.util.Set; 7 11 8 12 import org.junit.BeforeClass; … … 10 14 import org.openstreetmap.josm.JOSMFixture; 11 15 import org.openstreetmap.josm.Main; 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 12 17 13 18 /** 14 * Unit tests of {@link ReadRemotePluginInformationTask} class.19 * Unit tests of {@link PluginHandler} class. 15 20 */ 16 public class ReadRemotePluginInformationTaskTest {21 public class PluginHandlerTest { 17 22 18 23 /** … … 21 26 @BeforeClass 22 27 public static void setUp() { 23 JOSMFixture.createUnitTestFixture().init( );28 JOSMFixture.createUnitTestFixture().init(true); 24 29 } 25 30 26 31 /** 27 * Test of plugin list download.32 * Test that available plugins rules can be loaded. 28 33 */ 29 34 @Test 30 public void testDownloadPluginList() { 35 public void testValidityOfAvailablePlugins() { 36 // Download complete list of plugins 31 37 ReadRemotePluginInformationTask pluginInfoDownloadTask = new ReadRemotePluginInformationTask( 32 38 Main.pref.getOnlinePluginSites()); 33 39 pluginInfoDownloadTask.run(); 34 List<PluginInformation> list = pluginInfoDownloadTask.getAvailablePlugins(); 35 assertFalse(list.isEmpty()); 36 PluginInformation info = list.get(0); 40 List<PluginInformation> plugins = pluginInfoDownloadTask.getAvailablePlugins(); 41 System.out.println("Original plugin list contains " + plugins.size() + " plugins"); 42 assertFalse(plugins.isEmpty()); 43 PluginInformation info = plugins.get(0); 37 44 assertFalse(info.getName().isEmpty()); 38 45 assertFalse(info.getClass().getName().isEmpty()); 46 47 // Filter deprecated and unmaintained ones 48 Set<String> deprecatedPlugins = PluginHandler.getDeprecatedAndUnmaintainedPlugins(); 49 for (Iterator<PluginInformation> it = plugins.iterator(); it.hasNext();) { 50 PluginInformation pi = it.next(); 51 if (deprecatedPlugins.contains(pi.name)) { 52 it.remove(); 53 } 54 } 55 System.out.println("Filtered plugin list contains " + plugins.size() + " plugins"); 56 57 // Update the locally installed plugins 58 PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(NullProgressMonitor.INSTANCE, plugins, null); 59 pluginDownloadTask.run(); 60 assertTrue(pluginDownloadTask.getFailedPlugins().toString(), pluginDownloadTask.getFailedPlugins().isEmpty()); 61 assertEquals(plugins.size(), pluginDownloadTask.getDownloadedPlugins().size()); 62 63 // Update Plugin info for downloaded plugins 64 PluginHandler.refreshLocalUpdatedPluginInfo(pluginDownloadTask.getDownloadedPlugins()); 65 66 // Load early plugins 67 PluginHandler.loadEarlyPlugins(null, plugins, null); 68 69 // Load late plugins 70 PluginHandler.loadLatePlugins(null, plugins, null); 71 72 assertTrue(PluginHandler.pluginLoadingExceptions.toString(), PluginHandler.pluginLoadingExceptions.isEmpty()); 39 73 } 40 74 }
Note:
See TracChangeset
for help on using the changeset viewer.