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

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

make sure https is properly initialized for integration tests

  • Property svn:eol-style set to native
File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.validator;
3
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertTrue;
6
7import java.io.IOException;
8import java.util.ArrayList;
9import java.util.Collection;
10
11import org.junit.Rule;
12import org.junit.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 */
23public class ValidatorTagCheckerRulesPreferenceTestIT {
24
25 /**
26 * Setup rule
27 */
28 @Rule
29 @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
30 public JOSMTestRules test = new JOSMTestRules().https();
31
32 /**
33 * Test that available tag checker rules are valid.
34 * @throws Exception in case of error
35 */
36 @Test
37 public 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.