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

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

see #16567 - upgrade almost all tests to JUnit 5, except those depending on WiremockRule

See https://github.com/tomakehurst/wiremock/issues/684

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.validator;
3
4import static org.junit.jupiter.api.Assertions.assertFalse;
5import static org.junit.jupiter.api.Assertions.assertTrue;
6
7import java.io.IOException;
8import java.util.ArrayList;
9import java.util.Collection;
10
11import org.junit.jupiter.api.extension.RegisterExtension;
12import org.junit.jupiter.api.Test;
13import org.openstreetmap.josm.data.preferences.sources.ExtendedSourceEntry;
14import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
15import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult;
16import org.openstreetmap.josm.testutils.JOSMTestRules;
17
18import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
19
20/**
21 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
22 */
23class ValidatorTagCheckerRulesPreferenceTestIT {
24
25 /**
26 * Setup rule
27 */
28 @RegisterExtension
29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
30 public JOSMTestRules test = new JOSMTestRules().https().timeout(20_000);
31
32 /**
33 * Test that available tag checker rules are valid.
34 * @throws Exception in case of error
35 */
36 @Test
37 void testValidityOfAvailableRules() throws Exception {
38 Collection<ExtendedSourceEntry> sources = new ValidatorTagCheckerRulesPreference.TagCheckerRulesSourceEditor()
39 .loadAndGetAvailableSources();
40 assertFalse(sources.isEmpty());
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());
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 }
55 }
56 assertTrue(allErrors.isEmpty());
57 }
58}
Note: See TracBrowser for help on using the repository browser.