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.ArrayList;
|
---|
9 | import java.util.Collection;
|
---|
10 |
|
---|
11 | import org.junit.BeforeClass;
|
---|
12 | import org.junit.Test;
|
---|
13 | import org.openstreetmap.josm.JOSMFixture;
|
---|
14 | import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
|
---|
15 | import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
|
---|
16 | import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
|
---|
17 |
|
---|
18 | /**
|
---|
19 | * Unit tests of {@link MapPaintPreference} class.
|
---|
20 | */
|
---|
21 | public 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 | }
|
---|