Changeset 11978 in josm for trunk/test/unit/org/openstreetmap/josm/TestUtils.java
- Timestamp:
- 2017-04-22T21:14:24+02:00 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r11324 r11978 2 2 package org.openstreetmap.josm; 3 3 4 import static org.junit.Assert.assertEquals; 4 5 import static org.junit.Assert.fail; 5 6 … … 10 11 import java.io.InputStream; 11 12 import java.lang.reflect.Field; 13 import java.lang.reflect.Method; 12 14 import java.security.AccessController; 13 15 import java.security.PrivilegedAction; … … 29 31 import org.openstreetmap.josm.io.Compression; 30 32 import org.openstreetmap.josm.testutils.FakeGraphics; 33 import org.openstreetmap.josm.tools.JosmRuntimeException; 34 import org.openstreetmap.josm.tools.Utils; 31 35 32 36 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 286 290 }; 287 291 } 292 293 /** 294 * Ensures 100% code coverage for enums. 295 * @param enumClass enum class to cover 296 */ 297 public static void superficialEnumCodeCoverage(Class<? extends Enum<?>> enumClass) { 298 try { 299 Method values = enumClass.getMethod("values"); 300 Method valueOf = enumClass.getMethod("valueOf", String.class); 301 Utils.setObjectsAccessible(values, valueOf); 302 for (Object o : (Object[]) values.invoke(null)) { 303 assertEquals(o, valueOf.invoke(null, ((Enum<?>) o).name())); 304 } 305 } catch (IllegalArgumentException | ReflectiveOperationException | SecurityException e) { 306 throw new JosmRuntimeException(e); 307 } 308 } 288 309 }
Note:
See TracChangeset
for help on using the changeset viewer.
