Changeset 14100 in josm
- Timestamp:
- 2018-08-06T00:26:16+02:00 (6 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/TestUtils.java
r14092 r14100 26 26 import java.util.Comparator; 27 27 import java.util.Objects; 28 import java.util.Set; 28 29 import java.util.concurrent.ExecutionException; 29 30 import java.util.concurrent.ThreadPoolExecutor; … … 50 51 import org.openstreetmap.josm.tools.JosmRuntimeException; 51 52 import org.openstreetmap.josm.tools.Utils; 53 import org.reflections.Reflections; 52 54 53 55 import com.github.tomakehurst.wiremock.WireMockServer; … … 516 518 } 517 519 } 520 521 /** 522 * Returns all JOSM subtypes of the given class. 523 * @param <T> class 524 * @param superClass class 525 * @return all JOSM subtypes of the given class 526 */ 527 public static <T> Set<Class<? extends T>> getJosmSubtypes(Class<T> superClass) { 528 return new Reflections("org.openstreetmap.josm").getSubTypesOf(superClass); 529 } 518 530 } -
trunk/test/unit/org/openstreetmap/josm/data/osm/search/SearchCompilerTest.java
r13920 r14100 14 14 import java.util.Collection; 15 15 import java.util.Collections; 16 16 import java.util.Set; 17 18 import org.junit.Assert; 17 19 import org.junit.Rule; 18 20 import org.junit.Test; … … 39 41 import org.openstreetmap.josm.gui.tagging.presets.items.Key; 40 42 import org.openstreetmap.josm.testutils.JOSMTestRules; 43 import org.openstreetmap.josm.tools.Logging; 41 44 import org.openstreetmap.josm.tools.date.DateUtils; 42 45 43 46 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; 47 import nl.jqno.equalsverifier.EqualsVerifier; 48 import nl.jqno.equalsverifier.Warning; 44 49 45 50 /** … … 701 706 } 702 707 } 708 709 /** 710 * Unit test of methods {@link Match#equals} and {@link Match#hashCode}, including all subclasses. 711 */ 712 @Test 713 public void testEqualsContract() { 714 TestUtils.assumeWorkingEqualsVerifier(); 715 Set<Class<? extends Match>> matchers = TestUtils.getJosmSubtypes(Match.class); 716 Assert.assertTrue(matchers.size() >= 10); // if it finds less than 10 classes, something is broken 717 for (Class<?> c : matchers) { 718 Logging.debug(c.toString()); 719 EqualsVerifier.forClass(c).usingGetClass() 720 .suppress(Warning.NONFINAL_FIELDS, Warning.INHERITED_DIRECTLY_FROM_OBJECT) 721 .withPrefabValues(TaggingPreset.class, newTaggingPreset("foo"), newTaggingPreset("bar")) 722 .verify(); 723 } 724 } 725 726 private static TaggingPreset newTaggingPreset(String name) { 727 TaggingPreset result = new TaggingPreset(); 728 result.name = name; 729 return result; 730 } 703 731 } -
trunk/test/unit/org/openstreetmap/josm/gui/TableCellRendererTest.java
r12632 r14100 16 16 import org.junit.Rule; 17 17 import org.junit.Test; 18 import org.openstreetmap.josm.TestUtils; 18 19 import org.openstreetmap.josm.testutils.JOSMTestRules; 19 20 import org.openstreetmap.josm.tools.Utils; 20 import org.reflections.Reflections;21 21 22 22 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 61 61 @Test 62 62 public void testTableCellRenderer() throws ReflectiveOperationException { 63 Reflections reflections = new Reflections("org.openstreetmap.josm"); 64 Set<Class<? extends TableCellRenderer>> renderers = reflections.getSubTypesOf(TableCellRenderer.class); 63 Set<Class<? extends TableCellRenderer>> renderers = TestUtils.getJosmSubtypes(TableCellRenderer.class); 65 64 Assert.assertTrue(renderers.size() >= 10); // if it finds less than 10 classes, something is broken 66 65 JTable tbl = new JTable(2, 2);
Note:
See TracChangeset
for help on using the changeset viewer.