Changeset 10876 in josm for trunk/test/unit
- Timestamp:
- 2016-08-22T22:05:45+02:00 (8 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r10850 r10876 91 91 System.setProperty("josm.home", josmHome); 92 92 TimeZone.setDefault(TimeZone.getTimeZone("UTC")); 93 Main. initApplicationPreferences();93 Main.pref.resetToInitialState(); 94 94 Main.pref.enableSaveOnPut(false); 95 95 I18n.init(); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r10758 r10876 17 17 import org.openstreetmap.josm.JOSMFixture; 18 18 import org.openstreetmap.josm.Main; 19 import org.openstreetmap.josm.data.Preferences;20 19 import org.openstreetmap.josm.data.coor.EastNorth; 21 20 import org.openstreetmap.josm.data.osm.DataSet; … … 32 31 */ 33 32 public class SelectActionTest { 34 35 /**36 * Override some configuration variables without change in preferences.xml37 */38 static class PreferencesMock extends Preferences {39 @Override40 public synchronized int getInteger(String key, int def) {41 if ("edit.initial-move-delay".equals(key)) {42 return 0;43 } else {44 return super.getInteger(key, def);45 }46 }47 }48 33 49 34 boolean nodesMerged; … … 104 89 dataSet.addSelected(w); 105 90 106 Main.pref = new PreferencesMock();91 Main.pref.put("edit.initial-move-delay", "0"); 107 92 Main.getLayerManager().addLayer(layer); 108 93 try { -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/RelationSorterTest.java
r8857 r10876 8 8 9 9 import org.junit.Assert; 10 import org.junit.BeforeClass; 10 import org.junit.Before; 11 import org.junit.Rule; 11 12 import org.junit.Test; 12 import org.openstreetmap.josm.Main;13 13 import org.openstreetmap.josm.data.osm.DataSet; 14 14 import org.openstreetmap.josm.data.osm.Relation; 15 15 import org.openstreetmap.josm.data.osm.RelationMember; 16 import org.openstreetmap.josm.data.projection.Projections;17 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 18 17 import org.openstreetmap.josm.io.IllegalDataException; 19 18 import org.openstreetmap.josm.io.OsmReader; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 20 22 21 23 /** … … 25 27 26 28 private final RelationSorter sorter = new RelationSorter(); 27 private staticDataSet testDataset;29 private DataSet testDataset; 28 30 29 @BeforeClass 30 public static void loadData() throws IllegalDataException, IOException { 31 Main.initApplicationPreferences(); 32 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 33 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) { 34 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 31 /** 32 * Use Mercator projection 33 */ 34 @Rule 35 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 36 public JOSMTestRules test = new JOSMTestRules().preferences().projection(); 37 38 /** 39 * Load the test data set 40 * @throws IllegalDataException if an error was found while parsing the data 41 * @throws IOException in case of I/O error 42 */ 43 @Before 44 public void loadData() throws IllegalDataException, IOException { 45 if (testDataset == null) { 46 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) { 47 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 48 } 35 49 } 36 50 } -
trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/sort/WayConnectionTypeCalculatorTest.java
r8857 r10876 9 9 10 10 import org.junit.Assert; 11 import org.junit.BeforeClass; 11 import org.junit.Before; 12 import org.junit.Rule; 12 13 import org.junit.Test; 13 import org.openstreetmap.josm.Main;14 14 import org.openstreetmap.josm.data.osm.DataSet; 15 15 import org.openstreetmap.josm.data.osm.Relation; 16 import org.openstreetmap.josm.data.projection.Projections;17 16 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 18 17 import org.openstreetmap.josm.io.IllegalDataException; 19 18 import org.openstreetmap.josm.io.OsmReader; 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 20 21 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 20 22 21 23 /** … … 26 28 private RelationSorter sorter = new RelationSorter(); 27 29 private WayConnectionTypeCalculator wayConnectionTypeCalculator = new WayConnectionTypeCalculator(); 28 private staticDataSet testDataset;30 private DataSet testDataset; 29 31 30 @BeforeClass 31 public static void loadData() throws IllegalDataException, IOException { 32 Main.initApplicationPreferences(); 33 Main.setProjection(Projections.getProjectionByCode("EPSG:3857")); // Mercator 34 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) { 35 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 32 /** 33 * Use Mercator projection 34 */ 35 @Rule 36 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 37 public JOSMTestRules test = new JOSMTestRules().preferences().projection(); 38 39 /** 40 * Load the test data set 41 * @throws IllegalDataException if an error was found while parsing the data 42 * @throws IOException in case of I/O error 43 */ 44 @Before 45 public void loadData() throws IllegalDataException, IOException { 46 if (testDataset == null) { 47 try (InputStream fis = new FileInputStream("data_nodist/relation_sort.osm")) { 48 testDataset = OsmReader.parseDataSet(fis, NullProgressMonitor.INSTANCE); 49 } 36 50 } 37 51 } -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r10604 r10876 201 201 // Add preferences 202 202 if (usePreferences) { 203 Main. initApplicationPreferences();203 Main.pref.resetToInitialState(); 204 204 Main.pref.enableSaveOnPut(false); 205 205 // No pref init -> that would only create the preferences file. … … 247 247 MemoryManagerTest.resetState(true); 248 248 Main.getLayerManager().resetState(); 249 Main.pref = null;249 Main.pref.resetToInitialState(); 250 250 Main.platform = null; 251 251 System.gc(); … … 268 268 269 269 // TODO: Remove global listeners and other global state. 270 Main.pref = null;270 Main.pref.resetToInitialState();; 271 271 Main.platform = null; 272 272 // Parts of JOSM uses weak references - destroy them.
Note:
See TracChangeset
for help on using the changeset viewer.