Ticket #18441: 18441.patch
File 18441.patch, 2.9 KB (added by , 4 years ago) |
---|
-
src/org/openstreetmap/josm/data/validation/OsmValidator.java
165 165 } 166 166 } 167 167 168 /** 169 * Removes a test to the list of available tests. This will not remove core 170 * tests. 171 * 172 * @param testClass The test class 173 * @return {@code true} if the test was removed (see {@link Collection#remove}) 174 * @since xxx 175 */ 176 public static boolean removeTest(Class<? extends Test> testClass) { 177 boolean removed = false; 178 if (!Arrays.asList(CORE_TEST_CLASSES).contains(testClass)) { 179 removed = allTests.remove(testClass); 180 allTestsMap.remove(testClass.getName()); 181 } 182 return removed; 183 } 184 168 185 static { 169 186 for (Class<? extends Test> testClass : CORE_TEST_CLASSES) { 170 187 addTest(testClass); -
test/unit/org/openstreetmap/josm/data/validation/OsmValidatorTest.java
2 2 package org.openstreetmap.josm.data.validation; 3 3 4 4 import static org.junit.Assert.assertFalse; 5 import static org.junit.Assert.assertNotEquals; 5 6 import static org.junit.Assert.assertTrue; 6 7 7 8 import org.junit.Before; 8 9 import org.junit.Rule; 9 10 import org.junit.Test; 11 import org.openstreetmap.josm.data.validation.tests.Addresses; 10 12 import org.openstreetmap.josm.testutils.JOSMTestRules; 11 13 12 14 import edu.umd.cs.findbugs.annotations.SuppressFBWarnings; … … 83 85 assertTrue(OsmValidator.hasIgnoredError("1351:n_6871910559:w_733713588")); 84 86 } 85 87 88 /** 89 * Test that tests are really removed, and that core tests cannot be removed 90 */ 91 @Test 92 public void testRemoveTests() { 93 org.openstreetmap.josm.data.validation.Test test = new org.openstreetmap.josm.data.validation.Test("test") { 94 }; 95 assertNotEquals(org.openstreetmap.josm.data.validation.Test.class, test.getClass()); 96 OsmValidator.addTest(test.getClass()); 97 assertTrue(OsmValidator.getAllAvailableTestClasses().contains(test.getClass())); 98 assertTrue(OsmValidator.removeTest(test.getClass())); 99 assertFalse(OsmValidator.removeTest(test.getClass())); 100 assertFalse(OsmValidator.getAllAvailableTestClasses().contains(test.getClass())); 101 102 assertTrue(OsmValidator.getAllAvailableTestClasses().contains(Addresses.class)); 103 assertFalse(OsmValidator.removeTest(Addresses.class)); 104 assertTrue(OsmValidator.getAllAvailableTestClasses().contains(Addresses.class)); 105 } 106 86 107 }