Changeset 14528 in josm for trunk/test


Ignore:
Timestamp:
2018-12-08T23:48:44+01:00 (6 years ago)
Author:
Don-vip
Message:

see #16073 - handle ignore list

Location:
trunk/test/unit/org/openstreetmap/josm
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/TestUtils.java

    r14410 r14528  
    2525import java.util.Collection;
    2626import java.util.Comparator;
     27import java.util.List;
    2728import java.util.Objects;
    2829import java.util.Set;
    2930import java.util.concurrent.ExecutionException;
    3031import java.util.concurrent.ThreadPoolExecutor;
     32import java.util.stream.Collectors;
    3133import java.util.stream.Stream;
    3234
     
    5254import org.openstreetmap.josm.tools.JosmRuntimeException;
    5355import org.openstreetmap.josm.tools.Utils;
     56import org.openstreetmap.josm.tools.WikiReader;
    5457import org.reflections.Reflections;
    5558
     
    578581        return Utils.getSystemProperty("osm.username") != null && Utils.getSystemProperty("osm.password") != null;
    579582    }
     583
     584    /**
     585     * Returns the ignored error messages listed on
     586     * <a href="https://josm.openstreetmap.de/wiki/IntegrationTestIgnores">JOSM wiki</a> for a given test.
     587     * @param integrationTest The integration test class
     588     * @return the ignored error messages listed on JOSM wiki for this test.
     589     * @throws IOException in case of I/O error
     590     */
     591    public static List<String> getIgnoredErrorMessages(Class<?> integrationTest) throws IOException {
     592        return Arrays.stream(new WikiReader()
     593                .read("https://josm.openstreetmap.de/wiki/IntegrationTestIgnores?format=txt")
     594                .split("\\n"))
     595                .filter(s -> s.startsWith("|| " + integrationTest.getSimpleName() + " ||"))
     596                .map(s -> s.substring(s.indexOf("{{{") + 3, s.indexOf("}}}")))
     597                .collect(Collectors.toList());
     598    }
    580599}
  • trunk/test/unit/org/openstreetmap/josm/gui/preferences/imagery/ImageryPreferenceTestIT.java

    r14527 r14528  
    1515import java.util.concurrent.TimeUnit;
    1616
     17import org.junit.Before;
    1718import org.junit.Rule;
    1819import org.junit.Test;
     
    2425import org.openstreetmap.gui.jmapviewer.tilesources.ScanexTileSource;
    2526import org.openstreetmap.gui.jmapviewer.tilesources.TemplatedTMSTileSource;
     27import org.openstreetmap.josm.TestUtils;
    2628import org.openstreetmap.josm.data.Bounds;
    2729import org.openstreetmap.josm.data.coor.LatLon;
     
    5759    @Rule
    5860    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
    59     public JOSMTestRules test = new JOSMTestRules().https().projection().projectionNadGrids().timeout(10000*60);
     61    public JOSMTestRules test = new JOSMTestRules().https().preferences().projection().projectionNadGrids().timeout(10000*60);
    6062
    6163    private final Map<String, Map<ImageryInfo, List<String>>> errors = Collections.synchronizedMap(new TreeMap<>());
    6264    private final Set<String> workingURLs = Collections.synchronizedSet(new HashSet<>());
    6365
     66    private List<String> ignoredErrors;
     67
     68    /**
     69     * Setup test
     70     * @throws IOException in case of I/O error
     71     */
     72    @Before
     73    public void before() throws IOException {
     74        ignoredErrors = TestUtils.getIgnoredErrorMessages(ImageryPreferenceTestIT.class);
     75    }
     76
    6477    private boolean addError(ImageryInfo info, String error) {
    65         return errors.computeIfAbsent(info.getCountryCode(), x -> Collections.synchronizedMap(new TreeMap<>()))
     78        return !ignoredErrors.contains(error) &&
     79               errors.computeIfAbsent(info.getCountryCode(), x -> Collections.synchronizedMap(new TreeMap<>()))
    6680                     .computeIfAbsent(info, x -> Collections.synchronizedList(new ArrayList<>()))
    6781                     .add(error);
Note: See TracChangeset for help on using the changeset viewer.