source: josm/trunk/test/unit/org/openstreetmap/josm/gui/preferences/validator/ValidatorTagCheckerRulesPreferenceTestIT.java@ 17536

Last change on this file since 17536 was 17531, checked in by Don-vip, 3 years ago

see #16567 - consistency between extended source entry integration tests

  • Property svn:eol-style set to native
File size: 3.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.validator;
3
4import static org.junit.Assume.assumeFalse;
5import static org.junit.Assume.assumeTrue;
6import static org.junit.jupiter.api.Assertions.assertFalse;
7import static org.junit.jupiter.api.Assertions.assertTrue;
8
9import java.io.IOException;
10import java.util.ArrayList;
11import java.util.HashSet;
12import java.util.List;
13import java.util.Set;
14
15import org.junit.jupiter.api.BeforeAll;
16import org.junit.jupiter.api.extension.RegisterExtension;
17import org.junit.jupiter.api.parallel.Execution;
18import org.junit.jupiter.api.parallel.ExecutionMode;
19import org.junit.jupiter.params.ParameterizedTest;
20import org.junit.jupiter.params.provider.MethodSource;
21import org.openstreetmap.josm.TestUtils;
22import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
23import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
24import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult;
25import org.openstreetmap.josm.gui.preferences.AbstractExtendedSourceEntryTestCase;
26import org.openstreetmap.josm.testutils.JOSMTestRules;
27
28import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
29
30/**
31 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
32 */
33class ValidatorTagCheckerRulesPreferenceTestIT extends AbstractExtendedSourceEntryTestCase {
34
35 /**
36 * Setup rule
37 */
38 @RegisterExtension
39 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
40 static JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);
41
42 /**
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
54 * @throws Exception in case of error
55 */
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);
85 }
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());
92 }
93}
Note: See TracBrowser for help on using the repository browser.