Changeset 17531 in josm for trunk/test/unit/org
- Timestamp:
- 2021-02-23T00:28:29+01:00 (4 years ago)
- Location:
- trunk/test/unit/org/openstreetmap/josm/gui/preferences
- Files:
-
- 3 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/unit/org/openstreetmap/josm/gui/preferences/AbstractExtendedSourceEntryTestCase.java
r17530 r17531 1 1 // License: GPL. For details, see LICENSE file. 2 package org.openstreetmap.josm.gui.preferences .map;2 package org.openstreetmap.josm.gui.preferences; 3 3 4 4 import java.util.ArrayList; … … 12 12 import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry; 13 13 14 abstract class AbstractExtendedSourceEntryTestCase { 14 /** 15 * Super class of parameterized source entry integration tests. 16 */ 17 public abstract class AbstractExtendedSourceEntryTestCase { 15 18 16 19 private static final Pattern RESOURCE_PATTERN = Pattern.compile("resource://(.+)"); … … 40 43 } 41 44 42 protected final void handleException(ExtendedSourceEntry source, Exceptione, Set<String> errors, List<String> ignoredErrors) {45 protected final void handleException(ExtendedSourceEntry source, Throwable e, Set<String> errors, List<String> ignoredErrors) { 43 46 e.printStackTrace(); 44 47 String s = source.url + " => " + e.toString(); -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTestIT.java
r17360 r17531 22 22 import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction; 23 23 import org.openstreetmap.josm.gui.mappaint.mapcss.Instruction.AssignmentInstruction; 24 import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase; 24 25 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSRule; 25 26 import org.openstreetmap.josm.gui.mappaint.mapcss.MapCSSStyleSource; -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/TaggingPresetPreferenceTestIT.java
r17360 r17531 18 18 import org.junit.jupiter.api.BeforeAll; 19 19 import org.junit.jupiter.api.extension.RegisterExtension; 20 import org.junit.jupiter.api.parallel.Execution; 21 import org.junit.jupiter.api.parallel.ExecutionMode; 20 22 import org.junit.jupiter.params.ParameterizedTest; 21 23 import org.junit.jupiter.params.provider.MethodSource; 22 24 import org.openstreetmap.josm.TestUtils; 23 25 import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry; 26 import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase; 24 27 import org.openstreetmap.josm.gui.tagging.presets.TaggingPreset; 25 28 import org.openstreetmap.josm.gui.tagging.presets.TaggingPresetReader; … … 79 82 * @throws Exception in case of error 80 83 */ 84 @Execution(ExecutionMode.CONCURRENT) 81 85 @ParameterizedTest(name = "{0} - {1}") 82 86 @MethodSource("data") -
trunk/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java
r17383 r17531 2 2 package org.openstreetmap.josm.gui.preferences.validator; 3 3 4 import static org.junit.Assume.assumeFalse; 5 import static org.junit.Assume.assumeTrue; 4 6 import static org.junit.jupiter.api.Assertions.assertFalse; 5 7 import static org.junit.jupiter.api.Assertions.assertTrue; … … 7 9 import java.io.IOException; 8 10 import java.util.ArrayList; 9 import java.util.Collection; 11 import java.util.HashSet; 12 import java.util.List; 13 import java.util.Set; 10 14 11 import org.junit.jupiter.api. Test;15 import org.junit.jupiter.api.BeforeAll; 12 16 import org.junit.jupiter.api.extension.RegisterExtension; 17 import org.junit.jupiter.api.parallel.Execution; 18 import org.junit.jupiter.api.parallel.ExecutionMode; 19 import org.junit.jupiter.params.ParameterizedTest; 20 import org.junit.jupiter.params.provider.MethodSource; 21 import org.openstreetmap.josm.TestUtils; 13 22 import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry; 14 23 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker; 15 24 import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult; 25 import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase; 16 26 import org.openstreetmap.josm.testutils.JOSMTestRules; 17 27 … … 21 31 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class. 22 32 */ 23 class ValidatorTagCheckerRulesPreferenceTestIT {33 class ValidatorTagCheckerRulesPreferenceTestIT extends AbstractExtendedSourceEntryTestCase { 24 34 25 35 /** … … 28 38 @RegisterExtension 29 39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD") 30 public JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);40 static JOSMTestRules test = new JOSMTestRules().https().timeout(20_000); 31 41 32 42 /** 33 * Test that available tag checker rules are valid. 43 * Setup test 44 * @throws IOException in case of I/O error 45 */ 46 @BeforeAll 47 public static void beforeClass() throws IOException { 48 errorsToIgnore.addAll(TestUtils.getIgnoredErrorMessages(ValidatorTagCheckerRulesPreferenceTestIT.class)); 49 } 50 51 /** 52 * Returns list of entries to test. 53 * @return list of entries to test 34 54 * @throws Exception in case of error 35 55 */ 36 @Test 37 void testValidityOfAvailableRules() throws Exception { 38 Collection<ExtendedSourceEntry> sources = new ValidatorTagCheckerRulesPreference.TagCheckerRulesSourceEditor() 39 .loadAndGetAvailableSources(); 40 assertFalse(sources.isEmpty(), sources::toString); 41 Collection<Throwable> allErrors = new ArrayList<>(); 42 MapCSSTagChecker tagChecker = new MapCSSTagChecker(); 43 for (ExtendedSourceEntry source : sources) { 44 System.out.print(source.url); 45 try { 46 ParseResult result = tagChecker.addMapCSS(source.url); 47 assertFalse(result.parseChecks.isEmpty(), result::toString); 48 System.out.println(result.parseErrors.isEmpty() ? " => OK" : " => KO"); 49 allErrors.addAll(result.parseErrors); 50 } catch (IOException e) { 51 System.out.println(" => KO"); 52 allErrors.add(e); 53 e.printStackTrace(); 54 } 56 public static List<Object[]> data() throws Exception { 57 return getTestParameters(new ValidatorTagCheckerRulesPreference.TagCheckerRulesSourceEditor() 58 .loadAndGetAvailableSources()); 59 } 60 61 /** 62 * Test that available tag checker rule is valid. 63 * @param displayName displayed name 64 * @param url URL 65 * @param source source entry to test 66 * @throws Exception in case of error 67 */ 68 @Execution(ExecutionMode.CONCURRENT) 69 @ParameterizedTest(name = "{0} - {1}") 70 @MethodSource("data") 71 void testValidityOfAvailableRule(String displayName, String url, ExtendedSourceEntry source) throws Exception { 72 assumeFalse(isIgnoredSubstring(source, source.url)); 73 List<String> ignoredErrors = new ArrayList<>(); 74 Set<String> errors = new HashSet<>(); 75 System.out.print(source.url); 76 try { 77 ParseResult result = new MapCSSTagChecker().addMapCSS(source.url); 78 assertFalse(result.parseChecks.isEmpty(), result::toString); 79 System.out.println(result.parseErrors.isEmpty() ? " => OK" : " => KO"); 80 result.parseErrors.forEach(e -> handleException(source, e, errors, ignoredErrors)); 81 } catch (IOException e) { 82 System.out.println(" => KO"); 83 e.printStackTrace(); 84 handleException(source, e, errors, ignoredErrors); 55 85 } 56 assertTrue(allErrors.isEmpty(), allErrors::toString); 86 // #16567 - Shouldn't be necessary to print displayName if Ant worked properly 87 // See https://josm.openstreetmap.de/ticket/16567#comment:53 88 // See https://bz.apache.org/bugzilla/show_bug.cgi?id=64564 89 // See https://github.com/apache/ant/pull/121 90 assertTrue(errors.isEmpty(), displayName + " => " + errors); 91 assumeTrue(ignoredErrors.toString(), ignoredErrors.isEmpty()); 57 92 } 58 93 }
Note:
See TracChangeset
for help on using the changeset viewer.