Changeset 12849 in josm
- Timestamp:
- 2017-09-14T00:22:37+02:00 (7 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/JOSMFixture.java
r12848 r12849 108 108 Logging.setLogLevel(Logging.LEVEL_INFO); 109 109 Main.pref.init(false); 110 String url = Main.pref.get("osm-server.url");110 String url = Config.getPref().get("osm-server.url"); 111 111 if (url == null || url.isEmpty() || isProductionApiUrl(url)) { 112 Main.pref.put("osm-server.url", "http://api06.dev.openstreetmap.org/api");113 } 114 I18n.set( Main.pref.get("language", "en"));112 Config.getPref().put("osm-server.url", "http://api06.dev.openstreetmap.org/api"); 113 } 114 I18n.set(Config.getPref().get("language", "en")); 115 115 116 116 try { -
trunk/test/unit/org/openstreetmap/josm/actions/MergeNodesActionTest.java
r12842 r12849 10 10 import org.junit.Rule; 11 11 import org.junit.Test; 12 import org.openstreetmap.josm.Main;13 12 import org.openstreetmap.josm.data.coor.LatLon; 14 13 import org.openstreetmap.josm.data.osm.DataSet; 15 14 import org.openstreetmap.josm.data.osm.Node; 15 import org.openstreetmap.josm.spi.preferences.Config; 16 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 17 … … 43 43 @Test(expected = IllegalStateException.class) 44 44 public void testSelectTargetLocationNodeInvalidMode() { 45 Main.pref.putInt("merge-nodes.mode", -1);45 Config.getPref().putInt("merge-nodes.mode", -1); 46 46 MergeNodesAction.selectTargetLocationNode(Arrays.asList(new Node(0), new Node(1))); 47 47 } … … 52 52 @Test 53 53 public void testSelectTargetLocationNode() { 54 Main.pref.putInt("merge-nodes.mode", 0);54 Config.getPref().putInt("merge-nodes.mode", 0); 55 55 assertEquals(1, MergeNodesAction.selectTargetLocationNode(Arrays.asList(new Node(0), new Node(1))).getId()); 56 56 57 Main.pref.putInt("merge-nodes.mode", 1);57 Config.getPref().putInt("merge-nodes.mode", 1); 58 58 assertEquals(LatLon.ZERO, MergeNodesAction.selectTargetLocationNode( 59 59 Arrays.asList(new Node(LatLon.NORTH_POLE), new Node(LatLon.SOUTH_POLE))).getCoor()); 60 60 61 Main.pref.putInt("merge-nodes.mode", 2);61 Config.getPref().putInt("merge-nodes.mode", 2); 62 62 assertEquals(LatLon.NORTH_POLE, MergeNodesAction.selectTargetLocationNode( 63 63 Arrays.asList(new Node(LatLon.NORTH_POLE))).getCoor()); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r12636 r12849 14 14 import org.junit.Rule; 15 15 import org.junit.Test; 16 import org.openstreetmap.josm.Main;17 16 import org.openstreetmap.josm.TestUtils; 18 17 import org.openstreetmap.josm.actions.mapmode.SelectAction.Mode; … … 26 25 import org.openstreetmap.josm.gui.layer.MainLayerManager; 27 26 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 27 import org.openstreetmap.josm.spi.preferences.Config; 28 28 import org.openstreetmap.josm.testutils.JOSMTestRules; 29 29 import org.openstreetmap.josm.tools.Utils; … … 88 88 dataSet.addSelected(w); 89 89 90 Main.pref.put("edit.initial-move-delay", "0");90 Config.getPref().put("edit.initial-move-delay", "0"); 91 91 MainApplication.getLayerManager().addLayer(layer); 92 92 try { -
trunk/test/unit/org/openstreetmap/josm/data/UserIdentityManagerTest.java
r12747 r12849 11 11 import org.junit.Rule; 12 12 import org.junit.Test; 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.data.osm.User; 15 14 import org.openstreetmap.josm.data.osm.UserInfo; 15 import org.openstreetmap.josm.spi.preferences.Config; 16 16 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 17 … … 188 188 189 189 // for this test we disable the listener 190 Main.pref.removePreferenceChangeListener(im);191 192 try { 193 Main.pref.put("osm-server.url", null);194 Main.pref.put("osm-server.username", null);190 Config.getPref().removePreferenceChangeListener(im); 191 192 try { 193 Config.getPref().put("osm-server.url", null); 194 Config.getPref().put("osm-server.username", null); 195 195 196 196 im.initFromPreferences(); … … 198 198 assertTrue(im.isAnonymous()); 199 199 } finally { 200 Main.pref.addPreferenceChangeListener(im);200 Config.getPref().addPreferenceChangeListener(im); 201 201 } 202 202 } … … 213 213 214 214 // for this test we disable the listener 215 Main.pref.removePreferenceChangeListener(im);216 217 try { 218 Main.pref.put("osm-server.url", "http://api.openstreetmap.org");219 Main.pref.put("osm-server.username", null);215 Config.getPref().removePreferenceChangeListener(im); 216 217 try { 218 Config.getPref().put("osm-server.url", "http://api.openstreetmap.org"); 219 Config.getPref().put("osm-server.username", null); 220 220 221 221 im.initFromPreferences(); … … 223 223 assertTrue(im.isAnonymous()); 224 224 } finally { 225 Main.pref.addPreferenceChangeListener(im);225 Config.getPref().addPreferenceChangeListener(im); 226 226 } 227 227 } … … 235 235 236 236 // for this test we disable the listener 237 Main.pref.removePreferenceChangeListener(im);237 Config.getPref().removePreferenceChangeListener(im); 238 238 239 239 try { … … 241 241 im.setAnonymous(); 242 242 243 Main.pref.put("osm-server.url", "http://api.openstreetmap.org");244 Main.pref.put("osm-server.username", "test");243 Config.getPref().put("osm-server.url", "http://api.openstreetmap.org"); 244 Config.getPref().put("osm-server.username", "test"); 245 245 246 246 im.initFromPreferences(); … … 248 248 assertTrue(im.isPartiallyIdentified()); 249 249 } finally { 250 Main.pref.addPreferenceChangeListener(im);250 Config.getPref().addPreferenceChangeListener(im); 251 251 } 252 252 } … … 262 262 263 263 // for this test we disable the listener 264 Main.pref.removePreferenceChangeListener(im);264 Config.getPref().removePreferenceChangeListener(im); 265 265 266 266 try { 267 267 im.setFullyIdentified("test1", newUserInfo()); 268 268 269 Main.pref.put("osm-server.url", "http://api.openstreetmap.org");270 Main.pref.put("osm-server.username", "test2");269 Config.getPref().put("osm-server.url", "http://api.openstreetmap.org"); 270 Config.getPref().put("osm-server.username", "test2"); 271 271 272 272 im.initFromPreferences(); … … 274 274 assertTrue(im.isPartiallyIdentified()); 275 275 } finally { 276 Main.pref.addPreferenceChangeListener(im);276 Config.getPref().addPreferenceChangeListener(im); 277 277 } 278 278 } … … 288 288 289 289 // for this test we disable the listener 290 Main.pref.removePreferenceChangeListener(im);290 Config.getPref().removePreferenceChangeListener(im); 291 291 292 292 try { 293 293 im.setFullyIdentified("test1", new UserInfo()); 294 294 295 Main.pref.put("osm-server.url", "http://api.openstreetmap.org");296 Main.pref.put("osm-server.username", "test1");295 Config.getPref().put("osm-server.url", "http://api.openstreetmap.org"); 296 Config.getPref().put("osm-server.username", "test1"); 297 297 298 298 im.initFromPreferences(); … … 300 300 assertTrue(im.isFullyIdentified()); 301 301 } finally { 302 Main.pref.addPreferenceChangeListener(im);302 Config.getPref().addPreferenceChangeListener(im); 303 303 } 304 304 } … … 311 311 im.setAnonymous(); 312 312 313 Main.pref.put("osm-server.url", "http://api.openstreetmap.org");314 assertTrue(im.isAnonymous()); 315 316 Main.pref.put("osm-server.url", null);313 Config.getPref().put("osm-server.url", "http://api.openstreetmap.org"); 314 assertTrue(im.isAnonymous()); 315 316 Config.getPref().put("osm-server.url", null); 317 317 assertTrue(im.isAnonymous()); 318 318 … … 320 320 im.setPartiallyIdentified("test"); 321 321 322 Main.pref.put("osm-server.url", "http://api.openstreetmap.org");323 assertTrue(im.isPartiallyIdentified()); 324 assertEquals("test", im.getUserName()); 325 326 Main.pref.put("osm-server.url", null);322 Config.getPref().put("osm-server.url", "http://api.openstreetmap.org"); 323 assertTrue(im.isPartiallyIdentified()); 324 assertEquals("test", im.getUserName()); 325 326 Config.getPref().put("osm-server.url", null); 327 327 assertTrue(im.isAnonymous()); 328 328 … … 330 330 im.setFullyIdentified("test", newUserInfo()); 331 331 332 Main.pref.put("osm-server.url", "http://api.openstreetmap.org");332 Config.getPref().put("osm-server.url", "http://api.openstreetmap.org"); 333 333 assertTrue(im.isPartiallyIdentified()); 334 334 assertEquals("test", im.getUserName()); … … 337 337 im.setFullyIdentified("test", newUserInfo()); 338 338 339 Main.pref.put("osm-server.url", null);339 Config.getPref().put("osm-server.url", null); 340 340 assertTrue(im.isAnonymous()); 341 341 } … … 348 348 im.setAnonymous(); 349 349 350 Main.pref.put("osm-server.username", "test");351 assertTrue(im.isPartiallyIdentified()); 352 assertEquals("test", im.getUserName()); 353 354 Main.pref.put("osm-server.username", null);350 Config.getPref().put("osm-server.username", "test"); 351 assertTrue(im.isPartiallyIdentified()); 352 assertEquals("test", im.getUserName()); 353 354 Config.getPref().put("osm-server.username", null); 355 355 assertTrue(im.isAnonymous()); 356 356 assertEquals(User.getAnonymous(), im.asUser()); … … 359 359 im.setPartiallyIdentified("test1"); 360 360 361 Main.pref.put("osm-server.username", "test2");361 Config.getPref().put("osm-server.username", "test2"); 362 362 assertTrue(im.isPartiallyIdentified()); 363 363 assertEquals("test2", im.getUserName()); … … 366 366 assertEquals("test2", usr.getName()); 367 367 368 Main.pref.put("osm-server.username", null);368 Config.getPref().put("osm-server.username", null); 369 369 assertTrue(im.isAnonymous()); 370 370 … … 372 372 im.setFullyIdentified("test1", newUserInfo()); 373 373 374 Main.pref.put("osm-server.username", "test2");374 Config.getPref().put("osm-server.username", "test2"); 375 375 assertTrue(im.isPartiallyIdentified()); 376 376 assertEquals("test2", im.getUserName()); … … 382 382 im.setFullyIdentified("test1", newUserInfo()); 383 383 384 Main.pref.put("osm-server.username", null);384 Config.getPref().put("osm-server.username", null); 385 385 assertTrue(im.isAnonymous()); 386 386 } -
trunk/test/unit/org/openstreetmap/josm/data/preferences/ColorPropertyTest.java
r10824 r12849 9 9 import org.junit.Rule; 10 10 import org.junit.Test; 11 import org.openstreetmap.josm. Main;11 import org.openstreetmap.josm.spi.preferences.Config; 12 12 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 13 … … 42 42 assertEquals(Color.RED, base.get()); 43 43 44 Main.pref.put("color.test", "#00ff00");44 Config.getPref().put("color.test", "#00ff00"); 45 45 assertEquals(new Color(0xff00ff00), base.get()); 46 46 } … … 55 55 base.put(new Color(0xff00ff00)); 56 56 assertEquals(new Color(0xff00ff00), base.get()); 57 assertEquals("#00ff00", Main.pref.get("color.test").toLowerCase());57 assertEquals("#00ff00", Config.getPref().get("color.test").toLowerCase()); 58 58 59 59 base.put(null); -
trunk/test/unit/org/openstreetmap/josm/data/preferences/StrokePropertyTest.java
r10874 r12849 9 9 import org.junit.Rule; 10 10 import org.junit.Test; 11 import org.openstreetmap.josm. Main;11 import org.openstreetmap.josm.spi.preferences.Config; 12 12 import org.openstreetmap.josm.testutils.JOSMTestRules; 13 13 … … 33 33 StrokeProperty property = new StrokeProperty("x", "1"); 34 34 35 Main.pref.put("x", "11");35 Config.getPref().put("x", "11"); 36 36 BasicStroke bs = property.get(); 37 37 assertWide(bs); … … 39 39 assertEquals(null, bs.getDashArray()); 40 40 41 Main.pref.put("x", ".5");41 Config.getPref().put("x", ".5"); 42 42 bs = property.get(); 43 43 assertThin(bs); … … 45 45 assertEquals(null, bs.getDashArray()); 46 46 47 Main.pref.put("x", "2 1");47 Config.getPref().put("x", "2 1"); 48 48 bs = property.get(); 49 49 assertWide(bs); … … 51 51 assertArrayEquals(new float[] {1}, bs.getDashArray(), 1e-10f); 52 52 53 Main.pref.put("x", "2 0.1 1 10");53 Config.getPref().put("x", "2 0.1 1 10"); 54 54 bs = property.get(); 55 55 assertWide(bs); … … 57 57 assertArrayEquals(new float[] {0.1f, 1, 10}, bs.getDashArray(), 1e-10f); 58 58 59 Main.pref.put("x", "x");59 Config.getPref().put("x", "x"); 60 60 bs = property.get(); 61 61 assertThin(bs); … … 64 64 65 65 // ignore dashes 66 Main.pref.put("x", "11 0 0 0.0001");66 Config.getPref().put("x", "11 0 0 0.0001"); 67 67 bs = property.get(); 68 68 assertWide(bs); -
trunk/test/unit/org/openstreetmap/josm/gui/MainApplicationTest.java
r12643 r12849 41 41 import org.openstreetmap.josm.plugins.PluginListParseException; 42 42 import org.openstreetmap.josm.plugins.PluginListParser; 43 import org.openstreetmap.josm.spi.preferences.Config; 43 44 import org.openstreetmap.josm.testutils.JOSMTestRules; 44 45 import org.openstreetmap.josm.tools.Logging; … … 205 206 public void testSetupUIManager() { 206 207 MainApplication.setupUIManager(); 207 assertEquals( Main.pref.get("laf", Main.platform.getDefaultStyle()), UIManager.getLookAndFeel().getClass().getCanonicalName());208 assertEquals(Config.getPref().get("laf", Main.platform.getDefaultStyle()), UIManager.getLookAndFeel().getClass().getCanonicalName()); 208 209 } 209 210 -
trunk/test/unit/org/openstreetmap/josm/gui/io/CustomConfiguratorTest.java
r12842 r12849 15 15 import org.junit.Rule; 16 16 import org.junit.Test; 17 import org.openstreetmap.josm.Main;18 17 import org.openstreetmap.josm.TestUtils; 19 18 import org.openstreetmap.josm.data.Preferences; 20 19 import org.openstreetmap.josm.data.PreferencesUtils; 20 import org.openstreetmap.josm.spi.preferences.Config; 21 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 22 import org.openstreetmap.josm.tools.Utils; … … 44 44 File tmp = File.createTempFile("josm.testExportPreferencesKeysToFile.lorem_ipsum", ".xml"); 45 45 46 Main.pref.putList("lorem_ipsum", Arrays.asList(46 Config.getPref().putList("lorem_ipsum", Arrays.asList( 47 47 "Lorem ipsum dolor sit amet, consectetur adipiscing elit.", 48 48 "Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor.", … … 57 57 String xml = Utils.join("\n", Files.readAllLines(tmp.toPath(), StandardCharsets.UTF_8)); 58 58 assertTrue(xml.contains("<preferences operation=\"replace\">")); 59 for (String entry : Main.pref.getList("lorem_ipsum")) {59 for (String entry : Config.getPref().getList("lorem_ipsum")) { 60 60 assertTrue(entry + "\nnot found in:\n" + xml, xml.contains(entry)); 61 61 } 62 62 63 Main.pref.putList("test", Arrays.asList("11111111", "2222222", "333333333"));63 Config.getPref().putList("test", Arrays.asList("11111111", "2222222", "333333333")); 64 64 CustomConfigurator.exportPreferencesKeysByPatternToFile(tmp.getAbsolutePath(), true, "test"); 65 65 xml = Utils.join("\n", Files.readAllLines(tmp.toPath(), StandardCharsets.UTF_8)); 66 66 assertTrue(xml.contains("<preferences operation=\"append\">")); 67 for (String entry : Main.pref.getList("test")) {67 for (String entry : Config.getPref().getList("test")) { 68 68 assertTrue(entry + "\nnot found in:\n" + xml, xml.contains(entry)); 69 69 } … … 79 79 public void testReadXML() throws IOException { 80 80 // Test 1 - read(dir, file) + append 81 Main.pref.putList("test", Collections.<String>emptyList());82 assertTrue( Main.pref.getList("test").isEmpty());81 Config.getPref().putList("test", Collections.<String>emptyList()); 82 assertTrue(Config.getPref().getList("test").isEmpty()); 83 83 CustomConfigurator.readXML(TestUtils.getTestDataRoot() + "customconfigurator", "append.xml"); 84 84 String log = PreferencesUtils.getLog(); 85 85 assertFalse(log, log.contains("Error")); 86 assertFalse( Main.pref.getList("test").isEmpty());86 assertFalse(Config.getPref().getList("test").isEmpty()); 87 87 88 88 // Test 2 - read(file, pref) + replace -
trunk/test/unit/org/openstreetmap/josm/gui/layer/gpx/GpxDrawHelperTest.java
r12842 r12849 11 11 import org.junit.Rule; 12 12 import org.junit.Test; 13 import org.openstreetmap.josm.Main;14 13 import org.openstreetmap.josm.TestUtils; 15 14 import org.openstreetmap.josm.data.gpx.GpxData; 16 15 import org.openstreetmap.josm.gui.layer.GpxLayer; 17 16 import org.openstreetmap.josm.io.GpxReaderTest; 17 import org.openstreetmap.josm.spi.preferences.Config; 18 18 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 19 import org.openstreetmap.josm.tools.ColorHelper; … … 42 42 @Test 43 43 public void testTicket12312() throws FileNotFoundException, IOException, SAXException { 44 Main.pref.putBoolean("draw.rawgps.colors.dynamic.layer 12312", true);45 Main.pref.putInt("draw.rawgps.colors.layer 12312", GpxDrawHelper.ColorMode.VELOCITY.toIndex());44 Config.getPref().putBoolean("draw.rawgps.colors.dynamic.layer 12312", true); 45 Config.getPref().putInt("draw.rawgps.colors.layer 12312", GpxDrawHelper.ColorMode.VELOCITY.toIndex()); 46 46 final List<String> colors = calculateColors(TestUtils.getRegressionDataFile(12312, "single_trackpoint.gpx"), "12312", 1); 47 47 assertEquals("[#FF00FF]", colors.toString()); … … 68 68 @Test 69 69 public void testVelocity() throws IOException, SAXException { 70 Main.pref.putInt("draw.rawgps.colors.layer 001", GpxDrawHelper.ColorMode.VELOCITY.toIndex());70 Config.getPref().putInt("draw.rawgps.colors.layer 001", GpxDrawHelper.ColorMode.VELOCITY.toIndex()); 71 71 final List<String> colors = calculateColors("data_nodist/2094047.gpx", "001", 10); 72 72 assertEquals("[#FF00FF, #FFAD00, #FFA800, #FFA800, #FF9E00, #FF9400, #FF7000, #FF7000, #FF8000, #FF9400]", colors.toString()); … … 81 81 @Test 82 82 public void testVelocityDynamic() throws IOException, SAXException { 83 Main.pref.putInt("draw.rawgps.colors.layer 002", GpxDrawHelper.ColorMode.VELOCITY.toIndex());84 Main.pref.putBoolean("draw.rawgps.colors.dynamic.layer 002", true);83 Config.getPref().putInt("draw.rawgps.colors.layer 002", GpxDrawHelper.ColorMode.VELOCITY.toIndex()); 84 Config.getPref().putBoolean("draw.rawgps.colors.dynamic.layer 002", true); 85 85 final List<String> colors = calculateColors("data_nodist/2094047.gpx", "002", 10); 86 86 assertEquals("[#FF00FF, #00FFE0, #00FFC2, #00FFC2, #00FF75, #00FF3D, #99FF00, #94FF00, #38FF00, #00FF38]", colors.toString()); … … 95 95 @Test 96 96 public void testDirection() throws IOException, SAXException { 97 Main.pref.putInt("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.DIRECTION.toIndex());97 Config.getPref().putInt("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.DIRECTION.toIndex()); 98 98 final List<String> colors = calculateColors("data_nodist/2094047.gpx", "003", 10); 99 99 assertEquals("[#FF00FF, #EAEC25, #EDEA26, #EDE525, #ECD322, #EBB81D, #E85A0D, #E73708, #E84D0B, #EA8A15]", colors.toString()); … … 108 108 @Test 109 109 public void testTime() throws IOException, SAXException { 110 Main.pref.putInt("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.TIME.toIndex());110 Config.getPref().putInt("draw.rawgps.colors.layer 003", GpxDrawHelper.ColorMode.TIME.toIndex()); 111 111 final List<String> colors = calculateColors("data_nodist/2094047.gpx", "003", 10); 112 112 assertEquals("[#FF00FF, #FF0000, #FF0000, #FF0500, #FF0500, #FF0A00, #FF0A00, #FF1F00, #FF2E00, #FF3300]", colors.toString()); -
trunk/test/unit/org/openstreetmap/josm/gui/layer/markerlayer/MarkerLayerTest.java
r12842 r12849 12 12 import org.junit.Rule; 13 13 import org.junit.Test; 14 import org.openstreetmap.josm.Main;15 14 import org.openstreetmap.josm.data.coor.LatLon; 16 15 import org.openstreetmap.josm.data.gpx.GpxConstants; … … 19 18 import org.openstreetmap.josm.data.gpx.WayPoint; 20 19 import org.openstreetmap.josm.gui.MainApplication; 20 import org.openstreetmap.josm.spi.preferences.Config; 21 21 import org.openstreetmap.josm.testutils.JOSMTestRules; 22 22 … … 40 40 @Before 41 41 public void setUp() { 42 Main.pref.putBoolean("marker.traceaudio", true);42 Config.getPref().putBoolean("marker.traceaudio", true); 43 43 } 44 44 -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/audio/AudioPreferenceTest.java
r12842 r12849 7 7 import org.junit.Test; 8 8 import org.openstreetmap.josm.JOSMFixture; 9 import org.openstreetmap.josm.Main;10 9 import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; 10 import org.openstreetmap.josm.spi.preferences.Config; 11 11 12 12 /** … … 36 36 @Test 37 37 public void testAddGui() { 38 Main.pref.putBoolean("audio.menuinvisible", true);38 Config.getPref().putBoolean("audio.menuinvisible", true); 39 39 PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null); 40 Main.pref.putBoolean("audio.menuinvisible", false);40 Config.getPref().putBoolean("audio.menuinvisible", false); 41 41 PreferencesTestUtils.doTestPreferenceSettingAddGui(new AudioPreference.Factory(), null); 42 42 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTest.java
r12842 r12849 9 9 import org.junit.Rule; 10 10 import org.junit.Test; 11 import org.openstreetmap.josm.Main;12 11 import org.openstreetmap.josm.TestUtils; 13 12 import org.openstreetmap.josm.gui.preferences.PreferencesTestUtils; 13 import org.openstreetmap.josm.spi.preferences.Config; 14 14 import org.openstreetmap.josm.testutils.JOSMTestRules; 15 15 … … 42 42 public void testAddGui() { 43 43 String fileUrl = new File(TestUtils.getTestDataRoot()+"__files/imagery/maps.xml").toURI().toString(); 44 Main.pref.putList("imagery.layers.sites", Arrays.asList(fileUrl));44 Config.getPref().putList("imagery.layers.sites", Arrays.asList(fileUrl)); 45 45 PreferencesTestUtils.doTestPreferenceSettingAddGui(new ImageryPreference.Factory(), null); 46 46 } -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java
r12842 r12849 17 17 import org.junit.rules.Timeout; 18 18 import org.openstreetmap.josm.JOSMFixture; 19 import org.openstreetmap.josm.Main;20 19 import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry; 21 20 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 22 21 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; 22 import org.openstreetmap.josm.spi.preferences.Config; 23 23 import org.openstreetmap.josm.tools.ImageProvider; 24 24 import org.openstreetmap.josm.tools.Logging; … … 58 58 assertFalse(sources.isEmpty()); 59 59 // Double traditional timeouts to avoid random problems 60 Main.pref.putInt("socket.timeout.connect", 30);61 Main.pref.putInt("socket.timeout.read", 60);60 Config.getPref().putInt("socket.timeout.connect", 30); 61 Config.getPref().putInt("socket.timeout.read", 60); 62 62 Map<Object, Throwable> allErrors = new HashMap<>(); 63 63 Set<String> allMessages = new HashSet<>(); -
trunk/test/unit/org/openstreetmap/josm/gui/util/WindowGeometryTest.java
r12679 r12849 16 16 import org.junit.Rule; 17 17 import org.junit.Test; 18 import org.openstreetmap.josm.Main;19 18 import org.openstreetmap.josm.gui.util.WindowGeometry.WindowGeometryException; 19 import org.openstreetmap.josm.spi.preferences.Config; 20 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 21 … … 53 53 assertEquals(new WindowGeometry(new Point(300, 250), dim), WindowGeometry.centerOnScreen(dim, null)); 54 54 55 Main.pref.put("gui.geometry", "x=0,y=0,width=800,height=600");55 Config.getPref().put("gui.geometry", "x=0,y=0,width=800,height=600"); 56 56 assertEquals(new WindowGeometry(new Point(300, 250), dim), WindowGeometry.centerOnScreen(dim)); 57 57 } … … 63 63 @Test(expected = WindowGeometryException.class) 64 64 public void testWindowGeometryException1() throws WindowGeometryException { 65 Main.pref.put("test", null);65 Config.getPref().put("test", null); 66 66 new WindowGeometry("test"); 67 67 } … … 73 73 @Test(expected = WindowGeometryException.class) 74 74 public void testWindowGeometryException2() throws WindowGeometryException { 75 Main.pref.put("test", "");75 Config.getPref().put("test", ""); 76 76 new WindowGeometry("test"); 77 77 } … … 83 83 @Test(expected = WindowGeometryException.class) 84 84 public void testWindowGeometryException3() throws WindowGeometryException { 85 Main.pref.put("test", "x=not_a_number");85 Config.getPref().put("test", "x=not_a_number"); 86 86 new WindowGeometry("test"); 87 87 } … … 93 93 @Test(expected = WindowGeometryException.class) 94 94 public void testWindowGeometryException4() throws WindowGeometryException { 95 Main.pref.put("test", "wrong_pattern");95 Config.getPref().put("test", "wrong_pattern"); 96 96 new WindowGeometry("test"); 97 97 } … … 103 103 @Test 104 104 public void testWindowGeometryException5() throws WindowGeometryException { 105 Main.pref.put("test", "x=15,y=55,width=200,height=100");105 Config.getPref().put("test", "x=15,y=55,width=200,height=100"); 106 106 assertNotNull(new WindowGeometry("test")); 107 107 } -
trunk/test/unit/org/openstreetmap/josm/io/remotecontrol/RemoteControlTest.java
r12842 r12849 27 27 import org.junit.Test; 28 28 import org.openstreetmap.josm.JOSMFixture; 29 import org.openstreetmap.josm. Main;29 import org.openstreetmap.josm.spi.preferences.Config; 30 30 import org.openstreetmap.josm.tools.Logging; 31 31 … … 52 52 RemoteControl.start(); 53 53 disableCertificateValidation(); 54 httpBase = "http://127.0.0.1:"+ Main.pref.getInt("remote.control.port", 8111);55 httpsBase = "https://127.0.0.1:"+ Main.pref.getInt("remote.control.https.port", 8112);54 httpBase = "http://127.0.0.1:"+Config.getPref().getInt("remote.control.port", 8111); 55 httpsBase = "https://127.0.0.1:"+Config.getPref().getInt("remote.control.https.port", 8112); 56 56 } 57 57 -
trunk/test/unit/org/openstreetmap/josm/plugins/PluginHandlerTestIT.java
r12842 r12849 28 28 import org.openstreetmap.josm.gui.layer.OsmDataLayer; 29 29 import org.openstreetmap.josm.gui.progress.NullProgressMonitor; 30 import org.openstreetmap.josm.spi.preferences.Config; 30 31 import org.openstreetmap.josm.testutils.JOSMTestRules; 31 32 … … 148 149 PluginDownloadTask pluginDownloadTask = new PluginDownloadTask(NullProgressMonitor.INSTANCE, plugins, null); 149 150 // Increase default timeout to avoid random network errors on big jar files 150 int defTimeout = Main.pref.getInt("socket.timeout.read", 30);151 Main.pref.putInt("socket.timeout.read", 2 * defTimeout);151 int defTimeout = Config.getPref().getInt("socket.timeout.read", 30); 152 Config.getPref().putInt("socket.timeout.read", 2 * defTimeout); 152 153 pluginDownloadTask.run(); 153 154 // Restore default timeout 154 Main.pref.putInt("socket.timeout.read", defTimeout);155 Config.getPref().putInt("socket.timeout.read", defTimeout); 155 156 assertTrue(pluginDownloadTask.getFailedPlugins().toString(), pluginDownloadTask.getFailedPlugins().isEmpty()); 156 157 assertEquals(plugins.size(), pluginDownloadTask.getDownloadedPlugins().size()); -
trunk/test/unit/org/openstreetmap/josm/testutils/JOSMTestRules.java
r12848 r12849 310 310 // No pref init -> that would only create the preferences file. 311 311 // We force the use of a wrong API server, just in case anyone attempts an upload 312 Main.pref.put("osm-server.url", "http://invalid");312 Config.getPref().put("osm-server.url", "http://invalid"); 313 313 } 314 314 … … 336 336 // Set API 337 337 if (useAPI == APIType.DEV) { 338 Main.pref.put("osm-server.url", "http://api06.dev.openstreetmap.org/api");338 Config.getPref().put("osm-server.url", "http://api06.dev.openstreetmap.org/api"); 339 339 } else if (useAPI == APIType.FAKE) { 340 340 FakeOsmApi api = FakeOsmApi.getInstance(); 341 Main.pref.put("osm-server.url", api.getServerUrl());341 Config.getPref().put("osm-server.url", api.getServerUrl()); 342 342 } 343 343
Note:
See TracChangeset
for help on using the changeset viewer.