source: josm/trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTest.java@ 8937

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

add unit tests to check validity of all map paint styles and tagging presets

File size: 1.7 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.gui.preferences.map;
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.gui.mappaint.MapPaintStyles;
15import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
16import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
17
18/**
19 * Unit tests of {@link MapPaintPreference} class.
20 */
21public class MapPaintPreferenceTest {
22
23 /**
24 * Setup test.
25 */
26 @BeforeClass
27 public static void setUpBeforeClass() {
28 JOSMFixture.createUnitTestFixture().init();
29 }
30
31 /**
32 * Test that available map paint styles are valid.
33 * @throws IOException if any I/O error occurs
34 * @throws ParseException if the config file does not match MapCSS syntax
35 */
36 @Test
37 public void testValidityOfAvailableStyles() throws ParseException, IOException {
38 Collection<ExtendedSourceEntry> sources = new MapPaintPreference.MapPaintSourceEditor()
39 .loadAndGetAvailableSources();
40 assertFalse(sources.isEmpty());
41 Collection<Throwable> allErrors = new ArrayList<>();
42 for (ExtendedSourceEntry source : sources) {
43 System.out.print(source.url);
44 Collection<Throwable> errors = MapPaintStyles.addStyle(source);
45 System.out.println(errors.isEmpty() ? " => OK" : " => KO");
46 allErrors.addAll(errors);
47 }
48 assertTrue(allErrors.isEmpty());
49 }
50}
Note: See TracBrowser for help on using the repository browser.