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

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

sonar - squid:S00112 - Generic exceptions should never be thrown

  • Property svn:eol-style set to native
File size: 2.0 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.BeforeClass;
12import org.junit.Test;
13import org.openstreetmap.josm.JOSMFixture;
14import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker;
15import org.openstreetmap.josm.data.validation.tests.MapCSSTagChecker.ParseResult;
16import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
17
18/**
19 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
20 */
21public class ValidatorTagCheckerRulesPreferenceTestIT {
22
23 /**
24 * Setup test.
25 */
26 @BeforeClass
27 public static void setUpBeforeClass() {
28 JOSMFixture.createUnitTestFixture().init();
29 }
30
31 /**
32 * Test that available tag checker rules are valid.
33 * @throws Exception in case of error
34 */
35 @Test
36 public void testValidityOfAvailableRules() throws Exception {
37 Collection<ExtendedSourceEntry> sources = new ValidatorTagCheckerRulesPreference.TagCheckerRulesSourceEditor()
38 .loadAndGetAvailableSources();
39 assertFalse(sources.isEmpty());
40 Collection<Throwable> allErrors = new ArrayList<>();
41 MapCSSTagChecker tagChecker = new MapCSSTagChecker();
42 for (ExtendedSourceEntry source : sources) {
43 System.out.print(source.url);
44 try {
45 ParseResult result = tagChecker.addMapCSS(source.url);
46 assertFalse(result.parseChecks.isEmpty());
47 System.out.println(result.parseErrors.isEmpty() ? " => OK" : " => KO");
48 allErrors.addAll(result.parseErrors);
49 } catch (IOException e) {
50 System.out.println(" => KO");
51 allErrors.add(e);
52 e.printStackTrace();
53 }
54 }
55 assertTrue(allErrors.isEmpty());
56 }
57}
Note: See TracBrowser for help on using the repository browser.