Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/data/validation/OsmValidator.java
r15588 r15603 166 166 } 167 167 168 /** 169 * Removes a test from the list of available tests. This will not remove 170 * core tests. 171 * 172 * @param testClass The test class 173 * @return {@code true} if the test was removed (see {@link Collection#remove}) 174 * @since 15603 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) { -
trunk/test/unit/org/openstreetmap/josm/data/validation/OsmValidatorTest.java
r15460 r15603 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 … … 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 … … 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 }
Note:
See TracChangeset
for help on using the changeset viewer.