Changeset 10988 in josm for trunk/test
- Timestamp:
- 2016-09-10T16:13:02+02:00 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
r10986 r10988 13 13 import java.util.Map; 14 14 import java.util.Set; 15 import java.util.function.Consumer; 15 16 import java.util.stream.Collectors; 16 17 … … 23 24 import org.openstreetmap.josm.JOSMFixture; 24 25 import org.openstreetmap.josm.Main; 26 import org.openstreetmap.josm.data.gpx.GpxData; 25 27 import org.openstreetmap.josm.data.osm.DataSet; 28 import org.openstreetmap.josm.gui.layer.GpxLayer; 29 import org.openstreetmap.josm.gui.layer.Layer; 26 30 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 31 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; … … 90 94 .collect(Collectors.toMap(e -> e.getKey(), e -> ExceptionUtils.getRootCause(e.getValue()))); 91 95 92 // Add/remove a data layertwice to test basic plugin good behaviour96 // Add/remove layers twice to test basic plugin good behaviour 93 97 Map<String, Throwable> layerExceptions = new HashMap<>(); 94 98 List<PluginInformation> loadedPlugins = PluginHandler.getPlugins(); 95 99 for (int i = 0; i < 2; i++) { 96 100 OsmDataLayer layer = new OsmDataLayer(new DataSet(), "Layer "+i, null); 97 try { 98 Main.getLayerManager().addLayer(layer); 99 } catch (Exception | LinkageError t) { 100 Throwable root = ExceptionUtils.getRootCause(t); 101 layerExceptions.put(findFaultyPlugin(loadedPlugins, root), root); 102 } 103 try { 104 Main.getLayerManager().removeLayer(layer); 105 } catch (Exception | LinkageError t) { 106 Throwable root = ExceptionUtils.getRootCause(t); 107 layerExceptions.put(findFaultyPlugin(loadedPlugins, root), root); 108 } 101 testPlugin(Main.getLayerManager()::addLayer, layer, layerExceptions, loadedPlugins); 102 testPlugin(Main.getLayerManager()::removeLayer, layer, layerExceptions, loadedPlugins); 103 } 104 for (int i = 0; i < 2; i++) { 105 GpxLayer layer = new GpxLayer(new GpxData()); 106 testPlugin(Main.getLayerManager()::addLayer, layer, layerExceptions, loadedPlugins); 107 testPlugin(Main.getLayerManager()::removeLayer, layer, layerExceptions, loadedPlugins); 109 108 } 110 109 … … 114 113 Arrays.toString(layerExceptions.entrySet().toArray()); 115 114 assertTrue(msg, loadingExceptions.isEmpty() && layerExceptions.isEmpty()); 115 } 116 117 void testPlugin(Consumer<Layer> consumer, Layer layer, 118 Map<String, Throwable> layerExceptions, Collection<PluginInformation> loadedPlugins) { 119 try { 120 consumer.accept(layer); 121 } catch (Exception | LinkageError t) { 122 Throwable root = ExceptionUtils.getRootCause(t); 123 root.printStackTrace(); 124 layerExceptions.put(findFaultyPlugin(loadedPlugins, root), root); 125 } 116 126 } 117 127
Note:
See TracChangeset
for help on using the changeset viewer.