- Timestamp:
- 2016-08-22T22:05:45+02:00 (8 years ago)
- Location:
- trunk
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/TagInfoExtract.groovy
r10872 r10876 371 371 */ 372 372 def init() { 373 Main.initApplicationPreferences()374 373 Main.determinePlatformHook() 375 374 Main.pref.enableSaveOnPut(false) -
trunk/src/org/openstreetmap/josm/Main.java
r10858 r10876 168 168 * Global application preferences 169 169 */ 170 public static Preferences pref;170 public static final Preferences pref = new Preferences(); 171 171 172 172 /** … … 513 513 */ 514 514 public static volatile PlatformHook platform; 515 516 /**517 * Initializes {@code Main.pref} in normal application context.518 * @since 6471519 */520 public static void initApplicationPreferences() {521 Main.pref = new Preferences();522 }523 515 524 516 /** -
trunk/src/org/openstreetmap/josm/data/Preferences.java
r10839 r10876 779 779 } 780 780 781 /** 782 * Resets the preferences to their initial state. This resets all values and file associations. 783 * The default values and listeners are not removed. 784 * <p> 785 * It is meant to be called before {@link #init(boolean)} 786 * @since 10876 787 */ 788 public void resetToInitialState() { 789 resetToDefault(); 790 preferencesDir = null; 791 cacheDir = null; 792 userdataDir = null; 793 saveOnPut = true; 794 initSuccessful = false; 795 } 796 797 /** 798 * Reset all values stored in this map to the default values. This clears the preferences. 799 */ 781 800 public final void resetToDefault() { 782 801 settingsMap.clear(); -
trunk/src/org/openstreetmap/josm/gui/MainApplication.java
r10824 r10876 326 326 } 327 327 328 initApplicationPreferences();329 330 328 Policy.setPolicy(new Policy() { 331 329 // Permissions for plug-ins loaded when josm is started via webstart -
trunk/test/functional/org/openstreetmap/josm/tools/HttpClientTest.java
r10758 r10876 20 20 import org.junit.Assert; 21 21 import org.junit.Before; 22 import org.junit. BeforeClass;22 import org.junit.Rule; 23 23 import org.junit.Test; 24 import org.openstreetmap.josm.JOSMFixture;25 import org.openstreetmap.josm.Main;26 24 import org.openstreetmap.josm.TestUtils; 27 25 import org.openstreetmap.josm.data.Version; 28 26 import org.openstreetmap.josm.gui.progress.ProgressMonitor; 27 import org.openstreetmap.josm.testutils.JOSMTestRules; 28 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 29 30 30 31 /** … … 33 34 public class HttpClientTest { 34 35 36 @Rule 37 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 38 public JOSMTestRules test = new JOSMTestRules().preferences(); 39 35 40 private ProgressMonitor progress; 36 37 @BeforeClass38 public static void setUpBeforeClass() {39 JOSMFixture.createFunctionalTestFixture().init();40 }41 41 42 42 @Before … … 173 173 @Test 174 174 public void testOpenUrlGzip() throws IOException { 175 Main.initApplicationPreferences();176 175 final URL url = new URL("https://www.openstreetmap.org/trace/1613906/data"); 177 176 try (BufferedReader x = HttpClient.create(url).connect().uncompress(true).getContentReader()) { … … 186 185 @Test 187 186 public void testOpenUrlBzip() throws IOException { 188 Main.initApplicationPreferences();189 187 final URL url = new URL("https://www.openstreetmap.org/trace/785544/data"); 190 188 try (BufferedReader x = HttpClient.create(url).connect().uncompress(true).getContentReader()) { … … 199 197 @Test 200 198 public void testTicket9660() throws IOException { 201 Main.initApplicationPreferences();202 199 final URL url = new URL("http://www.openstreetmap.org/trace/1350010/data"); 203 200 try (BufferedReader x = HttpClient.create(url).connect() -
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.