Changeset 11978 in josm for trunk/test/unit/org/openstreetmap
- Timestamp:
- 2017-04-22T21:14:24+02:00 (7 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 3 added
- 9 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 } -
trunk/test/unit/org/openstreetmap/josm/actions/ExtensionFileFilterTest.java
r10956 r11978 5 5 6 6 import org.junit.Test; 7 import org.openstreetmap.josm.TestUtils; 8 import org.openstreetmap.josm.actions.ExtensionFileFilter.AddArchiveExtension; 7 9 8 10 import nl.jqno.equalsverifier.EqualsVerifier; … … 47 49 .verify(); 48 50 } 51 52 /** 53 * Unit test of {@link AddArchiveExtension} enum. 54 */ 55 @Test 56 public void testEnumAddArchiveExtension() { 57 TestUtils.superficialEnumCodeCoverage(AddArchiveExtension.class); 58 } 49 59 } -
trunk/test/unit/org/openstreetmap/josm/actions/OrthogonalizeActionTest.java
r11921 r11978 11 11 import org.junit.Test; 12 12 import org.openstreetmap.josm.TestUtils; 13 import org.openstreetmap.josm.actions.OrthogonalizeAction.Direction; 13 14 import org.openstreetmap.josm.actions.search.SearchCompiler; 14 15 import org.openstreetmap.josm.data.coor.LatLon; … … 16 17 import org.openstreetmap.josm.data.osm.Node; 17 18 import org.openstreetmap.josm.data.osm.Way; 18 import org.openstreetmap.josm.gui.layer.OsmDataLayer;19 19 import org.openstreetmap.josm.io.OsmReader; 20 20 import org.openstreetmap.josm.testutils.JOSMTestRules; … … 26 26 27 27 /** 28 * Unit tests for class {@link O smDataLayer}.28 * Unit tests for class {@link OrthogonalizeAction}. 29 29 */ 30 30 public class OrthogonalizeActionTest { … … 111 111 } 112 112 } 113 114 /** 115 * Unit test of {@link Direction} enum. 116 */ 117 @Test 118 public void testEnumDirection() { 119 TestUtils.superficialEnumCodeCoverage(Direction.class); 120 } 113 121 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/DeleteActionTest.java
r11713 r11978 8 8 import org.junit.Test; 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.TestUtils; 11 import org.openstreetmap.josm.actions.mapmode.DeleteAction.DeleteMode; 10 12 import org.openstreetmap.josm.data.osm.DataSet; 11 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 43 45 } 44 46 } 47 48 /** 49 * Unit test of {@link DeleteMode} enum. 50 */ 51 @Test 52 public void testEnumDeleteMode() { 53 TestUtils.superficialEnumCodeCoverage(DeleteMode.class); 54 } 45 55 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ExtrudeActionTest.java
r11713 r11978 8 8 import org.junit.Test; 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.TestUtils; 11 import org.openstreetmap.josm.actions.mapmode.ExtrudeAction.Mode; 10 12 import org.openstreetmap.josm.data.osm.DataSet; 11 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 43 45 } 44 46 } 47 48 /** 49 * Unit test of {@link Mode} enum. 50 */ 51 @Test 52 public void testEnumMode() { 53 TestUtils.superficialEnumCodeCoverage(Mode.class); 54 } 45 55 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ImproveWayAccuracyActionTest.java
r11713 r11978 8 8 import org.junit.Test; 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.TestUtils; 11 import org.openstreetmap.josm.actions.mapmode.ImproveWayAccuracyAction.State; 10 12 import org.openstreetmap.josm.data.osm.DataSet; 11 13 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 43 45 } 44 46 } 47 48 /** 49 * Unit test of {@link State} enum. 50 */ 51 @Test 52 public void testEnumState() { 53 TestUtils.superficialEnumCodeCoverage(State.class); 54 } 45 55 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/ParallelWayActionTest.java
r10945 r11978 8 8 import org.junit.Test; 9 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.TestUtils; 11 import org.openstreetmap.josm.actions.mapmode.ParallelWayAction.Mode; 12 import org.openstreetmap.josm.actions.mapmode.ParallelWayAction.Modifier; 10 13 import org.openstreetmap.josm.data.osm.DataSet; 11 14 import org.openstreetmap.josm.gui.layer.OsmDataLayer; … … 43 46 } 44 47 } 48 49 /** 50 * Unit test of {@link Mode} enum. 51 */ 52 @Test 53 public void testEnumMode() { 54 TestUtils.superficialEnumCodeCoverage(Mode.class); 55 } 56 57 /** 58 * Unit test of {@link Modifier} enum. 59 */ 60 @Test 61 public void testEnumModifier() { 62 TestUtils.superficialEnumCodeCoverage(Modifier.class); 63 } 45 64 } -
trunk/test/unit/org/openstreetmap/josm/actions/mapmode/SelectActionTest.java
r10945 r11978 15 15 import org.junit.Test; 16 16 import org.openstreetmap.josm.Main; 17 import org.openstreetmap.josm.TestUtils; 18 import org.openstreetmap.josm.actions.mapmode.SelectAction.Mode; 19 import org.openstreetmap.josm.actions.mapmode.SelectAction.SelectActionCursor; 17 20 import org.openstreetmap.josm.data.coor.EastNorth; 18 21 import org.openstreetmap.josm.data.osm.DataSet; … … 142 145 } 143 146 } 147 148 /** 149 * Unit test of {@link Mode} enum. 150 */ 151 @Test 152 public void testEnumMode() { 153 TestUtils.superficialEnumCodeCoverage(Mode.class); 154 } 155 156 /** 157 * Unit test of {@link SelectActionCursor} enum. 158 */ 159 @Test 160 public void testEnumSelectActionCursor() { 161 TestUtils.superficialEnumCodeCoverage(SelectActionCursor.class); 162 } 144 163 } -
trunk/test/unit/org/openstreetmap/josm/actions/search/SearchCompilerTest.java
r11447 r11978 16 16 import org.openstreetmap.josm.TestUtils; 17 17 import org.openstreetmap.josm.actions.search.SearchAction.SearchSetting; 18 import org.openstreetmap.josm.actions.search.SearchCompiler.ExactKeyValue; 18 19 import org.openstreetmap.josm.actions.search.SearchCompiler.Match; 19 20 import org.openstreetmap.josm.actions.search.SearchCompiler.ParseError; … … 482 483 Paths.get(TestUtils.getRegressionDataFile(14217, "filter.txt"))), StandardCharsets.UTF_8))); 483 484 } 485 486 /** 487 * Unit test of {@link SearchCompiler.ExactKeyValue.Mode} enum. 488 */ 489 @Test 490 public void testEnumExactKeyValueMode() { 491 TestUtils.superficialEnumCodeCoverage(ExactKeyValue.Mode.class); 492 } 484 493 }
Note:
See TracChangeset
for help on using the changeset viewer.