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

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

cleaner output in unit tests

File size: 1.8 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.Collection;
9import java.util.HashMap;
10import java.util.Map;
11
12import org.junit.BeforeClass;
13import org.junit.Test;
14import org.openstreetmap.josm.JOSMFixture;
15import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
16import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
17import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
18
19/**
20 * Unit tests of {@link MapPaintPreference} class.
21 */
22public 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}
Note: See TracBrowser for help on using the repository browser.