Changeset 14977 in josm for trunk/test
- Timestamp:
- 2019-04-09T01:32:56+02:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r14782 r14977 54 54 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 55 55 import org.openstreetmap.josm.tools.JosmRuntimeException; 56 import org.openstreetmap.josm.tools.ReflectionUtils; 56 57 import org.openstreetmap.josm.tools.Utils; 57 58 import org.openstreetmap.josm.tools.WikiReader; … … 413 414 Method values = enumClass.getMethod("values"); 414 415 Method valueOf = enumClass.getMethod("valueOf", String.class); 415 Utils.setObjectsAccessible(values, valueOf);416 ReflectionUtils.setObjectsAccessible(values, valueOf); 416 417 for (Object o : (Object[]) values.invoke(null)) { 417 418 assertEquals(o, valueOf.invoke(null, ((Enum<?>) o).name())); -
trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java
r14542 r14977 21 21 import org.openstreetmap.josm.tools.GeoPropertyIndex; 22 22 import org.openstreetmap.josm.tools.Geometry; 23 import org.openstreetmap.josm.tools.ReflectionUtils; 23 24 import org.openstreetmap.josm.tools.RightAndLefthandTraffic; 24 import org.openstreetmap.josm.tools.Utils;25 25 26 26 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 118 118 // Mock left/right hand traffic database 119 119 Field rlCache = RightAndLefthandTraffic.class.getDeclaredField("rlCache"); 120 Utils.setObjectsAccessible(rlCache);120 ReflectionUtils.setObjectsAccessible(rlCache); 121 121 Object origRlCache = rlCache.get(null); 122 122 rlCache.set(null, new GeoPropertyIndex<>(new ConstantTrafficHand(true), 24)); -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r14138 r14977 27 27 import org.openstreetmap.josm.spi.preferences.Config; 28 28 import org.openstreetmap.josm.testutils.JOSMTestRules; 29 import org.openstreetmap.josm.tools. Utils;29 import org.openstreetmap.josm.tools.ReflectionUtils; 30 30 31 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 42 42 super(mapFrame); 43 43 Field mv = SelectAction.class.getDeclaredField("mv"); 44 Utils.setObjectsAccessible(mv);44 ReflectionUtils.setObjectsAccessible(mv); 45 45 mv.set(this, new MapViewMock(new MainLayerManager())); 46 46 } -
trunk/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java
r14138 r14977 20 20 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 21 import org.openstreetmap.josm.tools.Logging; 22 import org.openstreetmap.josm.tools. Utils;22 import org.openstreetmap.josm.tools.ReflectionUtils; 23 23 24 24 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 99 99 c = klass.getDeclaredConstructor(); 100 100 } 101 Utils.setObjectsAccessible(c);101 ReflectionUtils.setObjectsAccessible(c); 102 102 if (needOuterClass) { 103 103 return c.newInstance(createInstance(klass.getDeclaringClass())); -
trunk/test/unit/org/openstreetmap/josm/gui/io/UploadDialogTest.java
r14355 r14977 4 4 import static org.junit.Assert.assertEquals; 5 5 import static org.junit.Assert.assertFalse; 6 import static org.junit.Assert.assertNull; 6 7 import static org.junit.Assert.assertTrue; 7 8 8 9 import java.awt.GraphicsEnvironment; 10 import java.util.Arrays; 9 11 import java.util.List; 10 12 import java.util.Map; 11 13 import java.util.concurrent.ConcurrentHashMap; 14 import java.util.function.Supplier; 15 12 16 import javax.swing.JButton; 13 17 import javax.swing.JOptionPane; … … 15 19 import org.junit.Rule; 16 20 import org.junit.Test; 21 import org.openstreetmap.josm.TestUtils; 17 22 import org.openstreetmap.josm.gui.ExtendedDialog; 18 import org.openstreetmap.josm.TestUtils;19 23 import org.openstreetmap.josm.io.UploadStrategySpecification; 24 import org.openstreetmap.josm.spi.preferences.Config; 20 25 import org.openstreetmap.josm.testutils.JOSMTestRules; 21 26 import org.openstreetmap.josm.testutils.mockers.ExtendedDialogMocker; 22 27 import org.openstreetmap.josm.testutils.mockers.WindowMocker; 23 28 29 import com.google.common.collect.ImmutableMap; 30 31 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 24 32 import mockit.Invocation; 25 33 import mockit.Mock; 26 27 import com.google.common.collect.ImmutableMap;28 29 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;30 34 31 35 /** … … 96 100 public Map<String, String> getTags(boolean keepEmpty) { 97 101 return new ConcurrentHashMap<>(); 102 } 103 104 @Override 105 public void forceUpdateActiveField() { 106 // Do nothing 98 107 } 99 108 } … … 214 223 assertTrue(UploadDialog.UploadAction.isUploadCommentTooShort("\u0860")); 215 224 } 225 226 private static void doTestGetLastChangesetTagFromHistory(String historyKey, Supplier<String> methodToTest, String def) { 227 Config.getPref().putList(historyKey, null); 228 Config.getPref().putInt(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, 0); 229 Config.getPref().putInt(BasicUploadSettingsPanel.HISTORY_MAX_AGE_KEY, 30); 230 assertNull(methodToTest.get()); // age NOK (history empty) 231 Config.getPref().putList(historyKey, Arrays.asList("foo")); 232 assertNull(methodToTest.get()); // age NOK (history not empty) 233 Config.getPref().putLong(BasicUploadSettingsPanel.HISTORY_LAST_USED_KEY, System.currentTimeMillis() / 1000); 234 assertEquals("foo", methodToTest.get()); // age OK, history not empty 235 Config.getPref().putList(historyKey, null); 236 assertEquals(def, methodToTest.get()); // age OK, history empty 237 } 238 239 /** 240 * Test of {@link UploadDialog#getLastChangesetCommentFromHistory} method. 241 */ 242 @Test 243 public void testGetLastChangesetCommentFromHistory() { 244 doTestGetLastChangesetTagFromHistory( 245 BasicUploadSettingsPanel.HISTORY_KEY, 246 UploadDialog::getLastChangesetCommentFromHistory, 247 null); 248 } 249 250 /** 251 * Test of {@link UploadDialog#getLastChangesetSourceFromHistory} method. 252 */ 253 @Test 254 public void testGetLastChangesetSourceFromHistory() { 255 doTestGetLastChangesetTagFromHistory( 256 BasicUploadSettingsPanel.SOURCE_HISTORY_KEY, 257 UploadDialog::getLastChangesetSourceFromHistory, 258 BasicUploadSettingsPanel.getDefaultSources().get(0)); 259 } 216 260 }
Note:
See TracChangeset
for help on using the changeset viewer.