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

Last change on this file since 9973 was 9669, checked in by bastiK, 8 years ago

add missing svn:eol-style=native (see #12410)

  • 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.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.mappaint.mapcss.parsergen.ParseException;
17import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
18
19/**
20 * Integration tests of {@link ValidatorTagCheckerRulesPreference} class.
21 */
22public class ValidatorTagCheckerRulesPreferenceTestIT {
23
24 /**
25 * Setup test.
26 */
27 @BeforeClass
28 public static void setUpBeforeClass() {
29 JOSMFixture.createUnitTestFixture().init();
30 }
31
32 /**
33 * Test that available tag checker rules are valid.
34 * @throws IOException if any I/O error occurs
35 * @throws ParseException if the config file does not match MapCSS syntax
36 */
37 @Test
38 public void testValidityOfAvailableRules() throws ParseException, IOException {
39 Collection<ExtendedSourceEntry> sources = new ValidatorTagCheckerRulesPreference.TagCheckerRulesSourceEditor()
40 .loadAndGetAvailableSources();
41 assertFalse(sources.isEmpty());
42 Collection<Throwable> allErrors = new ArrayList<>();
43 MapCSSTagChecker tagChecker = new MapCSSTagChecker();
44 for (ExtendedSourceEntry source : sources) {
45 System.out.print(source.url);
46 try {
47 ParseResult result = tagChecker.addMapCSS(source.url);
48 assertFalse(result.parseChecks.isEmpty());
49 System.out.println(result.parseErrors.isEmpty() ? " => OK" : " => KO");
50 allErrors.addAll(result.parseErrors);
51 } catch (IOException e) {
52 System.out.println(" => KO");
53 allErrors.add(e);
54 e.printStackTrace();
55 }
56 }
57 assertTrue(allErrors.isEmpty());
58 }
59}
Note: See TracBrowser for help on using the repository browser.