Changeset 9334 in josm for trunk/test/unit


Ignore:
Timestamp:
2016-01-07T01:53:58+01:00 (6 years ago)
Author:
Don-vip
Message:

see #12282 - handle warnings for mappaint styles:

  • Log warnings that occur when loading style
  • Display them in Mappaint dialog (Info action)
  • Drop redundant error icon
  • Ignore XML styles in styles validation test
  • Make styles validation test fail if at least a warning occur
Location:
trunk/test/unit/org/openstreetmap/josm/gui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/gui/layer/geoimage/ImageEntryTest.java

    r9329 r9334  
    55
    66import java.io.File;
    7 import java.io.IOException;
    87
    98import org.junit.Test;
    109import org.openstreetmap.josm.TestUtils;
    11 import org.openstreetmap.josm.io.IllegalDataException;
    12 import org.xml.sax.SAXException;
    1310
    1411/**
     
    1916    /**
    2017     * Non-regression test for ticket <a href="https://josm.openstreetmap.de/ticket/12255">#12255</a>.
    21      * @throws IllegalDataException if an error was found while parsing the data from the source
    22      * @throws IOException if any I/O error occurs
    23      * @throws SAXException if any XML error occurs
    2418     */
    2519    @Test
    26     public void testTicket12255() throws IllegalDataException, IOException, SAXException {
     20    public void testTicket12255() {
    2721        ImageEntry e = new ImageEntry(new File(TestUtils.getRegressionDataFile(12255, "G0016941.JPG")));
    2822        e.extractExif();
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/map/MapPaintPreferenceTest.java

    r9166 r9334  
    1414import org.openstreetmap.josm.JOSMFixture;
    1515import org.openstreetmap.josm.gui.mappaint.MapPaintStyles;
     16import org.openstreetmap.josm.gui.mappaint.StyleSource;
    1617import org.openstreetmap.josm.gui.mappaint.mapcss.parsergen.ParseException;
    1718import org.openstreetmap.josm.gui.preferences.SourceEditor.ExtendedSourceEntry;
     
    4142        assertFalse(sources.isEmpty());
    4243        Map<String, Collection<Throwable>> allErrors = new HashMap<>();
     44        Map<String, Collection<String>> allWarnings = new HashMap<>();
    4345        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);
     46            // Do not validate XML styles
     47            if (!"xml".equalsIgnoreCase(source.styleType)) {
     48                System.out.println(source.url);
     49                StyleSource style = MapPaintStyles.addStyle(source);
     50                System.out.println(style.isValid() ? " => OK" : " => KO");
     51                Collection<Throwable> errors = style.getErrors();
     52                Collection<String> warnings = style.getWarnings();
     53                if (!errors.isEmpty()) {
     54                    allErrors.put(source.url, errors);
     55                }
     56                if (!warnings.isEmpty()) {
     57                    allWarnings.put(source.url, warnings);
     58                }
    4959            }
    5060        }
    51         assertTrue(allErrors.toString(), allErrors.isEmpty());
     61        assertTrue(allErrors.toString()+"\n"+allWarnings.toString(), allErrors.isEmpty() && allWarnings.isEmpty());
    5262    }
    5363}
Note: See TracChangeset for help on using the changeset viewer.