1 | // License: GPL. For details, see LICENSE file.
|
---|
2 | package org.openstreetmap.josm.gui.preferences.map;
|
---|
3 |
|
---|
4 | import static org.junit.Assert.assertFalse;
|
---|
5 | import static org.junit.Assert.assertTrue;
|
---|
6 |
|
---|
7 | import java.io.IOException;
|
---|
8 | import java.util.Collection;
|
---|
9 | import java.util.HashMap;
|
---|
10 | import java.util.Map;
|
---|
11 |
|
---|
12 | import org.junit.BeforeClass;
|
---|
13 | import org.junit.Test;
|
---|
14 | import org.openstreetmap.josm.JOSMFixture;
|
---|
15 | import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
|
---|
16 | import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
|
---|
17 | import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
|
---|
18 |
|
---|
19 | /**
|
---|
20 | * Unit tests of {@link MapPaintPreference} class.
|
---|
21 | */
|
---|
22 | public class MapPaintPreferenceTest {
|
---|
23 |
|
---|
24 | /**
|
---|
25 | * Setup test.
|
---|
26 | */
|
---|
27 | @BeforeClass
|
---|
28 | public static void setUpBeforeClass() {
|
---|
29 | JOSMFixture.createUnitTestFixture().init();
|
---|
30 | }
|
---|
31 |
|
---|
32 | /**
|
---|
33 | * Test that available map paint styles 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 testValidityOfAvailableStyles() throws ParseException, IOException {
|
---|
39 | Collection<ExtendedSourceEntry> sources = new MapPaintPreference.MapPaintSourceEditor()
|
---|
40 | .loadAndGetAvailableSources();
|
---|
41 | assertFalse(sources.isEmpty());
|
---|
42 | Map<String, Collection<Throwable>> allErrors = new HashMap<>();
|
---|
43 | for (ExtendedSourceEntry source : sources) {
|
---|
44 | System.out.println(source.url);
|
---|
45 | Collection<Throwable> errors = MapPaintStyles.addStyle(source);
|
---|
46 | System.out.println(errors.isEmpty() ? " => OK" : " => KO");
|
---|
47 | if (!errors.isEmpty()) {
|
---|
48 | allErrors.put(source.url, errors);
|
---|
49 | }
|
---|
50 | }
|
---|
51 | assertTrue(allErrors.toString(), allErrors.isEmpty());
|
---|
52 | }
|
---|
53 | }
|
---|